Skip to content

Conversation

@dalrrard
Copy link
Contributor

Description

django-admin has a --template flag that lets you specify a directory to
base new apps off of. I've added a startapp_template directory to the
top level directory, updated the post gen hook to remove any files that
may not be needed, and updated the documentation for this new process.

Checklist:

  • I've made sure that tests/test_cookiecutter_generation.py is updated accordingly (especially if adding or updating a template option)
  • I've updated the documentation or confirm that my change doesn't require any updates

Rationale

This lets people semi-automatically create new apps without doing a lot of manual file moving and editing.

Fix #1876
Fix #1725
Fix #1505
Fix #881

django-admin has a --template flag that lets you specify a directory to
base new apps off of. I've added a `startapp_template` directory to the
top level directory, updated the post gen hook to remove any files that
may not be needed, and updated the documentation for this new process.
@Manjit2003
Copy link
Contributor

Please approve this :(

@browniebroke
Copy link
Member

I'm a bit on the edge with this: while it's solving the problem, I find it a bit odd to have an new app template in the repo. After all, the startapp command accepts an URL as template. But maybe having it in the repo means that it can evolve with each person taste...

# Conflicts:
#	docs/troubleshooting.rst
#	hooks/post_gen_project.py
@cjauvin
Copy link
Contributor

cjauvin commented May 24, 2025

I use cookiecutter-django with enough time passing between my generation runs that every single time I find myself struggling with the issue of app creation. Very recently it happened again, and even though you added some extra instructions in the manual to deal with this issue:

https://cookiecutter-django.readthedocs.io/en/latest/2-local-development/developing-locally.html#creating-your-first-django-app

the thing is that you only added it in the local dev section:

https://cookiecutter-django.readthedocs.io/en/latest/2-local-development/developing-locally.html

but not in the local dev with docker section:

https://cookiecutter-django.readthedocs.io/en/latest/2-local-development/developing-locally-docker.html

and in my mind at least, these two sections are optional, not sequential (so I only read the docker one, and missed those instructions, and was confused again).

So I started to think how I could try to solve this by proposing a PR with some automated post gen hook with the startapp command, but I came here first and saw this still open PR.

So as an experienced but casual Django developer, I would say this is definitely a pain point that should be addressed in this otherwise excellent and tasty cookiecutter recipe.

@luzfcb
Copy link
Collaborator

luzfcb commented May 29, 2025

There is a discussion about possible changes to django startapp and maybe this is a good place to contribute and maybe make the django app creation API easier to extend django/deps#98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants