CRApp¶
-
INDEXVIEW_NAME
= 'INDEX'¶ The name of the app index view (the landing page for the app). We do not enforce this, but we assume that each app has a view with this name.
-
class
Url
(regex, view, kwargs=None, name=None)¶ Bases:
object
Url is mostly the same as func:django.conf.urls.url. You use Url to add urls to an app.
Parameters: - regex – The URL regex.
- view – The view (E.g.:
MyView.as_view()
). - kwargs – Keyword arguments for the view.
- name – The name of the view. This just have to be unique within
the
App
- the actual URL name is generated based on the app name and thedjango_cradmin.crinstance.BaseCrAdminInstance.id
.
-
class
App
(appname, request, active_viewname)¶ Bases:
object
A cradmin App.
Added to a
django_cradmin.crinstance.BaseCrAdminInstance
withdjango_cradmin.crinstance.BaseCrAdminInstance.apps
.-
appname
¶ str – The name of the app.
-
request
¶ django.http.HttpRequest – Django request object for the current request.
-
active_viewname
¶ str – The name of the view we are currently rendering.
-
appurls
= []¶ See
get_appurls()
.
-
active_viewname_is_indexview
()¶ Is the active viewname the app index view?
Returns: True
ifReturn type: bool
-
is_crinstance_rolefrontpage_app
()¶ Is this the
django_cradmin.crinstance.BaseCrAdminInstance.rolefrontpage_appname
Returns: True
if the appname of this app is the same asrequest.cradmin_instance.rolefrontpage_appname
.Return type: bool
-
reverse_appurl
(viewname, args=None, kwargs=None)¶ Works just like
django.core.urlresolvers.reverse()
, except that the name is the name given inappurls
, not the full name of the URL.This means that you should use this to reverse urls within this app.
-
reverse_appindexurl
(args=None, kwargs=None)¶ Shortcut for:
reverse_appurl(crapp.INDEXVIEW_NAME, args=args, kwargs=kwargs)
-
classmethod
build_urls
(cradmin_instance_id, appname)¶ Used internally by
django_cradmin.crinstance.BaseCrAdminInstance.urls()
to build urls for all views in the app.
Add items to the breadcrumb item list.
If you completely override the
get_breadcrumb_item_list_renderable()
method without calling super (or calling this method explicitly), this method will have no effect.Examples:
Simple example:: def add_breadcrumb_list_items(self, breadcrumb_item_list): breadcrumb_item_list.append(url='#', label='Test')
Parameters: breadcrumb_item_list (django_cradmin.crbreadcrumb.BreadcrumbItemList) – The breadcrumb item list to add items to.
Get a breadcrumb item list renderable common for all views within this app.
By default, this just uses
request.cradmin_instance.get_breadcrumb_item_list_renderable()
(seedjango_cradmin.crinstance.BaseCrAdminInstance.get_breadcrumb_item_list_renderable()
).You will normally only want to override this if you want to customize how breadcrumbs are rendered for the views in this app. If you just need to add items to the breadcrumb item list, override
add_breadcrumb_list_items()
.If you override this, remember that the breadcrumb item list from
request.cradmin_instance.get_breadcrumb_item_list_renderable()
can beNone
, so if you use that method you have to remember to handle this.Returns: - A breadcrumb item list renderable object
- or
None
.
Return type: django_cradmin.crbreadcrumb.BreadcrumbItemList
-