Skip to main content

Creating a CRUD View

A CRUD view connects a model, a table class, and a form class into a single endpoint that handles listing, creating, editing, and deleting records.

Extend BaseCrudView in your module's views.py:

from ...packages.crud.base import BaseCrudView
from .tables import PatientTable
from .forms import PatientForm

class PatientCrudView(BaseCrudView):
page_title = "Patients"
add_btn_title = "Add Patient" # required — must not be empty
table = PatientTable
form = PatientForm

def display_add_button_check(self, request):
return True

Required Attributes

AttributeDescription
page_titleTitle shown on the CRUD page header
add_btn_titleLabel on the "Add" button — required, never leave empty
tableYour ModelTable subclass
formYour BaseForm subclass

Wire It Up in urls.py

from django.urls import path
from .views import PatientCrudView

urlpatterns = [
path("patients/", PatientCrudView.as_view(), name="patient-crud"),
]

:::tip Always add a trailing slash URL patterns in Zango must end with / — e.g., path("patients/", ...) not path("patients", ...). :::

Register the URL in settings.json

Add the module's URL to your app's settings.json so Zango picks it up:

{
"modules": [
{
"name": "patients",
"path": "backend/patients",
"url": "patients/"
}
]
}