11👍
✅
The ModelAdmin
s __init__
method creates instances of the inline admin classes and adds them to self.inline_instances
. So setting self.inlines
to another value afterwards doesn’t change anything. You should find this post, that deals with a similiar problem very helpful!
It also makes no sense to set values like that in __init__
, since the Modeladmin instance is created once and may persist for a lot more than one request!
1👍
I would suggest making a custom template which hides inlines when the operation is “create new foo”.
Admin templates are very easy to override globally or per-object. It is a lot nicer than overriding ModelAdmin methods and properties in __init__()
.
- [Django]-Internationalizing images in django
- [Django]-Celery beat process running on Heroku sends task twice
- [Django]-Django-social-auth redirect after login
- [Django]-Django sites framework and Heroku
Source:stackexchange.com