in blog | Carlton's latest posts |
---|---|
original entry | The first retirement project |
The week that was 2023 WK16.
After a couple of weeks of Post-Fellowing Holiday to myself — and handling only the new notifications on anything that isn’t django/django
, and even having capacity to engage on the Forum — time to get back to it.
The first retirement project then is Neapolitan, my take on quick CRUD views for Django.
The README example is the core of it…
I have a Django model:
from django.db import models
class Bookmark(models.Model):
url = models.URLField(unique=True)
title = models.CharField(max_length=255)
note = models.TextField(blank=True)
favourite = models.BooleanField(default=False)
I want easy CRUD views for it, without it taking all day:
# urls.py
from neapolitan.views import CRUDView
class BookmarkView(CRUDView):
model = Bookmark
fields = ["url", "title", "note"]
filterset_fields = [
"favourite",
]
urlpatterns = [ ... ] + BookmarkView.get_urls()
Neapolitan's CRUDView
provides the standard list, detail,
create, edit, and delete views for a model, as well as the hooks you need to
be able to customise any part of that.
CRUDView
has all the usual hooks you’d expect: get_context_data()
, get_queryset()
, get_object()
, get_form()
, and so on. You know Django: you should find it pretty intuitive to use.
I was going to keep Neapolitan under my hat for a little while longer but Jeff spotted it on GitHub, and it made Django News, so the cat’s out the bag.
Current status is alpha: I’m still deciding the final details of the api, the templates are very barebones as yet, and the docs need fleshing out, but it won’t end up looking too much different from how it is now.
Dive in, And do give it a ⭐️! 😘
All of this was part of a monumental exercise in yak shaving. In order to get anything done, you’ve always got to knock one or two other things off first. Having the whole week to focus, I’m enjoying being back able to get things done.
More to come. 🚀