Changes between Initial Version and Version 2 of Ticket #16263


Ignore:
Timestamp:
Jun 15, 2011, 4:14:29 PM (13 years ago)
Author:
Ramiro Morales
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16263

    • Property Resolutionneedsinfo
    • Property Status newclosed
  • Ticket #16263 – Description

    initial v2  
    11I'm getting the following problem:
    2 ---
     2
     3{{{
    34Traceback (most recent call last):
    45  File "request_handler.py", line 10, in <module>
     
    910    return getattr(self._wrapped, name)
    1011AttributeError: 'Settings' object has no attribute '__file__'
    11 ---
     12}}}
    1213
    1314when trying to use django standalone with code like this (and with DJANGO_SETTINGS_MODULE set to a valid module):
    1415
     16{{{
    1517from django.conf import settings
    1618from django.core.management import setup_environ
    1719setup_environ(settings)
     20}}}
    1821
    19 The problem is that there is no __file__ attribute on the django.conf.Settings object, and the setup_environ() code assumes that there will be.
     22The problem is that there is no `__file__` attribute on the `django.conf.Settings` object, and the `setup_environ()` code assumes that there will be.
    2023
    21 One fix (that I've tested) is to add the copy of the __file__ attribute within the Settings class in  django.conf.__init__.py like this:
     24One fix (that I've tested) is to add the copy of the `__file__` attribute within the Settings class in  `django.conf.__init__.py` like this:
    2225
    23 ---
     26{{{
    2427class Settings(BaseSettings):
    2528    def __init__(self, settings_module):
     
    4447            #if setting == setting.upper():  ## OLD BROKEN
    4548            if setting == setting.upper() or setting == '__file__': #NEW FIXED
     49}}}
    4650
    47 ---
    4851
    49 This works, but might not be the best solution. This problem means that I cannot use any settings files other than the default one (so is quite a big problem). There is of course a simple workaround: ie to rename my custom file to settings.py, but this isn't ideal.
     52This works, but might not be the best solution. This problem means that I cannot use any settings files other than the default one (so is quite a big problem). There is of course a simple workaround: ie to rename my custom file to `settings.py`, but this isn't ideal.
    5053
    51 (Also note that this is not a problem when using manage.py, just when trying to use this standalone, eg in a non-webserver process).
     54(Also note that this is not a problem when using `manage.py`, just when trying to use this standalone, eg in a non-webserver process).
Back to Top