Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when settings added at app level #2

Open
polotek opened this issue Mar 7, 2010 · 1 comment
Open

Error when settings added at app level #2

polotek opened this issue Mar 7, 2010 · 1 comment

Comments

@polotek
Copy link

polotek commented Mar 7, 2010

I ran into this problem with adding dbsettings to my app. I believe i'm doing it in a non-standard way and the dbsettings code is making some assumptions.

First here is the error I get when I try to load my settings page in the admin:

Traceback: File "/Users/marco/www/apps/eig2010/src/django/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/Users/marco/www/apps/eig2010/src/django/django/contrib/admin/views/decorators.py" in _checklogin 33. return view_func(request, *args, **kwargs) File "/Users/marco/www/apps/eig2010/eig2010/dbsettings/views.py" in app_settings 16. settings = loading.get_app_settings(app_label) File "/Users/marco/www/apps/eig2010/eig2010/dbsettings/loading.py" in get_app_settings 38. return [p for p in _settings if app_label == p.module_name.split('.')[-2]]

Exception Type: IndexError at /admin/settings/eigsite/
Exception Value: list index out of range

The problem is with the splitting and taking the second to last item from the module_name. I did some print and the module name is only the name of the app, i.e. "eigsite". I didn't fully trace the code here, but I see two possible reasons for this.

  1. I have my django project on my python path so when I add apps to INSTALLED_APPS I don't have to prefix them with the project name. So I added "eigsite" instead of "eig2010.eigsite". It's unlikely that this is the issue because you're looking up the module name from the dynamically and don't seem to be looking in INSTALLED_APPS

  2. The more likely cause is that I'm adding my settings in the top level app instead of in a submodule like models.py. So this is in my eigsite/init.py

    import dbsettings
    
    class AppSettings(dbsettings.Group):
        feature_url = dbsettings.StringValue('Feature URL')
        register_url = dbsettings.StringValue('Registration URL')
    
    app_settings = AppSettings()
    

So basically my settings are at "eigsite.app_settings" instead of "eigsite.models.app_settings". I have a patch for this but it's pretty simplistic. It just checks the length of module_name.split('.') and if it's less than 2 just turns the first item. I'm sure you'll have a more appropriate fix in mind.

zlorf referenced this issue in zlorf/django-dbsettings Jun 29, 2012
@ZackPlauche
Copy link

I actually didn't see in the README specifically how to add settings at an app level (which is exactly what I need). I really need this setting. Is it possible for this to be a priority?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants