ModelController and site

class djmvc.ModelController[source]

Bases: ModelMixin, Controller

CRUD controller for a single Django model.

routes

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

model

Django model class managed by this controller.

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 model name (lowercase).

has_permission(view)[source]

Check Django permissions for view via the permission backend.

get_queryset(view)[source]

Return all rows for view; override to scope per user or role.

get_json_fields()[source]

Field names exposed in JSON responses.

serialize(obj, fields=None)[source]

Map a model instance to a JSON-serializable dict.

class djmvc.Site[source]

Bases: Controller

Root site controller; autodiscovers djmvc.py in installed apps.

autodiscover()[source]

Import djmvc modules from every installed app.

build()

Instantiate child routes into a Registry.

class djmvc.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.

djmvc.site

Root Site instance. Before build(), site.routes is the declaration list — append controllers from each app’s djmvc.py with site.routes.append(...) (see Stage 0 — Register a model). Call djmvc.site.build() from your project’s urls.py to autodiscover those modules and obtain urlpatterns.