ImproperlyConfigured: The included urlconf .urls doesn't have any patterns in it

后端 未结 5 1561
北恋
北恋 2020-12-02 12:36

I have a django (1.6.x) project that runs fine with the dev server, but is failing under Apache2 (2.2.22.1) and mod_wsgi (3.3-4) on Ubuntu 12.04.3 with the error

Imp

相关标签:
5条回答
  • 2020-12-02 13:15

    I used reverse instead of reverse_lazy to define the url parameter of a RedirectView.

    class YourRedirectView(RedirectView):
        url = reverse('reversed_url')
    

    Since the urls.py has not been initialized yet the error is coming up. Just use:

    class YourRedirectView(RedirectView):
        url = reverse_lazy('reversed_url')
    
    0 讨论(0)
  • 2020-12-02 13:19

    Also make sure you have urlpatterns in the file you are including and that it is spelt correctly

    0 讨论(0)
  • 2020-12-02 13:23

    I've suffered a similar problem after upgrading from django 1.5 to 1.6. I'm not sure if my experience is the same as yours.

    First, can you scroll up the errors, and check the admin.autodiscover() is what's generating the problem? Alternatively comment out this line and see if a page will load.

    The problem I found was related to wsgi.py. Is it possible for you to post this file?

    0 讨论(0)
  • 2020-12-02 13:36

    So, I actually ran into a similar problem. Coincidentally after you posted in the issues for django-stronghold. The issue is in fact due to a missing setting in django-debug-toolbar.

    The setting you are missing is:

    DEBUG_TOOLBAR_PATCH_SETTINGS = False 
    

    It will work with runserver, but if you try to run it with honcho, or gunicorn, or anything else that uses the WSGI interface it blows up.

    Hope this helps!

    EDIT: as mentioned below by @japhyr, its useful to check out the explicit setup instructions: http://django-debug-toolbar.readthedocs.org/en/1.0/installation.html#explicit-setup

    0 讨论(0)
  • 2020-12-02 13:36

    I'm having a very similar problem. My project works fine on the test server, but when I try to deploy to gunicorn I get the same ImproperlyConfigured error.

    If I comment out the urls which include another url file (i.e. url(r'^admin/', include(admin.site.urls)), then the rest of my urls work fine.

    [UPDATE] I was able to further narrow it down to only one of my included url files, but couldn't find anything special about it. However, setting Debug=False in my settings.py file seems to have fixed for me.

    0 讨论(0)
提交回复
热议问题