ModelRouter and site

class djcrud.ModelRouter[source]

Bases: ModelMixin, Router

CRUD router for a single Django model.

routes

Default list, detail, create, update, delete, and bulk-delete views. Extend with ModelRouter.routes + [MyView] or replace entries by codename (see Registry).

model

Django model class managed by this router.

icon

Bootstrap Icons name for the navigation list view.

Type:

str

color

Bulma color for the navigation list icon.

Type:

str

property codename

URL segment from the router class name (kebab-case) or model.

has_permission(*, user, model, action, perm, obj=None)[source]

Return whether user may perform action via the permission registry.

get_queryset(*, user, model, action, perm, obj=None)[source]

Return rows visible to user via the permission registry, then all rows.

class djcrud.Site[source]

Bases: Router

Root site router; autodiscovers djcrud.py in installed apps.

autodiscover()[source]

Import djcrud modules from every installed app.

build()

Instantiate child routes into a Registry.

ensure_built()[source]

Ensure discovery and registry are populated (idempotent).

Use this in error handlers, site search, debug tools, agents, etc. where you need the routes outside normal URLconf evaluation.

class djcrud.Home(**kwargs)[source]

Bases: TemplateView

Site root page at /.

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

has_permission()[source]

Allow anonymous access to the home page.

djcrud.site

Root Site instance. Before build(), site.routes is the declaration list — append routers from each app’s djcrud.py with site.routes.append(...) (see Routing). Call djcrud.site.build() from your project’s urls.py to autodiscover those modules and obtain urlpatterns.

After build, inspect the URL tree with python manage.py show_urls (see Routing).