Opened 13 years ago
Closed 13 years ago
#17104 closed Bug (worksforme)
from polls.models import Choice in admin.py
Reported by: | Owned by: | RodrigoJimmy | |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | tutorial, error |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In "Adding related objects" at https://docs.djangoproject.com/en/1.3/intro/tutorial02/ we have the code:
from polls.models import Choice
but in my app, it isn't works for me, because admin.py is in poll folder, so that, the code below works for me:
from models import Choice
Note:
See TracTickets
for help on using tickets.
from polls.models import Choice
does work if you've followed the tutorial up to that point, and you're runningpython manage.py runserver
, because the directory containingmanage.py
is added tosys.path
. So you must be doing something else different from the tutorial.Using
from polls.models import Choice
, as the tutorial does, can cause problems when deploying to production, because it often requires adding two overlapping paths tosys.path
in your webserver configuration. This issue has already been extensively discussed and is fixed in trunk (r16964).Using a relative import instead of an absolute one (as you are doing) is also fine, but you should really make the relative import explicit instead of implicit by using
from .models import Choice
.