Hey there,

Let's say that I have these models:

*from django.contrib.auth.models import User*
*
*
*class Publisher:*
*    name = Char(x)*
*
*
*class Author:*
*    publisher = FK(Publisher)*
*    name = Char(x)*
*
*
*class Book:*
*    user = FK(User)*
*    author = FK(Author)*
*    name = Char(x)*

As we see, Book is relatad to Author and User and Author is related to
Publisher. As we know, to add a record to Book I would have to have a User
and Author instance. Something like this:

*u = User.objects.get(id=1)*
*a = Publisher.objects.get(id=1).author_set.get(id=1237)*

and then insert the book data

*Book(user=u, author=a, name='MyBook').save()*

Now, my question is: Is there any way to insert data in the same statement
as you get the Author? something like:

*Publisher.objects.get(id=1).author_set.get(id=1237).Book(x, x, x).save()*
*
*
The problem I see is that Book needs it's parent instance. Is there any way
to go around this??

Thanks a lot as usual

jhv

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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