Skip to main content

Neapolitan with namespaces - Django CRUD views

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Nominopolitan

This is an opinionated extension package for the excellent neapolitan package. It adds these features:

  • Namespaced URL handling
  • Display related field str() value in lists and details (instead of numeric id)
  • Property fields in list views
  • Separate create form class if specified
  • Support for crispy-forms if installed in project
  • Support for rendering templates using htmx
  • Header title context for partial updates (so the title is updated without a page reload)
  • Allow specification of base_template_path (to your base.html template)
  • Allow override of all nominopolitan templates by specifying templates_path

At the moment the templates are styled using Bulma. I aim to also support the native neapolitan templates in a future release. FYI it uses django-template-partials under the hood.

This is a very early alpha release; expect many breaking changes. You might prefer to just fork or copy and use whatever you need. Hopefully some or all of these features may make their way into neapolitan over time.

Installation

With pip: pip install django-nominopolitan

Poetry: poetry add django-nominopolitan

Configuration

Add these to your settings.py:

INSTALLED_APPS = [
    ...
    "nominopolitan", # put this before neapolitan
    "neapolitan",    # this is required to use the `NominopolitanMixin`
    ...
]

Usage

The best starting point is neapolitan's docs. The basic idea is to specify model-based CRUD views using:

# neapolitan approach
class ProjectView(CRUDView):
    model = projects.models.Project
    fields = ["name", "owner", "last_review", "has_tests", "has_docs", "status"]

The nominopolitan mixin adds a number of features to this.

from nominopolitan.mixins import NominopolitanMixin
from neapolitan.views import CRUDView

class ProjectCRUDView(NominopolitanMixin, CRUDView):
    model = models.Project
    fields = [
        "name", "owner", "last_review", "has_tests", "has_docs", "status",
        ]
    form_class = forms.ProjectUpdateForm # standard neapolitan setting if needed
    # ...other standard neapolitan attributes

    namespace = "my_app_name" # specify the namespace if your urls.py has app_name = "my_app_name"

    properties = ["selected_scenario",] # if you want to include @property fields in the list view

    use_crispy = True # will default to True if you have `crispy-forms` installed
        # if you set it to True without crispy-forms installed, it will resolve to False

    create_form_class = forms.TenderCreateForm # if you want a separate create form
        # the update form always uses form_class

    base_template_path = "core/base_with_nav.html" # optional, defaults to "nominopolitan/base.html"
    templates_path = "neapolitan" # if you want to override all the templates in another app

    use_htmx = True # if you want the View, Detail, Delete and Create forms to use htmx
        # you must have `htmx` installed in your base template
        # Will only work if use_htmx is True AND you call the list view using htmx
        # in which case these templates will be returned to the same hx-target as used for the list view

    htmx_crud_target = "crudModal" # if you want to use a different htmx target for the crud forms
        # different (or the same) as the target used for the list view
        # eg you may want to target a modal for the create, read, update and delete forms
        # required use_htmx = True 

Status

Extremely early alpha. No tests. Limited docs. Suggest at this stage just use it as a reference and take what you need. It works for me.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_nominopolitan-0.0.6.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_nominopolitan-0.0.6-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file django_nominopolitan-0.0.6.tar.gz.

File metadata

  • Download URL: django_nominopolitan-0.0.6.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for django_nominopolitan-0.0.6.tar.gz
Algorithm Hash digest
SHA256 d32d3ae2c8f0cee488f29abbda5b39bd3d30b00517421a3482ebb4a3888ac5a3
MD5 32dc43a4053d0375fe6145555dcb8a39
BLAKE2b-256 3d6f00ef80fcc73a7c4def87fdb4fce40f61569f3b8812930dc28fb7f4edd877

See more details on using hashes here.

File details

Details for the file django_nominopolitan-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: django_nominopolitan-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for django_nominopolitan-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0587dcb450013da522fafef0d832f5dfa27958e1d6910900d0f935f8c2eeb7d3
MD5 244980e7ac64b2da173cb1d72af22e82
BLAKE2b-256 2bf5a5dfe13d587f4f949a769dd894d47863c06fe5d81228038c7c2db531566b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page