I would not use a dict like that, just uses more memory, I would
create a ArticleVote models, something like

http://dpaste.com/hold/109437/

I also show how I would use it in the views


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 15, 2009 at 9:17 AM, teth <godsinven...@gmail.com> wrote:
>
> Hello, I pickled a dictionary and stored it in my database like this:
> article.rating = article.rating + 1
> ratings[request.user.username] = 1
> article.rating_list = pickle.dumps(ratings)
> article.save()
>
> ratings looks like this:
> {'froob': 1, 'alik': 1, 'teth': 1}
>
> When I try and load the pickled string from the database it gives me
> the following error:
> KeyError at /article/testing123/up/
> '\x00'
>
> article/testing123 loads the article testing123 from the database and
> the /up/ is to improve the rating of it. The dictionary is to prevent
> users from rating the same article twice by putting their username as
> an index in a dictionary. What am I doing wrong? (The pickled string
> is stored in a TEXT field)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to