Class Reference¶
Template Tags¶
The logic for both
{% if_has_tag %}
and{% if not_has_tag %}
. Checks if all the given tags exist (or not exist ifnegate
isTrue
) and then only parses the branch that will not error due to non-existing tags. This means that the following is essentially the same as a{% comment %}
tag:{% if_has_tag non_existing_tag %} {% non_existing_tag %} {% endif_has_tag %}
Another example is checking a built-in tag. This will always render the current year and never FAIL:
{% if_has_tag now %} {% now "Y" %} {% else %} FAIL {% endif_has_tag %}
Tries to load a custom template tag set. Non existing tag libraries are ignored. This means that, if used in conjunction with
if_has_tag
, you can try to load the comments template tag library to enable comments even if the comments framework is not installed. For example:{% load friendly_loader %} {% friendly_load comments webdesign %} {% if_has_tag render_comment_list %} {% render_comment_list for obj %} {% else %} {% if_has_tag lorem %} {% lorem %} {% endif_has_tag %} {% endif_has_tag %}
usage example {{ your_dict|get_value_from_dict:your_key }}
Try to get an attribute from an object.
Example: {% if block|getattr:”editable,True” %}
Beware that the default is always a string, if you want this to return False, pass an empty second argument: {% if block|getattr:”editable,” %}
- Do something if all given tags are loaded::
{% load friendly_loader %} {% friendly_load webdesign %} {% if_has_tag lorem %}
{% lorem %}- {% else %}
- Non dummy content goes here!
{% endif_has_tag %}
When given multiple arguments each and every tag in the list has to be available. This means that the following will render nothing:
{% if_has_tag now nonexisting_tag %} {% now "Y" %} {% endif_has_tag %}
- Do something unless any given tag is loaded::
{% load friendly_loader %} {% friendly_load comments %} {% ifnot_has_tag render_comment_list %}
Comment support has been disabled.- {% else %}
- {% render_comment_list for obj %}
{% endifnot_has_tag %}
In the case of multiple arguments, the condition will trigger if any tag in the list is unavailable. This means that the following will still render the current year:
{% ifnot_has_tag now nonexisting_tag %} {% now "Y" %} {% endifnot_has_tag %}
Forms¶
Forms Mixin¶
Formsets¶
Views¶
View Mixins¶
Utils¶
Admin Config¶
Admin Decorators¶
-
django_webix.admin_webix.decorators.
register
(*models, site=None)[source]¶ Register the given model(s) classes and wrapped ModelWebixAdmin class with admin site: @register(Author) class AuthorAdmin(admin.ModelAdmin):
passThe site kwarg is an admin site to use instead of the default admin site.
Parameters: - models –
- site –
Returns:
Admin Options¶
Admin Sites¶
-
class
django_webix.admin_webix.sites.
AdminWebixSite
(name='admin_webix')[source]¶ -
admin_view
(view, cacheable=False)[source]¶ Decorator to create an admin view attached to this
AdminWebixSite
. This wraps the view and provides permission checking by callingself.has_permission
. You’ll want to use this from withinAdminWebixSite.get_urls()
:- class MyAdminWebixSite(AdminWebixSite):
- def get_urls(self):
from django.urls import path urls = super().get_urls() urls += [
path(‘my_view/’, self.admin_view(some_view))] return urls
By default, admin_views are marked non-cacheable using the
never_cache
decorator. If the view can be safely cached, set cacheable=True.
-
each_context
(request)[source]¶ Return a dictionary of variables to put in the template context for every page in the admin site. For sites running on a subpath, use the SCRIPT_NAME value if site_url hasn’t been customized.
-
get_app_list
(request)[source]¶ Return a sorted list of all the installed apps that have been registered in this site.
-
has_permission
(request)[source]¶ Return True if the given HttpRequest has permission to view at least one page in the admin site.
-
index
(request, extra_context=None)[source]¶ Display the main admin index page, which lists all of the installed apps that have been registered in this site.
-
logout
(request, extra_context=None)[source]¶ Log out the user for the given HttpRequest. This should not assume the user is already logged in.
-
password_change
(request, extra_context=None)[source]¶ Handle the “change password” task – both form display and validation.
-
password_change_done
(request, extra_context=None)[source]¶ Display the “success” page after a password change.
-
password_reset
(request, extra_context=None)[source]¶ Handle the “reset password” task – both form display and validation.
-
password_reset_done
(request, extra_context=None)[source]¶ Handle the “reset password” task – both form display and validation.
-
register
(model_or_iterable, admin_class=None, **options)[source]¶ Register the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn’t given, use ModelWebixAdmin (the default admin options). If keyword arguments are given – e.g., list_display – apply them as options to the admin class. If a model is already registered, raise AlreadyRegistered. If a model is abstract, raise ImproperlyConfigured.
-