Views

Base Classes & Utilities

Public Views

class django_logikal.views.generic.PublicViewMixin

Mark a class-based view public.

class django_logikal.views.generic.PublicView(**kwargs)

Bases: PublicViewMixin, View

Parent class for public views.

django_logikal.views.generic.public(view: Callable[[...], HttpResponseBase]) Callable[[...], HttpResponseBase]

Mark a view function public.

Form Views

class django_logikal.views.generic.FormView(**kwargs)

Bases: FormView, Generic

Display an improved form and render a template response.

HTMX Views

Note

The htmx extra needs to be installed for these views to function correctly.

class django_logikal.views.generic.HTMXTemplateView(**kwargs)

Bases: TemplateView

Render a htmx-enabled template.

render_block(name: str, context: dict[str, Any] | None = None) HttpResponse

Render a given block of the template.

class django_logikal.views.generic.HTMXFormView(**kwargs)

Bases: HTMXTemplateView, FormView, Generic

Display a htmx-enabled improved form and render a template response.

post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse

Process the form or validate the given form field.

Utilities

django_logikal.views.generic.redirect_to(viewname: str) Callable[[...], HttpResponseBase]

Redirect to the given view.

django_logikal.views.generic.page_not_found_view(*args: Any, **kwargs: Any) HttpResponseNotFound

Render the 404.html.j template.

django_logikal.views.generic.server_error_view(*args: Any, **kwargs: Any) HttpResponseServerError

Render the 500.html.j template.

django_logikal.views.generic.ERROR_HANDLERS = {400: <function server_error_view>, 403: <function page_not_found_view>, 404: <function page_not_found_view>, 500: <function server_error_view>}

Standard error handler views.

Authentication

Note

The auth extra needs to be installed for these views to function correctly.

Note

You need to define the following templates in your project:

  • account/account.html.j

  • account/auth.html.j

  • account/email_confirm.html.j

  • account/login.html.j

  • account/password_change.html.j

  • account/password_reset_done.html.j

  • account/password_reset_from_key.html.j

  • account/password_reset.html.j

  • account/password_set.html.j

  • account/signup.html.j

  • account/verification_sent.html.j

Note that you can use the pre-fabricated auth components in your templates, which reduce the necessary boilerplate in these templates to the minimum.

Account

class django_logikal.views.account.AuthView(**kwargs)

Bases: PublicViewMixin, HTMXFormView

Show the user authentication form.

template_name = 'account/auth.html.j'

The template to use.

form_class

alias of AuthForm

get_context_data(*args: Any, **kwargs: Any) dict[str, Any]

Insert the form into the context dict.

form_valid(form: AuthForm) HttpResponse

If the form is valid, redirect to the supplied URL.

class django_logikal.views.account.AccountView(**kwargs)

Bases: TemplateView

Show user account information.

template_name = 'account/account.html.j'

The template to use.

get_context_data(**kwargs: Any) dict[str, Any]

Return the template context.

Includes the social_accounts field containing all connected social account instances of the user.

Allauth

class django_logikal.views.allauth.SignupView(**kwargs)

Bases: PublicViewMixin, HTMXFormView, SignupView

View for signing a user up.

class django_logikal.views.allauth.LoginView(**kwargs)

Bases: PublicViewMixin, HTMXFormView, LoginView

View for logging a user in.

class django_logikal.views.allauth.PasswordResetView(**kwargs)

Bases: PublicViewMixin, HTMXFormView, PasswordResetView

Show the password reset form.

class django_logikal.views.allauth.PasswordResetFromKeyView(**kwargs)

Bases: PublicViewMixin, HTMXFormView, PasswordResetFromKeyView

View for resetting a user’s password.

class django_logikal.views.allauth.PasswordSetView(**kwargs)

Bases: HTMXFormView, PasswordSetView

View for setting the user’s password.

class django_logikal.views.allauth.PasswordChangeView(**kwargs)

Bases: HTMXFormView, PasswordChangeView

View for changing the user’s password.