Monday, May 17, 2010

pass related_name-s into Model.objects.create()?

Djangoids:

The documentation for Model.objects.create(**kwargs) just sez
"**kwargs".

What goes in the kwargs? Anything beside the obvious - the scalar
members of the model?

How about one-to-many relationships? Can I do this:

Author.objects.create( name='Cromskey',
blogs=[ b1, b2,
Blog.objects.create(title='yack
yack yack') ] )

In my hypothetical kwargs, the related_name accepts an array of the
target models.

Do the kwargs support this convenience? Or must I simply plug the
items in the old-fashioned way, after they are created?

--
Phlip
http://c2.com/cgi/wiki?ZeekLand

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate