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
CalendarEntryof therequest.user.This mixin uses
get_context_data()to provide all of the user’sCalendarEntryinstances for the context.- get_context_data(**kwargs)¶
- class calingen.views.mixins.ProfileIDMixin¶
Injects the
Profileid of therequest.userinto the context.This mixin uses
get_context_data()to inject theprofile_id.The mixin can safely be used on any
Viewthat 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_managerwith itsfilter_by_user()method.The view, that uses this mixin, must provide the attribute
modelto 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.Manageras provided bycalingen_manageron all of the app’s models. All of these managers rely on an app- and model-specific implementation ofdjango.db.models.QuerySetthat 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
modelhas to be defined on the view.