View

class djcrud.view.ViewMixin[source]

Bases: PermissionMixin, Clonable, Route

Base behaviour for every djcrud view: permissions, URLs, Unpoly defaults.

Subclasses and clones inherit permission_shortcode from the class body when set; otherwise it falls back to the view urlname.

Set unpoly_target to 'body' when the page shell differs from the default layout (for example SPA views using a template named *base_spa.html). Cross-shell navigation uses plain links (FULL_PAGE_LINK_ATTRIBUTES) so scripts such as Svelte components load correctly.

setup(request, *args, **kwargs)[source]

Track the active view on the request for cross-shell link wiring.

property unpoly

Unpoly request headers exposed to templates as view.unpoly.mode, etc.

property urlpatterns

Single Django URL pattern dispatching to this view class.

property title

Human-readable label with the View suffix removed.

property breadcrumb_title

Breadcrumb label; defaults to title.

property color

Bulma button/icon color; override on model-backed views.

property codename

URL segment with the view suffix removed from the class name.

dispatch(request, *args, **kwargs)[source]

Redirect anonymous users to login; return 403 when permission denied.

property permission_shortcode

Django permission prefix (add, change, view, …).

property permission_codename

Permission codename, e.g. view_document.

property permission_fullcode

Fully qualified permission string, e.g. myapp.view_document.

has_permission()[source]

Return whether the current user may access this view.

breadcrumbs(with_self=True)[source]

Return breadcrumb trail; override in object views.

Return Unpoly attrs for navigating from this page to target_view.

unpoly_attributes(context=None)[source]

HTML attributes for Unpoly navigation on this view.

querystring(**params)[source]

Current GET query string with params merged in.

class djcrud.view.View(**kwargs)[source]

Bases: ViewMixin, View

Minimal djcrud view for custom non-generic handlers.

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.