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 URL ordering for slug path converters.
Thanks to Sam Jennings.
Allowed overriding Role provided initkwargs in
as_view()
.Kwargs provided to
as_view()
will now take precedence over any Role provided defaults.
Fixed an error in 24.4 reversing non-routed URLs when only using a subset of roles.
Thanks to Emmanuelle Delescolle.
CRUDView
subclasses may now pass a set ofroles
toget_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_field
if not set) you may now setpath_converter
andurl_base
attributes on yourCRUDView
subclass 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"
CRUDView
will 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_list
template tag now takes the wholeview
from the context, rather than just theview.fields
.If you've overridden the
object_list.html
template and are still using theobject_list
template 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
filterset
to 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
mktemplate
management command to create an override template from the the active default templates for the specified model and CRUD action.See
./manage.py mktemplate --help
for 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.html
template. - Added basic styling and docs for the
object_confirm_delete.html
template.
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.