Opened 14 years ago

Closed 14 years ago

#14457 closed (invalid)

Possible error in settings.py description

Reported by: zsoltbot Owned by: nobody
Component: Documentation Version: 1.2
Severity: Keywords: tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Gabriel Hurley)

On this page
http://docs.djangoproject.com/en/1.2/intro/tutorial01/

I'm pretty sure:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'polls'
)

should really be

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'mysite.polls'
)}}}

Change History (3)

comment:1 by Łukasz Rekucki, 14 years ago

Keywords: tutorial added

This ticket is kind of interesting, because we just removed "mysite" from tutorial (see #14067) to meet a very popular demand #14216 (at least partially).

The trick here is that writing "from mysite.polls import ..." artificially ties the Polls application to your project. This is discouraged. But to make things work properly, the "polls" module must be imported everywhere using the same name (otherwise you will have two different modules: "mysite.polls" and "polls"). That includes imports made by Django itself, so the module name in INSTALLED_APPS had to be changed.

In simpler terms: if your application is named "polls" it seems reasonable to use "polls" in the INSTALLED_APPS. I don't see nothing in new version of the tutorial that would suggest using "mysite.polls".

comment:2 by Łukasz Rekucki, 14 years ago

Grr... I swear I double checked the ticket number - it should be #14255, not 14067.

comment:3 by Gabriel Hurley, 14 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

As lrekucki said, the removal of "mysite" was intentional; that particular instance was removed in #14255, and the rest are set to be removed by #14426.

The bottom line is that the "mysite.myapp" convention is not what we want to be encouraging people to do. It goes against the idea of reusable apps, and obfuscates the fact that Django apps are truly just Python packages and can be imported from anywhere on the PYTHONPATH.

Thanks for the report though, zsoltbot.

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