Django

Code

Ticket #6789 (closed: fixed)

Opened 6 months ago

Last modified 6 months ago

[patch]django-admin.py warning on usage of python mod name as project name

Reported by: Garion Assigned to: thejaswi_puthraya
Milestone: Component: django-admin.py
Version: SVN Keywords: django-admin.py warn project name
Cc: thejaswi.puthraya@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

First of all, kudos on a very clear and thorough tutorial. The steps are small enough not to skip things, but large enough to get somewhere. I have a small suggestion for improvement though:

Tutorial01 says:

"You’ll need to avoid naming projects after built-in Python or Django components. In particular, this means you should avoid using names like django (which will conflict with Django itself) or site (which conflicts with a built-in Python package)."

I understood this, so I chose the name 'bdb' for my project, which is not a python keyword. This name led to a correct project start, but as soon as I ran ./manage.py runserver, there was an error about not being able to find bdb.settings. This in turn led me (and #django) to think there was a problem with module paths. It took us about half an hour before we figured out that 'bdb' is an existing python module, and that was the cause of the problems.

So, it would be even better if the above text also said how you can check this: "After you've chosen a name for your project, start the python interactive shell and type 'import projectname'. If this succeeds, the name you've chosen is already in use, and you must choose another name."

Or, alternatively, it would be great if django-admin.py startproject namehere tried "import namehere", and if that succeeds, tell the user to choose another name.

Attachments

6789.diff (1.1 kB) - added by thejaswi_puthraya on 03/17/08 10:11:26.
diff for the ticket #6789

Change History

03/16/08 13:39:29 changed by Garion

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

03/17/08 10:11:26 changed by thejaswi_puthraya

  • attachment 6789.diff added.

diff for the ticket #6789

03/17/08 10:14:15 changed by thejaswi_puthraya

  • status changed from new to assigned.
  • cc set to thejaswi.puthraya@gmail.com.
  • component changed from Uncategorized to django-admin.py.
  • summary changed from Suggestion for textual improvement tutorial01 to [patch]Suggestion for textual improvement tutorial01.
  • owner changed from nobody to thejaswi_puthraya.
  • keywords changed from tutorial to django-admin.py warn project name.
  • has_patch set to 1.
  • stage changed from Unreviewed to Accepted.

Added the patch that first checks if the module can be imported ie is a standard module or a module in the current directory. Next if it was not imported then it checks in the INVALID_PROJECT_NAMES to check if it exists in that list.

03/17/08 23:11:57 changed by thejaswi_puthraya

  • summary changed from [patch]Suggestion for textual improvement tutorial01 to [patch]django-admin.py warning on usage of python mod name as project name.

03/19/08 10:10:31 changed by mtredinnick

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7320]) Fixed #6789 -- Added some small amount of extra protection for learners trying to pick a name for their project. Thanks, thejaswi_puthraya.


Add/Change #6789 ([patch]django-admin.py warning on usage of python mod name as project name)




Change Properties
Action