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, DetailView or anything else that acts on a single model type, it may be useful to be able to access that model in the template, specifically so that the Add template tag may be used even when there is no actual instance of model available, given the class:

class MyView(ModelContext, DetailView):
    model = MyModel

it would now be possible to render the add button, even if there is no object in 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, DetailView would throw a Http404 anyway, but for demonstration purposes it should illustrate the purpose of ModelContext

get_context_data(**kwargs)[source]

Puts the model into the template context.