Opened 14 years ago
Closed 14 years ago
#15631 closed (worksforme)
There is no __file__ when settings.DEBUG = False
Reported by: | Belegnar | Owned by: | Belegnar |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Processing admin.py with following code failed when DEBUG = False
from django.contrib import admin from django.contrib.auth.models import User import os.path app_name = os.path.basename(os.path.dirname(__file__)) models_module = __import__('%s' % app_name).models models_list = [models_module.__dict__[model] for model in models_module.__dict__ \ if type(models_module.__dict__[model]) == type(User) \ and models_module.__dict__[model].__module__ == '%s.models' % app_name] admin.site.register(models_list)
because of file = None. Working fine when DEBUG = True
Note:
See TracTickets
for help on using tickets.
This must be something else in your setup; I can't see how
DEBUG
could possibly affect__file__
in this way. I quickly tested in anadmin.py
to ensure I wasn't insane.