Code

Opened 7 years ago

Closed 7 years ago

#4543 closed (duplicate)

django-admin.py startapp and startproject should help newbies avoid module name clash

Reported by: jdunck Owned by: adrian
Component: Core (Management commands) Version: master
Severity: Keywords: newbie
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Fairly often, newbies name their first Django project "site", which
breaks python's built-in site package, disabling packages and .pth's
in site-packages.

Ouch.

Perhaps Django should validate that the thing you supply to startapp
and startproject aren't named something that's already importable, or in the regular library paths, or similar, issuing an error something like this:

"""
The name you've given the project, "site", clashes with the existing module "site" located at "/usr/lib/python2.5/".  
This is likely to cause confusion when importing the modules.  Please choose another name or use the --force flag to continue.
For more info, see the Python Tutorial section on modules: http://docs.python.org/tut/node8.html
"""

As a real-world example, in the thread below, a person had the misfortune of naming an app "calendar", and then trying to use the python built-in calendar module from the wrong directory:

Forwarded Conversation
Subject: App Migration: ImportError @ isleap


From: Justin Lilly <JustinLilly@gmail.com>

Reply-To: django-users@…
To: Django users <django-users@…>
Date: Mon, Jun 11, 2007 at 12:33 PM

Hi all.

I have a little calendar working based on a django snippet from

masida_ in #django (Freenode).
...

It seems to be having a problem with the isleap function. I've
imported both calendar and datetime, so I'm not sure what the problem
is.
...


From: Justin Lilly <justinlilly@…>

Reply-To: django-users@…
To: Django users <django-users@…>
Date: Mon, Jun 11, 2007 at 5:41 PM

For archival purposes, the reason it wasn't working is I had named one of my apps "calendar". After I renamed it to agenda and remapped it appropriately, everything was in working order.
...

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by SmileyChris

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

Dupe of #3475

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.