I have URLs in the following form:
http://example.com/[language_code]/xxx
I need to do:
1. Based on the language code, I want to select appropriate DB or raise Http 404 if language code is not supported.
2. I'd like to save the language code in the request object preferably, so I can access it in my templates.
3. I'd like my urls.py don't look like this:
url(r'^(?P<lang>w+)/xxx/$', 'my_app.views.xxx')
but rather:
url(r'^xxx/$', 'my_app.views.xxx')
so django will completely ignore the language code in the URL.
Can anyone tell me please if this is doable with django or I should look for another solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…