Smarter View
- class smarter.lib.django.views.SmarterView(**kwargs)[source]
Bases:
ViewThe foundational base view for all Smarter platform views.
This class serves as the root for every view within the Smarter application, providing a unified interface and shared functionality for web, XML, and text-based views.
All other view classes in the platform are designed to extend this base, inheriting its core logic and conventions. This approach centralizes common behaviors, such as context management, template rendering, HTML minification, and logging, enabling maintainable and scalable development across the platform.
The
SmarterViewclass is intended to be subclassed, allowing developers to build specialized views while leveraging the robust foundation it provides. It encapsulates essential mechanisms for error handling, template processing, and integration with platform-wide configuration, making it the cornerstone of the Smarter view architecture.- __init__(**kwargs)
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- classmethod as_view(**initkwargs)
Main entry point for a request-response process.
- dispatch(request, *args, **kwargs)
- property formatted_class_name: str
Returns the class name in a formatted string along with the name of this view.
- http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']
- http_method_not_allowed(request, *args, **kwargs)
- options(request, *args, **kwargs)
Handle responding to requests for the OPTIONS HTTP verb.
- property ready: bool
Returns True if the view is ready to handle requests, False otherwise.
This can be used to check if the necessary context or data is available before processing a request.
- render_clean_html(request, template_path, context=None)[source]
Render a template as a string, with comments removed and minified.
- Parameters:
request (
HttpRequest) – The HTTP request object.template_path (str) – The path to the template to render.
context (dict, optional) – The context to use for rendering the template.
- Returns:
The rendered, cleaned HTML string.
- Return type:
- setup(request, *args, **kwargs)
Initialize attributes shared by all view methods.
- view_is_async = False