filter by category
This commit is contained in:
parent
b837addd84
commit
bc6d973bf3
@ -10,4 +10,4 @@ urlpatterns = [
|
||||
path('<category_name>', category),
|
||||
]
|
||||
|
||||
urlpatterns = router.urls
|
||||
urlpatterns += router.urls
|
||||
|
@ -6,6 +6,7 @@ from categories.serializers import CategorySerializer
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render, redirect
|
||||
from django.template import loader
|
||||
from trials.models import Test
|
||||
|
||||
class CategoryModelViewSet(viewsets.ModelViewSet):
|
||||
queryset = Category.objects.all()
|
||||
@ -15,5 +16,5 @@ class CategoryModelViewSet(viewsets.ModelViewSet):
|
||||
def category(request, category_name):
|
||||
context = {}
|
||||
context['name'] = category_name
|
||||
context['tests'] = Test.objects.all(category=category_name)
|
||||
context['tests'] = Test.objects.filter(category=category_name)
|
||||
return render(request, 'category.html', context)
|
Loading…
Reference in New Issue
Block a user