[Answered ]-Why does Django throw a warning when loading my URLconf?

2👍

My guess is it has to do with your satchmo patterns and overloading on the name “urlpatterns” which django specifically looks for.

Try

from satchmo_store.urls import urlpatterns as satchmo_patterns
urlpatterns = myapp_patterns + satchmo_patterns

#etc.

0👍

The strange behavior may be bacause before if settings.DEBUG, urlpatterns is empty for some reason.

When running the dev server, it gets populated with the urlpatterns from the static app. When running in production, it remains empty.

You can check this easily with a clause like

if urlpatterns:
    # something is in urlpatterns
    # What's its type, contents, ...?
else:
    # urlpatterns is empty

Once you figured this out, you can dig deeper. You can also add the check in a unit test or do it directly in the python shell, by importing the urls module if you want to make it more robust.

0👍

I think, and this is just a hunch, your urls maybe fine, (since no issues arise in your staged dev machine, only reloading on prod) the problem maybe with the way gunicorn re-loads the modules, and the way python compiled code behaves between different versions of the interpreter and how iterators behave, but again this are all hunches.

I recommend that you use the same version of python that you have on production in your staged machine and see if you can recreate the error if there already same version, then it must be something else, the reason I ask is that most production machines tend to use older versions of python, though I could be wrong.

good luck.

0👍

Instead of the urlpatterns = myapp_patterns + urlpatterns stuff, surely we could instead call myapp_patterns urlpatterns off the bat, and have inside the end of it, something along the lines of:

(r'^', include('satchmo_store.urls')),

As this is the “Django” way to include URL patterns?

This might solve your issue, I’m not sure. Worth a shot, I guess.

Leave a comment