Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#248 closed enhancement (fixed)

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

Reported by: Moof <moof@…> Owned by: adrian
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: UI/UX:

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 Changed 10 years ago by adrian

Interesting idea!

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

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 Changed 10 years ago by adrian

  • Component changed from Tools to django-admin.py

comment:4 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

The new manage.py thing solves this problem.

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