Model classes as containers to objects of another model

25 views
Skip to first unread message

Ajay D

unread,
Jul 19, 2016, 3:17:14 PM7/19/16
to Django users, The Other Me
Hi All,

I am fairly new to Django and find myself in the need to write to the group. 

I have a django model "A", which has an "items" attribute. "items" is a list with objects of another django model "B" (there are no relationships between A and B). Everytime I create a new instance of "A", I need to make the attributes of all of the "B" objects editable via the template/form of "A".

What would the obvious/ideal way to achieve this? 

TIA,
Aj

James Schneider

unread,
Jul 20, 2016, 12:47:54 AM7/20/16
to django...@googlegroups.com, The Other Me

You would probably create a custom form that had all of the fields that you require, with a custom form save() method that would take the form fields and save them into the right models.

https://docs.djangoproject.com/en/1.9/topics/forms/#building-a-form-in-django

Without any relationships, you have to do a bit more of the manual work yourself.

-James

Reply all
Reply to author
Forward
0 new messages