View mixins¶
These provide additional functionality which may be useful when using django-adminlinks
-
class
adminlinks.views.ModelContext[source]¶ When working with things like
ListView,DetailViewor anything else that acts on a singlemodeltype, it may be useful to be able to access that model in the template, specifically so that theAddtemplate tag may be used even when there is no actual instance ofmodelavailable, given the class:class MyView(ModelContext, DetailView): model = MyModel
it would now be possible to render the add button, even if there is no
objectin the context:{% load adminlinks_buttons %} <!-- model is not an instance, but a class --> {% render_add_button model %}In the slightly contrived example above, if the object didn’t exist,
DetailViewwould throw aHttp404anyway, but for demonstration purposes it should illustrate the purpose ofModelContext