Hi,

I want build a custom api (have tried and abandoned tastypie and
restframework). I have come to the the point where I want to save a
dictionary in a django model.

Example:

class Person(models.Model):
    name          = models.CharField()
    title             = models.CharField()
class Log(models.Model):
    person  = models.ForeignKey(Person)
    action   = models.CharField()
    time     = models.DateTimeField()


I have a dictionary, and would like it to be saved to database

d = {
'person':{'name':'Joe', 'title':'Boss'},
'action':'Got to work',
'time':'2011-01-01 14:00'
}

if I do:
Log(**d)

I get error message:
Cannot assign "'person':{'name':'Joe', 'title':'Boss'}": "Log.person"
must be a "Person" instance.

How can I get django to understand that I want it to convert my
dictionary recursively? Then I want to full save it (the whole blob)
recursively, that is fields that are pointing to other models should
be saved first.


Thanks in advance

David


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