calingen.views.mixins
¶
App-specific mixins to be used with class-based views.
Module Contents¶
Classes¶
Add all |
|
Injects the |
|
Limits the resulting queryset to objects, that belong to the current user. |
- class calingen.views.mixins.AllCalendarEntriesMixin¶
Add all
CalendarEntry
of therequest.user
.This mixin uses
get_context_data()
to provide all of the user’sCalendarEntry
instances for the context.- get_context_data(**kwargs)¶
- class calingen.views.mixins.ProfileIDMixin¶
Injects the
Profile
id of therequest.user
into the context.This mixin uses
get_context_data()
to inject theprofile_id
.The mixin can safely be used on any
View
that also uses thedjango.contrib.auth.mixins.LoginRequiredMixin
.- get_context_data(**kwargs)¶
- class calingen.views.mixins.RestrictToUserMixin¶
Limits the resulting queryset to objects, that belong to the current user.
This mixin overwrites the view’s
get_queryset()
method and automatically uses the model’s app-specificcalingen_manager
with itsfilter_by_user()
method.The view, that uses this mixin, must provide the attribute
model
to actually make this mixin usable by any class-based view of the app.- get_queryset()¶
Return a queryset that only contains objects, that belong to the current user.
Internally, the returned queryset will use the app- and model-specific implementation of
django.db.models.Manager
as provided bycalingen_manager
on all of the app’s models. All of these managers rely on an app- and model-specific implementation ofdjango.db.models.QuerySet
that provide a model-specific methodfilter_by_user()
.- Returns:
The actual returned QuerySet is provided by the model’s app-specific manager
calingen_manager
.- Return type:
django.db.models.QuerySet
- Raises:
django.core.exceptions.ImproperlyConfigured – The attribute
model
has to be defined on the view.