Django-Admin : OveOrride add-URL of the Foreign Key Auto-Complete "add" button / + green cross

24 views
Skip to first unread message

luigim...@gmail.com

unread,
Sep 8, 2022, 6:24:21 PM9/8/22
to Django users
Hello Community, 

Goal : adding a parameter to the add_url embedded by the green cross of a foreignkey field in the django-admin details view.


Screenshot 2022-09-08 at 12.00.39.png

Solution : pass my parameter as a widget attrs through the formfield_for_dbfield method and override the admin template : see code paste_bin

Issue
- Template gets overriden
- I can't access attrs.my_parameter or attr.my_parameter. It remains empty. 

Am I doing something wrong? Is it a bug ? 


Best, 

Louis
Reply all
Reply to author
Forward
0 new messages