NoReverseMatch - Обратный запрос для 'emotion-buttons' с аргументами '(1,)' не найден. Проверено 1 шаблон(ы): ['student/emotion\\\-buttons$'].
Я продолжаю получать сообщение об ошибке "NoReverseMatch at /student/take-exam/1
".Поиск для 'emotion-buttons' с аргументами '(1,)' не найден. Испробован 1 шаблон(ы): ['student/emotion\-buttons$']'". Я не смог понять, в чем проблема с моим кодом. Когда я связываю take_exam со start_exam, все работает нормально, так что проблема должна быть в связывании emotion_buttons со start_exam.
Вот что у меня есть на данный момент:
urls.py
from django.urls import path
from student import views
from django.contrib.auth.views import LoginView
urlpatterns = [
path('student-exam', views.student_exam_view,name='student-exam'),
path('take-exam/<int:pk>', views.take_exam_view,name='take-exam'),
path('emotion-buttons', views.emotion_buttons_view,name='emotion-buttons'),
path('start-exam/<int:pk>', views.start_exam_view,name='start-exam'),
]
views.py
@login_required(login_url='studentlogin')
@user_passes_test(is_student)
def take_exam_view(request,pk):
course=QMODEL.Course.objects.get(id=pk)
total_questions=QMODEL.Question.objects.all().filter(course=course).count()
questions=QMODEL.Question.objects.all().filter(course=course)
total_marks=0
for q in questions:
total_marks=total_marks + q.marks
return render(request,'student/take_exam.html',{'course':course,'total_questions':total_questions,'total_marks':total_marks})
@login_required(login_url='studentlogin')
@user_passes_test(is_student)
def start_exam_view(request,pk):
course=QMODEL.Course.objects.get(id=pk)
questions=QMODEL.Question.objects.all().filter(course=course)
if request.method=='POST':
pass
response= render(request,'student/start_exam.html',{'course':course,'questions':questions})
response.set_cookie('course_id',course.id)
return response
@login_required(login_url='studentlogin')
@user_passes_test(is_student)
def emotion_buttons_view(request):
courses=QMODEL.Course.objects.all()
return render(request,'student/emotion_buttons.html',{'courses':courses})
take_exam.html
<a href="{% url 'emotion-buttons' course.id %}" class="btn btn-info">Let's Start</a>
emotion_buttons.html
<a href="{% url 'start-exam' %}" class="btn btn-info">End Session</a>
Любая помощь будет оценена по достоинству