Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#248 closed enhancement (fixed)

Add a "addtopath" command to

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


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 Changed 14 years ago by Adrian Holovaty

Interesting idea!

comment:2 Changed 14 years ago by hugo <gb@…>

I did it differently in my 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 Changed 14 years ago by Adrian Holovaty


comment:4 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

The new thing solves this problem.

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