3

I am Getting an error Reverse for 'question_list' not found. 'question_list' is not a valid view function or pattern name. after using the template tag 'collab_app:question_list' in template.

home.html:

{% extends "_base.html" %} 
{% load static %}
{% load socialaccount %}
{% block title %}Home{% endblock title %} 
{% block content %}
<h1>Homepage</h1>
<a href="{% url 'collab_app:question_list' %}">Ask Question Here</a>
<img class="collabimage" src="{% static 'images/collab.jpg' %}" ><br>
{% if user.is_authenticated %}
  Hi {{ user.email }}
  <p><a href="{% url 'account_logout' %}">Log Out</a></p>
{% else %}
  <p>You are not logged in</p>
  <!--Github-->
  <a href="{% provider_login_url 'github' %}" ><p class="git">Github</p></a>
  <a href="{% url 'account_login' %}">Login</a>
  <a href="{% url 'account_signup' %}">Sign Up</a>
{% endif %}
{% endblock content %}

views.py:

class HomePageView(generic.TemplateView):
    template_name = "home.html"

urls.py in users app:

from django.urls import path, include
from .views import SignupPageView
from .views import HomePageView

app_name = "users"

    urlpatterns = [
        path("", HomePageView.as_view(), name="home"),
        path("signup/", SignupPageView.as_view(), name="signup"),
    ]

urls.py in project:

from django.contrib import admin
from django.urls import path, include
from users.views import HomePageView


urlpatterns = [
    path("", include("users.urls")),
    path("collab/", include("collab_app.urls"),),  # , "collab_app")),
]

urls.py in collap_app:

from django.contrib import admin
from django.urls import path, include
from collab_app import views
from users.views import HomePageView

app_name = "collab_app"

urlpatterns = [
    path("", views.QuestionListView.as_view(), name="question-list"),
]

view.py in collab_app:

class QuestionListView(ListView):
    model = Question
    template_name = "collab_app/question_list.html"
1
  • have you added your app_name to installed apps in settings? Commented Jan 25, 2020 at 6:59

2 Answers 2

1

Your named the url as question-list and you're referencing question_list; it's just a typo.

Use {% url 'collab_app:question-list' %} instead.

Sign up to request clarification or add additional context in comments.

Comments

0

Try changing.

Your urls.py in collap_app:

urlpatterns = [
    path("question-list", views.QuestionListView.as_view(), name="question-list"),
]

In home.html

<a href="{% url 'collab_app:question-list' %}">Ask Question Here</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.