hi guys!
im trying to do something that trully im not sure if its possible…
so, i created a formset (using inlineformset_factory) with two models which works but im having an interesting problem… im not able to load the admin context to it … so the admin add/change forms are kind of weird (they dont have the lateral bar nor the media of the admin site or the title, etc etc… the base template needs all the basic context vars)
is it possible to load somehow the “default” context of the administrator web page in a custom view?
my way to do it might be wrong (clearly lol), not sure, although it works, is there any way around it?
Thank you!
(sorry for my bad english :D)
#admin.py
class modelAdmin(admin.ModelAdmin):
list_display = ('name', 'code')
## i override the change url of my form with a view
def get_urls(self):
urls = super().get_urls()
urls = [url for url in urls if url.name != 'app_model_add' and url.name != 'app_model_change']
custom_urls = [
path('<path:id>/change/', self.admin_site.admin_view(myview), name='app_model_change'),
]
return custom_urls + urls
# views.py
def myview(request, id=None):
#.... code ....
if request.method == 'POST':
#.... code .... which works great when creating or changing a model object
tabla_form = secondaryModelForm()
#########
### Is it possible here to load somehow the administrator context and then add my custom vars??
########
context = {
#.... code ....
# my vars for context and template
'max_q': 10000,
}
return render(request, 'admin/app/mymodeltemplate.html', context)