Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disqus_export HTTP 400: Bad Request #10

Open
kogan opened this issue Feb 28, 2011 · 3 comments
Open

disqus_export HTTP 400: Bad Request #10

kogan opened this issue Feb 28, 2011 · 3 comments

Comments

@kogan
Copy link

kogan commented Feb 28, 2011

I was getting a HTTP 400 Bad Request when exporting my django.contrib.comments. This was because the export command was not properly assigning the default value when the contrib model returned an empty string for User and User Email.

I fixed it by modifying the disqus_export.py file to perform the following tests:
author_email = '[email protected]' if not author_email else author_email
author_name = 'nobody' if not author_name else author_name

that segment of code then looked like:

        # name and email are optional in contrib.comments but required
        # in DISQUS. If they are not set, dummy values will be used
        author_email = comment.userinfo.get('email', '')
        author_email = '[email protected]' if not author_email else author_email
        author_name = comment.userinfo.get('name', '')
        author_name = 'nobody' if not author_name else author_name

        client.create_post(
            forum_api_key=forum_api_key,
            thread_id=thread['id'],
            message=comment.comment.encode('utf-8'),
            author_name=author_name.encode('utf-8'),
            author_email=author_email.encode('utf-8'),
            author_url=comment.userinfo.get('url', ''),
            created_at=comment.submit_date.strftime('%Y-%m-%dT%H:%M'))
        if state_file is not None:
            self._save_state(state_file, comment.pk)
@tylerball
Copy link

Thank you. you are a god!

@peppelorum
Copy link

This solves this issue partly. I ran into an issue when first exporting from Posterous to Django comments and then to Disqus, cause email is empty (or ''), so email is there but it's empty. So I made an extra check just to make sure it really is there, something like:

email = author_email.encode('utf-8')
if len(email) < 1:
email = '[email protected]'

@derekjamescurtis
Copy link
Contributor

I realize this was 3+ years ago, but if you still have the code, it would be SUPER nice to get it in a pull request so we could include it in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants