# Create a urls.py file when using the startapp command.

**URL:** <https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251>\
**Category:** Django Internals\
**Created:** [November 6, 2024, 11:52pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251 "2024-11-06T23:52:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dryzera](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dryzera/32/25021_2.png) [@Dryzera](https://forum.djangoproject.com/u/Dryzera)\
**Post date:** [November 6, 2024, 11:52pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/1 "2024-11-06T23:52:19Z")

</div>

I know this discussion is old, and it’s been going on for a while. Some people are in favor, most are against it, but I’m not here to simply ask to add urls.py to the app\_templates. I’m here to ask for a small change that I’ve already made, tested, and works well.

My idea is this: since many don’t like the idea of automatically adding the urls.py, I, as a beginner developer, see a great need for this file. But how can we do this, since most people don’t like the idea of it being created automatically? Simple, when using “`python manage.py startapp example`”, we can simply add an argument to the command, making it like this: “`python manage.py startapp example --createurls`”. This is a simple example of how to end all the discussions this generates once and for all.

I am creating a prototype in the _startapp.py_ file (core). Basically, I receive this argument as a parameter, make a condition, and if it returns true, I use a variable “_urls\_content_”, go to the app directory, and with the context manager, I write the urls\_content to the file. If it returns false, it simply does nothing.

I apologize if this has already been discussed or if I have stated a concept incorrectly, I am a beginner with Django and Python as well.

**I hope this helps!**

---

<div class="post-metadata">

**Author:** ![czue](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/czue/32/1387_2.png) [@czue](https://forum.djangoproject.com/u/czue)\
**Post date:** [November 7, 2024, 3:16pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/2 "2024-11-07T15:16:37Z")

</div>

There’s some discussion about revamping `startproject` (and hopefully having multiple options) happening over here: [Add draft for extended project template by knyghty · Pull Request #98 · django/deps · GitHub](https://github.com/django/deps/pull/98)

I wonder if this is the type of thing that could also get incorporated, or at least piggyback on that work when it happens.

---

<div class="post-metadata">

**Author:** ![Dryzera](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dryzera/32/25021_2.png) [@Dryzera](https://forum.djangoproject.com/u/Dryzera)\
**Post date:** [November 7, 2024, 4:09pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/3 "2024-11-07T16:09:38Z")

</div>

Czue, in my opinion, this would only add value to the project, since creating _urls.py_ wouldn’t be mandatory, but developers who want convenience and will use the file could simply use a command to have it created automatically.

---

<div class="post-metadata">

**Author:** ![czue](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/czue/32/1387_2.png) [@czue](https://forum.djangoproject.com/u/czue)\
**Post date:** [November 8, 2024, 7:12am UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/4 "2024-11-08T07:12:36Z")

</div>

I understand that, and I know it sounds like a simple/obvious thing to add. Believe me, I’m [on your side](https://forum.djangoproject.com/t/updating-the-default-startapp-template/24193), and I would support this change.

The pushback I think you will get will be along the lines of:

- Why just this option? Shouldn’t we add more options?
- Shouldn’t there just be one way to do things? We should just pick a default and use it everywhere.
- We’ll now have to maintain mulitple options in the docs, tutorials, etc.
- We’re doing this template thing in one way in `startproject` and a totally different way in `startapp`…

Ultimately, the lesson I learned was that things that sound like simple changes, aren’t. And without getting too much in the weeds of how the django project makes decisions, I’m suggesting that based on what I understand the change-process of the project to be, that this might be a good topic to combine with the startproject DEP. That way there is (hopefully) at least a consensus that emerges on how we are going to be able to update and manage project and app templates moving forwards. Then we drop this option into that framework.

Just my two cents having gone through all this already…

---

<div class="post-metadata">

**Author:** ![carltongibson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/carltongibson/32/267_2.png) [@carltongibson](https://forum.djangoproject.com/u/carltongibson)\
**Post date:** [November 8, 2024, 1:45pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/5 "2024-11-08T13:45:06Z")

</div>

This is a duplicate of the thread here: [Updating the default startapp template](https://forum.djangoproject.com/t/updating-the-default-startapp-template/24193), as @czue already linked back to.

It’s much better to keep related conversations in one place, rather than re-raising the same topic in a new thread.

As far as I can see there’s no immediate consensus around a change here. I agree with @cory, the best way forward is the WIP DEP, which has more/better template support in its likely scope.

---

<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:** [November 8, 2024, 1:57pm UTC](https://forum.djangoproject.com/t/create-a-urls-py-file-when-using-the-startapp-command/36251/6 "2024-11-08T13:57:49Z")

</div>


