Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#248 closed enhancement (fixed)

Add a "addtopath" command to django-admin.py

Reported by: Moof <moof@…> Owned by: Adrian Holovaty
Component: Core (Management commands) Version:
Severity: normal Keywords:
Cc: moof@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django-admin startproject is a great way to start a project, but it doesn't add the project to the python path.

As a convenience, there should either be an addtopath command, or installinpython command, or something along those lines, or maybe an option to startproject. This would create a .pth file in site-packages which would have the project's parent directory in it, so that python would pick it up as part of its path. See the documentation for the site package for more information on how .pth files work.

This has the advantage of being cross-platform, so windows people who have never used a command line don't freak out about having to work out how to set the python path, something that isn't at all obvious, and difficult to do permanently. Plus, it works for python consoles started outside of command lines, which many windows users use.

Also, setuptools has a bunch of code showing how to do this, as it's how easy_install goes about installing eggs. You may wish to copy their example of having one "django_sites.pth" file with all the paths to all the sites.

As a corollary, maybe a removefrompath command might be a good idea too.

Change History (4)

comment:1 by Adrian Holovaty, 19 years ago

Interesting idea!

comment:2 by hugo <gb@…>, 19 years ago

I did it differently in my django-fcgi.py: I just added a --projects option that uses sys.path to temorarily add a given path to the python module path. That way you don't need administrator rights and don't need to fiddle with environment variables.

comment:3 by Adrian Holovaty, 19 years ago

Component: Toolsdjango-admin.py

comment:4 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

The new manage.py thing solves this problem.

Note: See TracTickets for help on using tickets.
Back to Top