Django передача данных из шаблона
Пытаюсь передать переменную из шаблона в url
<li class="menu__item menu__item_header">
<a href="{% url 'decision:room' rmslg='kitchen'%}" class="menu__link">Жилые интерьеры</a>
</li>
Но он не воспринимает ее как переменную
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/decision/livingrooms/%3Cslug:room.slug%3E/
Using the URLconf defined in caparol_center_spb_decision.urls, Django tried these URL patterns, in this order:
admin/
[name='index']
services/ [name='services']
decision/ livingrooms/ [name='livingrooms']
decision/ livingrooms/<slug:rmslg>/ [name='room']
decision/ livingrooms/<slug:rmslg>/<slug:stslg>/ [name='style']
news/
^media/(?P<path>.*)$
The current path, decision/livingrooms/<slug:room.slug>/, didn't match any of these.
urls.py
from django.urls import path
from .views import ContactView
from . import views
app_name = 'decision'
urlpatterns = [
path('livingrooms/', ContactView.as_view(), name='livingrooms'),
path('livingrooms/<slug:rmslg>/', views.room, name='room'),
path('livingrooms/<slug:rmslg>/<slug:stslg>/', views.style, name='style'),
]
views.py
from django.shortcuts import render
from .forms import EmailForm
from django.views.generic.edit import FormView
from .models import Room,Style
class ContactView(FormView):
template_name = 'decision/residentialInteriors.html'
form_class = EmailForm
success_url = 'decision/residentialInteriors.html'
def form_valid(self, form):
print("success")
def room(request, rmslg):
styles = Room.objects.get(slug=rmslg).styles.all()
return render(request, 'decision/residentialInteriors.html', {"styles": styles})
def style(request, stslg):
style = Style.objects.get(slug=stslg)
return render(request, 'decision/residentialInteriors.html', {"style": style})