I've written a custom field (I'm using Django nonrel) for storing
users in a SetField. The SetField doesn't seem to handle serialising
the set of User objects properly, so what I've done is implement the
pre_save method, which returns a set of strings which are the ids in
MongoDB.

The documentation states that pre_save is for converting complex
Python types to database types, which is working great. The problem
is, the documentation states this for Field.to_python; "Converts a
value as returned by your database (or a serializer) to a Python
object."

I'd expect that the database is returning a set of strings (which are
the ids) but it's actually returning a list of User objects. From
this, I would then expect that accessing the field on a model would
return a set of User objects, but it's returning a set of string
objects.

So to_python is receiving and returning a set of User objects, but
accessing the model's users attribute returns the raw database value.
How can I get my custom field to return the set of User objects
properly?

-- 
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