I'm new to Django and am trying to create a small website where I click on a flag and the language changes. I'm using django i18n for that:
urls.py
from django.conf.urls import patterns, include, url
from django.conf.urls.i18n import i18n_patterns
urlpatterns = [url(r'^i18n/', include('django.conf.urls.i18n'))]
urlpatterns += i18n_patterns(
url(r'^$', views.home, name='home'),
)
The problem is, when I run the following code:
templetatags.py
@register.simple_tag
def test():
r = requests.post('http://localhost:8000/i18n/setlang/', data = {'lang':'en', 'next' : '/'})
print r.status_code
home.html
<div id='country_flags'>
<a hreflang="en" href="{% test %}"><img id='en' src='{% static "mysyte/images/gb.png" %}'></a>
</div>
the result of r.status_code is 403.
What am I doing wrong?