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

Subscription object is not JSON serializable #104

Closed
amureki opened this issue Mar 17, 2014 · 15 comments · Fixed by #163
Closed

Subscription object is not JSON serializable #104

amureki opened this issue Mar 17, 2014 · 15 comments · Fixed by #163
Assignees
Labels
Milestone

Comments

@amureki
Copy link
Member

amureki commented Mar 17, 2014

Since Django 1.6 the default session serializer uses JSON objects instead of pickle objects to circumvent potential security issues. However, the import mechanism of django-newsletter stores subscription objects which are not JSON-serializable.

Exception

http://monosnap.com/image/OWikyTx9p7xURpTwhLNEt86M5rAnYK.png
And traceback gist: https://gist.github.com/amureki/9613750

Error rising after I choose newsletter and CSV from above and press "Upload".

Workaround

This is due to the change in Django 1.6 session_serializer. Look here https://docs.djangoproject.com/en/1.6/ref/settings/#session-serializer
So, if you have Django > 1.6 and django-newsletter current version, simplest way — you should add into your settings file:

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

Solution

The solution would be to rewrite the import mechanism to store just the raw imported data in the session and create the subcription objects right before saving. Pull requests are much welcomed!

@dokterbob
Copy link
Collaborator

Hey there,

Thanks for the feedback. It seems that there are no comma’s in your CSV, is that right?

Mathijs

On 17 mrt. 2014 08:01:36, amureki [email protected] wrote:

Greetings.
Trying to import csv file with emails and getting next error:
in weekly> is not JSON serializable

csv file:
name email
[email protected](mailto:[email protected]) [email protected](mailto:[email protected])


Reply to this email directly or view it on GitHub(#104).

@amureki
Copy link
Member Author

amureki commented Mar 17, 2014

Yep, i place emails like this:

name email
[email protected] [email protected]
[email protected] [email protected]

Where should I place commas, after every email in the same cell?

@dokterbob
Copy link
Collaborator

Perhaps you might want to give me a link to the actual file.

For more info on CSV: https://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules_and_examples

@amureki
Copy link
Member Author

amureki commented Mar 17, 2014

Seems like I wrongly understood about csv format first time, but now after adding commas:
https://gist.github.com/amureki/9597340
It still returns me same error.
Something else is wrong what I can't understand.

@dokterbob
Copy link
Collaborator

Hmm. Could you give me a traceback (from DEBUG mode) and/or a screenshot?

@amureki
Copy link
Member Author

amureki commented Mar 18, 2014

Sure, here is screenshot of some traceback info:
http://monosnap.com/image/OWikyTx9p7xURpTwhLNEt86M5rAnYK.png
And traceback gist: https://gist.github.com/amureki/9613750

Error rising after I choose newsletter and CSV from above and press "Upload".

@mfoacs
Copy link

mfoacs commented Mar 18, 2014

Yup same here...any news?

@dokterbob
Copy link
Collaborator

Allow me a while to get back to this. I’m at a conference now.

@mfoacs
Copy link

mfoacs commented Mar 19, 2014

Absolutely. In the meanwhile I am having fun reading the code... :-)

@dokterbob
Copy link
Collaborator

Good! Don’t hesitate with obvious improvements. :)

@dokterbob
Copy link
Collaborator

Any updates here? Would be great to have a reproducible test case so the issue can be fixed.

@RaidoS
Copy link

RaidoS commented Sep 29, 2014

Hi, i had this error too. This is due to the change in Django 1.6 session_serializer. Look here https://docs.djangoproject.com/en/1.6/ref/settings/#session-serializer
So, if you have Django > 1.6 and django-newsletter current version, simplest way — you should add into your settings file:
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

@dokterbob
Copy link
Collaborator

Hey @RaidoS,

Thanks for the workaround. I'll have to find some time to actually solve the issue (unless someone else gets to it before me - pull req's are welcome) - but now at least your solution is in the bug report on top.

M

@martinszy
Copy link

Hi I'm using Django 1.8.1 and I got the same problem, solved the same way.

BTW: I'm using django-newsletter with cuttlefish.io as a backend to send emails and track clicks and responses, it seems to be working.

@dokterbob dokterbob added the bug label Aug 6, 2015
@dokterbob dokterbob added this to the 0.6 milestone Aug 6, 2015
@dokterbob
Copy link
Collaborator

This is a pretty serious bug and it would be great to be able to solve this before the 0.6 release.

Steps:

  1. Implement a test for the import code - this would be great to have anyways.
  2. Setup an explicit regression test for this issue.
  3. Rewrite the import mechanism to store 'raw' imported data into the session instead of the Python objects.
  4. Win!

claudep added a commit to claudep/django-newsletter that referenced this issue Jan 1, 2016
claudep added a commit to claudep/django-newsletter that referenced this issue Jan 2, 2016
claudep added a commit to claudep/django-newsletter that referenced this issue Jan 3, 2016
claudep added a commit to claudep/django-newsletter that referenced this issue Jan 3, 2016
@dokterbob dokterbob self-assigned this Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants