carltongibson / neapolitan

Quick CRUD views for Django
https://noumenal.es/neapolitan/
MIT License
413 stars 30 forks source link

Management command to create per-model template overrides. #19

Closed carltongibson closed 5 months ago

carltongibson commented 1 year ago

The default templates are good to get started, but then you find you need to customise.

The process here is to copy the (for example) object_list.html template as (for example) bookmark_list.html and then start making your changes.

A management command that found the neapolitan default (using the template loader, so allowing overrides) and then created the per-model version from that would be a nice addition.

carltongibson commented 1 year ago

An interactive CLI might be good here.

(By the time folks manually set template_name, they're on their own.)

tom-moran commented 1 year ago

Hi @carltongibson, I'm just getting started with this, neapolitian looks delicious! It really lowers the bar to getting a project started. Thanks for all your work creating and documenting it.

A couple of questions, to get me started:

carltongibson commented 1 year ago

Hey @tom-moran. That sounds like what I have in mind yes. 😊

The point about which models have a CRUDView registered would be to restrict the options to a sensible set.

Happy to input if you need.

Thanks for looking at this!

earthcomfy commented 6 months ago

Hey, what's the progress on this? I was hoping to work on it

carltongibson commented 6 months ago

@earthcomfy Please do. (This ticket crossed my mind again just the other day.)

tom-moran commented 6 months ago

Hi, sorry I dropped this one, i didn't manage to make time for it. Hope to make some space to pick up other issues.

carltongibson commented 5 months ago

I've pushed a first prototype for a mktemplate command in this branch here:

https://github.com/carltongibson/neapolitan/compare/add-mktemplate-command

It needs tests, docs, and a couple of edge-cases refined, but it's the basic idea.

% ./manage.py mktemplate my_app.MyModel --list

If someone would like to use that as the basis of a PR, that would be awesome. (Check out that branch and work against that; we can merge to main once it's worked out.)

carltongibson commented 5 months ago

Added a basic test case.

carltongibson commented 5 months ago

OK, I added some docs as well. And a change note.

Don't know if anyone wants to look at the TODO in the code, otherwise I might leave it for whoever first hits the issue. (Since it works for me the way I do it already 😅)

carltongibson commented 5 months ago

OK, this made it into the 24.2 release. https://noumenal.es/posts/neapolitan-242-released/DkK/