I'm facing a strange problem.
Seems hard to be reproduced as it occurs only on my staging/prodution servers.
The exact same code runs fine, no errors with django server even if DEBUG is True or False...
It seems that the monkey patched I18NRegexURLResolver class can't find _i18n_regex_dict ...
Any idea ? Any Hints on how to debug case like this ?
2011-08-08 05:16:22,022 [ERROR] django.request: Internal Server Error: /fr/
Traceback (most recent call last):
File "/home/administrator/.virtualenvs/django1.3-001/lib/python2.6/site-packages/django/core/handlers/base.py", line 101, in get_response
File "/home/administrator/.virtualenvs/django1.3-001/lib/python2.6/site-packages/django/core/urlresolvers.py", line 247, in resolve
match = self.regex.search(path)
File "/home/administrator/.virtualenvs/django1.3-001/lib/python2.6/site-packages/i18nurls/urlresolvers.py", line 74, in regex
if language_code not in self._i18n_regex_dict:
AttributeError: 'RegexURLResolver' object has no attribute '_i18n_regex_dict'
I'm having the same issue. It occurs on a test server but not locally. It also goes away after a refresh, as if it's not picking up some language setting properly.
I was able to fix it by properly configuring the middleware. It now looks like:
MIDDLEWARE_CLASSES = (
Sorry for my late reply (I was on holiday). Can it be caused by an other package (or your own code) that imports the url resolver before it gets patched?
In that case the order of your installed apps might solve the problem? Which other packages are you using? Could you post your INSTALLED_APPS and MIDDLEWARE_CLASSES settings?
Not sure about franckbret's situation but in my case, it was indeed due to the ordering of middleware (and using the correct middleware too, there's various Locale middleware around now). See my previous comment with my MIDDLEWARE_CLASSES.
I finally make it works on both local and production server. It seems that replacing
'django.middleware.locale.LocaleMiddleware' with 'i18nurls.middleware.I18NLocaleMiddleware' do the job.
I'm still confused about it cause you say in the README "Add django.middleware.locale.LocaleMiddleware to your settings.MIDDLEWARE_CLASSES (if it is not already there, make sure it comes before the CommonMiddleware)."
Do you confirm it's the good way to go or do I have miss something ?
So my final settings are :
MIDDLEWARE_CLASSES = (
TEMPLATE_CONTEXT_PROCESSORS = (
INSTALLED_APPS = (
# Uncomment the next line to enable the admin:
# Uncomment the next line to enable admin documentation:
I've made a local demo project to test all this stuff are you interested in including it in the app ?
Strange, since I am patching the django.middleware.LocaleMiddleware as well (so the API will be exactly the same when you upgrade to Django 1.4, if nothing will change in meantime). What happens when you change the i18nurls middleware back to the django middleware and put the i18nurls app on top of your INSTALLED_APPS tuple?
Unfortunately moving i18nurls on top and activating django.middleware.LocaleMiddleware does not work. Got various AttributeError: 'RegexURLResolver' object has no attribute '_i18n_regex_dict' errors
I've just pushed my demo project here if you want to have a look
I'm having the same issue, but it happens only with https://github.com/dcramer/django-devserver enabled.
Django Version: 1.3.1
Python Version: 2.6.6