hello, i just started. I added multiple languages to my Django project. I get an error when I assign a url from one language to another page
language = en
url: site/en/product/trial
set_language = en
surl : site/en/product/trial
And
Page not found (404)
No Categories match the given query.
Whereas en url but url should have been http://127.0.0.1:8000/en/product/test
Can you help me ?
views.py
from django.shortcuts import render, get_object_or_404
# Create your views here.
from .models import Category, Product, ProductImage
def category_view(request, category_slug):
#print(f"kategori slug : {category_slug}")
category = get_object_or_404(Category, slug=category_slug)
products = Product.objects.filter(
is_activate=True,
category=category,
)
context = dict(
category=category,
products=products
)
return render(request, 'product/products_list.html', context)
navbar.html
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}">
<select name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<input type="submit" value="Go">
</form>