Opened 5 years ago

Closed 5 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: UI/UX:


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 5 years ago by DrMeers

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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