Reverse for 'surveydetails' not found. 'surveydetails' is not a valid view function or pattern name

60 views Asked by At

I've been stuck on this for a while, can't seem to fix the error. I've checked the code a hundred times but obviously there is something I'm missing. I have installed my app also.

Can anybody see what I'm missing?

views.py

 def survey_details(request, id=None):
     context = {}
     surveys = Survey.objects.get(id=id)
     context['survey'] = survey
     return render(request, 'surveydetails.html', context)

feedback.urls.py

path('details/<int:id>', views.survey_details, name="surveydetails"),

surveys.html

{% extends 'main.html' %}

{% block content%}

    <h1>Surveys</h1>
    <h2>list of {{title}} </h2>
    {% if surveys %}
        <ul>
            {% for survey in surveys %}
            <li>
                <a href="{% url 'feedback:surveydetails' %}">{{ survey.title }}</a>
            </li>
            {% endfor %}
        </ul>
    {% else %}
        <p>There are no surveys.</p>
    {% endif %}
{% endblock %}

surveydetails.html

{% extends 'main.html' %}

{% block content%}

    <h1>Surveys</h1>
    <h2>Detail page</h2>
    <h3>{{question.title}}</h3>
    <p>Details page of {{question.title}}</p>

{% endblock %}
1

There are 1 answers

1
arjun On BEST ANSWER

Here you are not passing the survey id.

{% for survey in surveys %}
   <li>
     <a href="{% url 'feedback:surveydetails' survey.id %}">{{ survey.title }}</a>
 </li>
{% endfor %}