Opened 8 years ago

Closed 8 years ago

#15631 closed (worksforme)

There is no __file__ when settings.DEBUG = False

Reported by: Belegnar Owned by: Belegnar
Component: Core (Other) Version: master
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


Processing 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]

because of file = None. Working fine when DEBUG = True

Change History (1)

comment:1 Changed 8 years ago by Simon Meers

Resolution: worksforme
Status: newclosed

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 an to ensure I wasn't insane.

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