On Fri, 2006-06-16 at 16:41 +0000, char wrote:
> 
> Thanks. That's not quite what I need though because it looks like the
> IDs for his records are entered free-form in a single text field and
> then processed manually. What I need is exactly what the admin
> interface does for "edit_inline" records. I have a form with multiple
> records (either being added or edited) that all have the same parent
> object. The parent object already exists regardless of whether I'm
> adding or editing the related "edit_inline" records. I think I can use
> a ChangeManipulator for the parent object type to  add or edit the
> child records but I'm not sure how to access these related objects in
> the ChangeManipulator, either in my views.py or in my template file.

To get the related objects into your template file, you need to be able
to select them into a list or QuerySet and then pass them into the
template. So your two problems are the same: how to get at the related
objects in Python -- you have to retrieve all the possibilities first in
order to pass them into the template and then retrieve the right choice
in the form handler in order to update it in the primary object. That
last bit is usually just a matter of RelatedObject.objects.get(pk = ...)
if your form returns the primary key value, for example).

Assuming you have read [1] and also looked through the Tutorial,
particularly part 1 where it works with Poll and Choice objects and the
relations between them from Python, what bits are you finding confusing?
Accessing related objects is usually no more complicated than accessing
normal attributes on a mode (although be sure to note how getting the
data from many-to-many relations is done slightly differently to
many-to-one fields).

[1] 
http://www.djangoproject.com/documentation/db_api/#related-objects

Regards,
Malcolm


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