Opened 18 years ago

Closed 18 years ago

#4543 closed (duplicate)

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

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

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.
...

Change History (1)

comment:1 by Chris Beaven, 18 years ago

Resolution: duplicate
Status: newclosed

Dupe of #3475

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