Opened 11 years ago
Last modified 4 years ago
#21528 closed Cleanup/optimization
improve Django Doc with an example for formfield_for_foreignkey accessing parent ID — at Initial Version
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Please,
Could you add an example for formfield_for_foreignkey (
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey) showing how to access parent ID for filtering a foreignkey.
I saw on http://www.stereoplex.com/blog/filtering-dropdown-lists-in-the-django-admin
parent_id = request.METAPATH_INFO.strip('/').split('/')[-1]
Clearly it's not ideal.
Thanks!
Note:
See TracTickets
for help on using tickets.