Opened 13 years ago
Closed 13 years ago
#17540 closed Uncategorized (invalid)
Errors in 1.3 Writing your first Django app part 1 and 2 Ubuntu 11.10
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
I recently tried to work through your tutorial for Django 1.3 on Ubuntu 11.10. The first error I found was in part 1 where the new app was added to installed apps and there is a missing comma ',':
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'polls' )
and should read:
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'polls', )
The second error was in part 2 in the section "Make the poll app modifiable in the admin". It has a misplaced 'models' in the first import and reads:
from polls.models import Poll from django.contrib import admin admin.site.register(Poll)
and should read:
from models import Poll from django.contrib import admin admin.site.register(Poll)
I believe the second issue could be also fixed by describing the expected project structure in the tutorial.
These errors were discovered when setting up a Django, mod_wsgi, apache configuration on Ubuntu 11.10
In the first case, the comma at the end is not required.
In the second case, doing "from polls.models import Poll" will work fine, and is definitely preferred over "from models import Poll" (which is using implicit relative imports, which are going away). It is likely your Python path has been incorrectly set up. The setup for 1.3 and earlier is a bit confusing due to Python path hacking that was done in those older versions of Django, but has now been corrected.
Tutorial 1 does indeed document what the project structure will look like.