From a92ad4baf5b30462c3572a649f5e67d766b0a431 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 22 Jul 2024 15:50:51 +0200 Subject: [PATCH] Added Project-level Overrides How-To to docs. --- docs/source/how-tos.rst | 28 ++++++++++++++++++++++++++++ docs/source/index.rst | 1 + 2 files changed, 29 insertions(+) create mode 100644 docs/source/how-tos.rst diff --git a/docs/source/how-tos.rst b/docs/source/how-tos.rst new file mode 100644 index 0000000..457e297 --- /dev/null +++ b/docs/source/how-tos.rst @@ -0,0 +1,28 @@ +======= +How Tos +======= + + +Project-level Overrides +======================= + +Maybe ``CRUDView`` doesn't work exactly how you want. Maybe you need to +override something whilst experimenting. + +You can add a base-class of your own to add project-level overrides. + +In your ``views.py``:: + + from neapolitan.views import CRUDView as BaseCRUDView + + + class CRUDView(BaseCRUDView): + # Add your overrides here. + + + class MyModelCRUDView(CRUDView): + model = "MyModel" + fields = ["name", "description"] + +By defining your base-class like this, you can revert to Neapolitan's class +simply by commenting it out, or deleting it, and adjusting the import. diff --git a/docs/source/index.rst b/docs/source/index.rst index 782e060..789ee11 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,6 +25,7 @@ Contents tutorial crud-view templates + how-tos A quick look