Sorry if there is an obvious answer to this, but I couldn't find it.

Based off of the following:

class ObjectA(models.model):
    name = models.CharField(length=20)

class ObjectB(models.model):
    name = models.CharField(length=20)
    a = models.ForeignKey(ObjectA, related_name="bs")


In the view I do this:

a = get_object_or_404(ObjectA, pk=object_a_id)
b = a.bs.get(id=request.POST.get('b_id', False))
b.name = 'some new name'

This objects in a.bs are not updated.  Shouldn't the get procedure
return a reference?  If not how do I do this.  I need to access the
foreign key by id and have it updated in the parent object.  The only
way I could find to do this is to loop through a.bs.all() list until I
found the matching id and modify the object that way, but that isn't
nearly as neat and clean.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to