Neapolitan is still in alpha stage. It won't change much but I'm still working out the fine details of the API.
The provided templates (in particular) will evolve as needed without notice until we get closer to a resting place. If a change affects you, you can copy to templates as were to your own project, and go from there.
Version numbers correspond to git tags. Please use the compare view on GitHub for full details. Until we're further along, I will just note the highlights here:
Fixed an error in 24.4 reversing non-routed URLs when only using a subset of roles.
Thanks to Emmanuelle Delescolle.
CRUDViewsubclasses may now pass a set ofrolestoget_urls()in order to route only a subset of all the available CRUD roles.As an example, to route only the list and detail views, the README/Quickstart example would become:
from neapolitan.views import CRUDView, Role from .models import Bookmark class BookmarkView(CRUDView): model = Bookmark fields = ["url", "title", "note"] filterset_fields = [ "favourite", ] urlpatterns = [ *BookmarkView.get_urls(roles={Role.LIST, Role.DETAIL}), ]In order to keep this logic within the view here, you would likely override
get_urls()in this case, rather than calling it from the outside in your URL configuration.As well as setting the existing
lookup_field(which defaults to"pk") andlookup_url_kwarg(which defaults tolookup_fieldif not set) you may now setpath_converterandurl_baseattributes on yourCRUDViewsubclass in order to customise URL generation.For example, for this model and
CRUDView:class NamedCollection(models.Model): name = models.CharField(max_length=25, unique=True) code = models.UUIDField(unique=True, default=uuid.uuid4) class NamedCollectionView(CRUDView): model = NamedCollection fields = ["name", "code"] lookup_field = "code" path_converter = "uuid" url_base = "named-collections"CRUDViewwill generate URLs such as/named-collections/,/named-collections/<uuid:code>/, and so on. URL patterns will be named usingurl_base: "named-collections-list", "named-collections-detail", and so on.Thanks to Kasun Herath for preliminary discussion and exploration here.
BREAKING CHANGE. In order to facilitate the above the
object_listtemplate tag now takes the wholeviewfrom the context, rather than just theview.fields.If you've overridden the
object_list.htmltemplate and are still using theobject_listtemplate tag, you will need to update your usage to be like this:{% object_list object_list view %}
Improved app folder discovery in mktemplate command.
Thanks to Andrew Miller.
Added the used
filtersetto list-view context.Added CI testing for supported Python and Django versions. (Python 3.10 onwards; Django 4.2 onwards, including the development branch.)
Thanks to Josh Thomas.
Added CI build for the documentation.
Thanks to Eduardo Enriquez
Added the
mktemplatemanagement command to create an override template from the the active default templates for the specified model and CRUD action.See
./manage.py mktemplate --helpfor full details.
- Fixed an incorrect type annotation, that led to incorrect IDE warnings.
- Adjusted object form template for multipart forms.
- Added a
{{ delete_view_url}}context variable for the form action to theobject_confirm_delete.htmltemplate. - Added basic styling and docs for the
object_confirm_delete.htmltemplate.
Adds the beginnings of some TailwindCSS styling to the provided templates. See the guide here for integrating TailwindCSS with Django.
- These are merely CSS classes, so you can ignore them, or override the templates if you're not using Tailwind.
- The templates docs now have an introductory sections about the templates to give a bit of guidance there.
The <form> element in the object_form.html template has a .dl-form
class applied, to go with the styles used in the object_detail.html.
- This assumes you're using Django's new div-style form rendering.
- This needs a Tailwind plugin to be applied, which is still under-development. Please see see issue #8 for an example snippet that you can add to your Tailwind configuration now.
- Adjusted object-view action links to include the detail view link.
To 23.7: initial exploratory work.