django_sorcery.views.base module

Base model view things with sqlalchemy.

class django_sorcery.views.base.BaseMultipleObjectMixin[source]

Bases: django_sorcery.views.base.SQLAlchemyMixin

Provides sqlalchemy support for list views.

allow_empty = True

Return True if the view should display empty lists and False if a 404 should be raised instead.


Return the field or fields to use for ordering the queryset.


Get the number of items to paginate by, or None for no pagination.


Return the maximum number of orphans extend the last page by when paginating.

get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)[source]

Return an instance of the paginator for this view.


Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

ordering = None
page_kwarg = 'page'
paginate_by = None
paginate_orphans = 0
paginate_queryset(queryset, page_size)[source]

Paginate queryset.


alias of django.core.paginator.Paginator

class django_sorcery.views.base.BaseSingleObjectMixin[source]

Bases: django_sorcery.views.base.SQLAlchemyMixin

Provides sqlalchemy support for detail views.


Return the object the view is displaying.

Require self.queryset and the primary key attributes or the slug attributes in the URLconf. Subclasses can override this to return any object


Get the name of a slug field to be used to look up by slug.

object = None
query_pkg_and_slug = False
slug_field = 'slug'
slug_url_kwarg = 'slug'
class django_sorcery.views.base.SQLAlchemyMixin[source]

Bases: django.views.generic.base.ContextMixin

Provides sqlalchemy model view support like query, model, session, etc..

context_object_name = None
classmethod get_model()[source]

Returns the model class.


Returns the base template path.


Returns sqlalchemy query options.


Return the QuerySet that will be used to look up the object.

This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.


Returns the sqlalchemy session.

model = None
query_options = None
queryset = None
session = None