Changes between Initial Version and Version 2 of Ticket #16263
- Timestamp:
- Jun 15, 2011, 4:14:29 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #16263
- Property Resolution → needsinfo
- Property Status new → closed
-
Ticket #16263 – Description
initial v2 1 1 I'm getting the following problem: 2 --- 2 3 {{{ 3 4 Traceback (most recent call last): 4 5 File "request_handler.py", line 10, in <module> … … 9 10 return getattr(self._wrapped, name) 10 11 AttributeError: 'Settings' object has no attribute '__file__' 11 --- 12 }}} 12 13 13 14 when trying to use django standalone with code like this (and with DJANGO_SETTINGS_MODULE set to a valid module): 14 15 16 {{{ 15 17 from django.conf import settings 16 18 from django.core.management import setup_environ 17 19 setup_environ(settings) 20 }}} 18 21 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.22 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. 20 23 21 One fix (that I've tested) is to add the copy of the __file__ attribute within the Settings class in django.conf.__init__.pylike this:24 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: 22 25 23 --- 26 {{{ 24 27 class Settings(BaseSettings): 25 28 def __init__(self, settings_module): … … 44 47 #if setting == setting.upper(): ## OLD BROKEN 45 48 if setting == setting.upper() or setting == '__file__': #NEW FIXED 49 }}} 46 50 47 ---48 51 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.52 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. 50 53 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).