Closed kristofelst closed 8 years ago
Hi,
Indeed siteprefs relies on project structure and should support classic pre and post 1.4 layouts - https://github.com/idlesign/django-siteprefs/blob/master/siteprefs/utils.py#L225
In a week I'll think over what we might want to do in cases similar to yours, maybe some kind of heuristics or even explicit setup. If you have any ideas you're welcome.
Since this project looks the best, and the most natural way of dealing with live settings, it would be really nice if it could deal with rather unconventional project structures.
Can't you just look at the packages which contain a settings.py file, and label them as being the django-app for that settings file?
Unfortunately things are more complex than that. Here is a probable culprit: https://github.com/idlesign/django-siteprefs/blob/master/siteprefs/toolbox.py#L49
To solve the issue we might have introduce some module attribute holding a proper app name that one could define in settings.py of apps, before trying name attribute. Or there may be some other more appropriate way. That requires further investigation.
That'll be nice if you provide a stub of your project with more stuff that described above: with manage.py, several apps, etc. (real stuff not required)
Simple KeyError workaround is in 0.6.0. That should do for most cases. Closing this one. Feel fre to reopen if required.
Following the quick start tutorial of the docs, I came across an error I can't fix at this moment. It is a KeyError for the value apps.settings. I think it has something to do with my rather unconventional project structure:
Here, only search and base are Django apps, the rest are just Python Packages. I have put autodiscover_siteprefs() in urls.py of base, and put a preference declaration as described in the tutorial in the settings.py of search:
When running the server I get a KeyError for 'apps.settings'. It has the following traceback:
When looking at the local variables in the get_pref_model_class method, I see that for the preference I declared, the variable app is 'apps' instead of 'search':
So my guess is that it is taking the root map of all the apps as django-app, and not the correct app (search). Since the Python Package apps has no file called settings, it crashes.
So my question is, does siteprefs makes some assumptions about the file structure of the project or did I make some mistake? How can I make it work for my file structure?
Thanks in advance!