Banana specific Django View Mixins¶
To fit our specific requirements we created Django View Mixins that extend the default behavior. They are used in various views in the banana app.
The mixins¶
-
class
banana.views.mixins.
DatasetMixin
[source]¶ Mixin view that adds the ‘dataset’ request variable to the context.
-
class
banana.views.mixins.
FluxViewMixin
[source]¶ Mixin view that adds the ‘flux_prefix’ request variable to the context.
-
class
banana.views.mixins.
HybridTemplateMixin
[source]¶ Assigns a default
template_name
, and checks the request for a format.If the format specified in the querystring is json or csv, this will change the
content_type
andtemplate_name
accordingly.If template name is not explicitly set, we assign one based on the object or model in the view. We derive the template path as:
<app_label>/<object_name.lower()><template_name_suffix><extension>where
template_name_suffix
is something like ‘_list’ or ‘_detail’ (inherited from the Django standard class views) e.g.:banana/extractedsource_list.html
banana/extractedsource_detail.html