Closed simonseyer closed 10 years ago
@monofox please review these changes
Seems to be fine. There is just one issue which is really not beautiful. If you've not created the local configuration file, there is no error handling and the corresponding administrator sit in front of long error messages with stack trace:
Traceback (most recent call last): (...) ImportError: No module named 'local_settings'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): (...) ImportError: Could not import settings 'zuks.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'local_settings'
Could be more helpful to define it in the settings.py. I just prepared something. Will add it. Just a second.
See my last commit: Result:
$ python3.3 manage.py syncdb Could not load the local configuration settings!
Test failed. Get always the error message, that the local configuration could not be load.
@monofox I could not reproduce your problem. Could you describe it in more detail?
@Eldorado234 Yeah i can say the exact reason - i'm using Python 3 and the things have a little bit changed regarding the import. Import inside of a package differs to import outside of a package. If you make imports of another file inside of a package, than you have to use the complete module (e.g. from zuks.local_settings import ). This is not possible here - it is not resolvable - "local_settings" has first to be imported before using the corresponding import . There is ONE solution here: to use relative import (e.g. from . import local_settings). This leads to another problem: inside of the local_settings you cannot refer back to settings (obviously it's a great example of recursive dependency).
That's the problem. I'm pretty sure that the current solution will work on old python version. But it is not very fine to break the support of newer python versions.
Got it. Can you please check it for the old python 2.x version?
Everything works fine in python 2.x. But it is not such beautiful, that some of the settings are defined in the module file. Is there really no other solution?
Ha! After your messages i wonder, that it worked with the MIDDLEWARE_CLASSES. Because it was done in the same way as it was done with the project paths and dirs. I made the constants import now separate (for each constant one import). Now it works.
Fine in this way?
Perfect!
See django example: https://code.djangoproject.com/wiki/SplitSettings#Multiplesettingfilesimportingfromeachother
It is very dangerous to change a versioned settings file to the local environment. You have to merge changes every time and you have to care that you don't push your local settings.