Should manage.py startapp create a urls.py file?

972 views
Skip to first unread message

Rob Hudson

unread,
Feb 4, 2008, 12:53:11 PM2/4/08
to Django developers
If it's common advice to make apps portable and bundle urls along with
an app, shouldn't manage.py startapp also drop in a default urls.py
file?

I realize it's simple to create a skeleton file yourself, but if
manage.py did it, it's one less thing to think about and do, and also
promotes good url bundling.

--
kthnxbye,
-Rob

Brian Rosner

unread,
Feb 4, 2008, 1:34:30 PM2/4/08
to django-d...@googlegroups.com
> If it's common advice to make apps portable and bundle urls along with
> an app, shouldn't manage.py startapp also drop in a default urls.py
> file?

-1. While Django is a web framework it would seem logical for a urls.py
to be created with startapp. However, I am sure the original design
decision was that it would tie this to much to a HttpRequest object
being present which isn't always the case.

IMHO, I think that having a urls.py created automatically is beneifical
and it shouldn't stop there. A forms.py is very useful and once
newforms-admin is merged in an admin.py. I feel that if something like
this should happen it will happen in other skeletons. Perhaps startapp
should take an argument like http that would create a skeleton based on
things needed in that environment.


--
Brian Rosner
http://oebfare.com


Alex Koshelev

unread,
Feb 4, 2008, 1:39:35 PM2/4/08
to Django developers
No, only startproject creates project-wide urls.py

ludvig.ericson

unread,
Feb 11, 2008, 2:58:12 PM2/11/08
to Django developers
+0, but I think it's the wrong way to go about it. What is needed is
an easy way to add to the skeleton, on a per-user (or rather, per-
Python?) installation basis. Not saying that all files from a certain
directory should be copied if they exist, rather something like:

python manage.py startapp --skeleton=/home/user/django-skel foo-
app

Ludvig

Empty

unread,
Feb 12, 2008, 12:11:24 AM2/12/08
to django-d...@googlegroups.com
Rob,

If you want, check out the django-command-extensions project on Google
Code (http://code.google.com/p/django-command-extensions/). I added a
create_app command extension that allows you to use a --template
option for specifying your app directory structure. If no template is
provided a default is created for you which includes a forms.py and a
urls.py.

It's been on my todo list for a while now, so your discussion item
prompted me to get it done. That said it has not been tested much.

Michael Trier
blog.michaeltrier.com

Reply all
Reply to author
Forward
0 new messages