Createapp with crud

Hi.

I’m just curious. Django is opinionated and with batteries included.

Is it planned or maybe decided against to offer functionality to make django command createapp but with crud-views, templates and urls, maybe if the command is run with some flag? App or project templates and such decisions would just be made for us if using this option.

I think it would help all non-pros like myself and make Django a whole lot more approachable from a learning curve perspective.

Edit: Maybe what we need as well is a parameter for the the first model too or a seperate createmodel command.

All in all I am wishing for an even more opinionated framework :blush:

It sounds to me like this is an ideal case for a “cookiecutter” solution. Perhaps this one? Overview — django-crudbuilder 0.1.5 documentation

Or, if you want a jump start, take a look at Neapolitan

Or, it’s possible that your use-case here could be satisfied using something like Wagtail or Django CMS as a base product instead of raw Django.

That makes me go down the path of getting a third party library working in my project. I guess Im just wondering why the create_model_with_views_and_urls is not a built in command. I think that would tremendously help beginners.
(I did try neapolitan and liked it)

I don’t think that’s such a bad thing, for all the reasons mentioned in multiple places here in the forum and elsewhere.

I can’t think of any real project I’ve deployed that doesn’t use at least 3 external-to-django libraries, and the ability for those projects to advance without being tied to Django’s release schedule and resource limitations is a real plus.

I’ve seen multiple comments here from people who shy away from third-party libraries, and while I understand the concerns, that’s really a fact of life in the Python / Django ecosystem. (It’s also an issue shared in every other open source framework that I’ve worked with over the past 20 years.)

Yeah, cookiecutter solutions are good here because they let you pick one for your project. Django isn’t particularly opinionated on how you lay out your code, so it would be hard to define a template useful for everyone.

Also, startapp takes a --template option, so you’re free to use a template for your apps: django-admin and manage.py | Django documentation | Django . (And startproject too.)

The idea of expanding the templates has been discussed many times. Most recently, the addition of a urls.py file to startapp in Updating the default startapp template - #35 by KenWhitesell . The general consensus is that the default templates shouldn’t create too much, because practices differ between projects. Instead, using custom templates (or a package) is how to get the code generation that you want.

I didnt know the template flag. Not sure I understand it fully but I will test it out.
My takeaway is something like:
I make new app that I want to use as a template app
I make all the views, model, templates and such
I zip it
I put it in github
I use it in the command next time.
Am I sort of right?

Pretty much, but the files can be templated as well. See Django’s built-in startapp template and startproject template, and my repo of small startproject templates.

You don’t need to put templates on GitHub, they could live within your project if they are project-specific.