Borrowing functionality from Django Admin forms

29 views
Skip to first unread message

Justin Johnson

unread,
Mar 7, 2018, 3:11:18 PM3/7/18
to Django users
I have a user who saw how new objects can be created using the Admin forms, and asked if I could reproduce some of that functionality.  I'm still new to Django, and even newer to building forms.  I'm wondering if there is a way to "borrow" elements from the Admin forms into my own forms and templates.  Particularly, I would like the ability to create a new related object by clicking the "+" sign next to that dropdown list on another form.

I have not been able to find much documentation on how the Admin forms are constructed for a given Django project.  I understand the basic form construction method, but I can't seem to find the equivalent workings in the Admin site.  Where is the equivalent of urls.py, where the links are mapped to specific Views?  Where are the equivalents of the Views, where a context is created and sent to the template?

I would like to get more familiar with the working code behind Django, and eventually contribute to the project, so feel free to get technical.

Thx.


Andy

unread,
Mar 8, 2018, 3:41:06 AM3/8/18
to Django users
Take a deeper look at the RelatedFieldWidgetWrapper (https://github.com/django/django/blob/1.3.2/django/contrib/admin/widgets.py#L200)
Reply all
Reply to author
Forward
0 new messages