Hello I have a problem while I am trying two slugs in one url. I have:
html file:
<div class="panel-heading">
<h4><a class="link" href="{% url 'data:inspection_detail'
plant_slug=plant.slug
inspection_slug=inspection.slug%}">{{inspection.name}}</a></h4>
</div>
views.py file
def inspection_detail(request, inspection_slug, plant_slug):
if not request.user.is_authenticated():
return render(request, 'data/login.html')
else:
user = request.user
plant = get_object_or_404(Plant, slug=plant_slug)
inspection = get_object_or_404(Inspection, slug=inspection_slug)
template = 'data/inspection_detail.html'
context = {'inspection': inspection, 'user': user, 'plant':plant}
return render(request, template, context)
and my url patterns:
url(r'^plants/(?P<plant_slug>[-\w])/(?P<inspection_slug>[-\w]+)/$', views.inspection_detail, name='inspection_detail'),
But I get:
Page not found (404)
And I cant see where is the mistake!
This is how I fixed it:
in the html file:
my views.py
and my url file: