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
get_allow_empty()[source]

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

get_ordering()[source]

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

get_paginate_by(queryset)[source]

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

get_paginate_orphans()[source]

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.

get_queryset()[source]

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.

paginator_class

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.

get_object(queryset=None)[source]

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_slug_field()[source]

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.

get_model_template_name()[source]

Returns the base template path.

get_query_options()[source]

Returns sqlalchemy query options.

get_queryset()[source]

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.

get_session()[source]

Returns the sqlalchemy session.

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