# Createapp scaffolds?

**URL:** <https://forum.djangoproject.com/t/createapp-scaffolds/13261>\
**Category:** Getting Started\
**Created:** [April 19, 2022, 4:30pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261 "2022-04-19T16:30:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 19, 2022, 4:30pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/1 "2022-04-19T16:30:05Z")

</div>

Is there a way to do startapp command(maybe 3rd party) so there will be urls.py and crud-urlpatterns, cet\_absolute\_url and maybe some other stuff?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 19, 2022, 4:33pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/2 "2022-04-19T16:33:30Z")

</div>

How would you do that in the absence of the models and views?

(Also, take a look at [cookiecutter](https://github.com/cookiecutter/cookiecutter) and [cookiecutter-django](https://cookiecutter-django.readthedocs.io/en/latest/index.html) to see what _has_ been done in that area.)

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 19, 2022, 5:38pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/3 "2022-04-19T17:38:19Z")

</div>

Maybe it is more like a startmodel command I am looking for.  
I am also an opinionated use of the generec cbv could do it

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 19, 2022, 6:01pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/4 "2022-04-19T18:01:14Z")

</div>

The admin already does it by building its URLs from the ModelAdmin classes.

You could effectively do this by doing your own URL decoding and dispatch - but then you’re just recreating what Django already provides. (e.g. something along the lines of `re_path('.*', my_custom_dispatcher)`)

A generic CBV _can’t_ do it, because it doesn’t get instantiated until _after_ a URL has been received and resolved, directing it to the view.

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 20, 2022, 8:33am UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/5 "2022-04-20T08:33:16Z")

</div>

I don’t think I am explaining myself properly. 🙂

I was thinking of doing a management command like “django-admin createscaffoldapp appname modelname fieldname” for example “django-admin createscaffoldapp books Book title”

Then (I think) django would be able to:

- register the app in setting
- make the \_ \_ str \_ \_ and get\_absolute\_url in the model
- make the subdir in the templates dir
- create the book\_list.html with demo of a for book in books: {{book.title}}
- create the book\_detail.html
- create the four crud views (generic)

… I think? 😇  
I know the model and app will need all the rest of the fields and content. But the above is even for me as a beginner starting to be repetitive (yet time consuming).

I do realize that some of the process like naming the specific way the urlpattern paths are designed have to be chosen for me, but as a beginner I am fully okay with that. Maybe there is a corporate standard or way most people would agree it would be okay. My guess is something like (or whatever is more agreed upon by pros):

- path(‘add/’, views.add, name=‘add’),
- path(‘edit/int:id/’, views.edit, name=‘edit’),
- path(‘delete/int:id/’, views.delete, name=‘delete’),
- path(‘insert/’, views.insert, name=‘insert’),
- path(‘update/int:id/’, views.update, name=‘update’),

I know about cookie-cutter, but I dont want to scaffold the whole project, only the individual app.

I know this mostly applies the beginners like me or maybe intermediate users (in a hurry), but I think Django could expand the project-start-supporting commands a bit more than they are right now.

Does this even make sense if you are making professional projects? (which I am not, not that anyone doubted this 😃 )

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 20, 2022, 12:35pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/6 "2022-04-20T12:35:57Z")

</div>

The misinterpretation mistake was mine. 🙂

> [@qvisty](#):
>
> I know about cookie-cutter, but I dont want to scaffold the whole project, only the individual app.

You can create a cookiecutter for just an app.

I wasn’t suggesting to use django-cookiecutter, just to point out that there is a framework available for building what you describe.

A cookiecutter, at its most fundamental layer, creates a directory and a set of files while substituting text. It’s quite practical to build what you describe using it.

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 20, 2022, 3:04pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/7 "2022-04-20T15:04:55Z")

</div>

> [@KenWhitesell](#):
>
> cookiecutter, at its most fundamental layer, creates a directory and a set of files while substituting text. It’s quite practical to build what you describe using it.

Edit: forget this: Could you or someone else point me in the right direction? I only find cookiecutter project stuff

Edit: I think I found it… [https://cookiecutter.readthedocs.io/en/1.7.2/first\_steps.html](https://cookiecutter.readthedocs.io/en/1.7.2/first_steps.html)

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 20, 2022, 3:06pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/8 "2022-04-20T15:06:41Z")

</div>

Oh wait maybe someone has already built this “app starter”?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 20, 2022, 4:04pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/9 "2022-04-20T16:04:08Z")

</div>

Also, if you want some ideas, see [GitHub - wildfish/cookiecutter-django-crud: A cookiecutter template to create a Django app around a model with CRUD views using django-vanilla-views, a floppyforms ModelForm and WebTest tests using model mommy.](https://github.com/wildfish/cookiecutter-django-crud) and [GitHub - smajda/cookiecutter-django-crud-app: A Django app template that sets up initial Create, List, Detail, and Update generic views, forms, urls, templates, and tests.](https://github.com/smajda/cookiecutter-django-crud-app)

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 20, 2022, 5:09pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/10 "2022-04-20T17:09:43Z")

</div>

> [@KenWhitesell](#):
>
> and [GitHub - smajda/cookiecutter-django-crud-app: A Django app template that sets up initial Create, List, Detail, and Update generic views, forms, urls, templates, and tests.](https://github.com/smajda/cookiecutter-django-crud-app)

This looks like it (quick look) is exactly what I was thinking of. 👍

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 22, 2022, 2:57pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/11 "2022-04-22T14:57:25Z")

</div>

… But cookiecutter keeps throwing errors… 🤔  
(cant share error msg right now. On the phone)

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 22, 2022, 6:05pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/12 "2022-04-22T18:05:56Z")

</div>

```auto
error: invalid path '{{cookiecutter.app_name}}/templates/{{cookiecutter.app_name}}/{{cookiecutter.model_name|lower}}_confirm_delete.html'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

```

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 22, 2022, 6:07pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/13 "2022-04-22T18:07:10Z")

</div>

git status

```auto
fatal: not a git repository (or any of the parent directories): .git

```

which is weird as I am trying to clone the cookiecutter from my github fork of the original repo

---

<div class="post-metadata">

**Author:** ![qvisty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/qvisty/32/4818_2.png) [@qvisty](https://forum.djangoproject.com/u/qvisty)\
**Post date:** [April 22, 2022, 6:47pm UTC](https://forum.djangoproject.com/t/createapp-scaffolds/13261/14 "2022-04-22T18:47:33Z")

</div>

I just watched a video of Django-Unicorn and it has a management command like “django-admin startunicorn Appname TemplateName” which does almost what I originally imagined without the need for CookieCutter.  
How do I go and make one of those?
