Sorry for the confusing title. Here is a simple example to illustrate
my question:

class Item(models.Model):
    name = models.CharField()

class Manager(models.Model):
    item = models.ForeignKey(Item)


On a POST I have the PK of the Item I want to link to a new instance
of the Manager object. I am saving a new Manager object that will be
linked to the Item with the PK i have. So I can do:

item_pk = request.POST.get('item')
item = Item.objects.get(pk=item_pk)
new_manager = Manager(item=item)
new_manager.save()

...but I don't like the idea of grabbing the item object first. Is
there any way to just save the new Manager object with just the PK of
the Item, thus avoiding the database call to grab the Item object?

Thanks!

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