[에러 질문입니다.] NoReverseMatch at /pybo/321/qna/

안녕하세요.
점프 투 장고 추가 기능으로 카테고리 만드려다가 에러가 났습니다.
열심히 구글링 해봤는데 도저히 원인을 모르겠어서 질문드려요.

에러메세지는 아래와 같습니다.

  • 에러 page
    NoReverseMatch at /pybo/321/qna/
Reverse for 'detail' with arguments '(321,)' not found. 1 pattern(s) tried: ['pybo/(?P<question_id>[0-9]+)/(?P<category_name>[^/]+)/$']
Request Method: GET
Request URL:    http://localhost:8000/pybo/321/qna/
Django Version: 3.2.7
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'detail' with arguments '(321,)' not found. 1 pattern(s) tried: ['pybo/(?P<question_id>[0-9]+)/(?P<category_name>[^/]+)/$']
Exception Location: F:\vsc\python\venv\mysite\lib\site-packages\django\urls\resolvers.py, line 694, in _reverse_with_prefix
Python Executable:  F:\vsc\python\venv\mysite\Scripts\python.exe
Python Version: 3.9.5
Python Path:    
['...
Server time:    Fri, 15 Oct 2021 16:50:22 +0900

관련 코드는 아래와 같습니다.

  • question_list.html
    <a href="{% url 'pybo:detail' question.id category_name %}">{{ question.subject }}</a>
  • urls.py
    path('<int:question_id>/<str:category_name>/', base_views.detail, name='detail'),
  • base_views.py
    def detail(request, question_id, category_name):
    ...
    context = {'question': question, 'answer_list': page_obj, 'kw': kw, 'so': so,
     'category_list': category_list, 'category_name': category_name}
    return render(request, 'pybo/question_detail.html', context)

url에서 category_name을 인식하지 못하고 있는것 같은데 어디를 고쳐야 할까요..?

살펴봐주셔서 감사합니다.

tt 849

M 2021년 10월 15일 5:00 오후

목록으로
1개의 답변이 있습니다. 1 / 1 Page

{% url 'pybo:detail' question.id category_name %} 처럼 고쳐지지 않은 템플릿에 남아 있는것 같은데요?
여전히 {% url 'pybo:detail' question.id %}을 사용하고 있는 곳이 없는지 찾아보세요.

박응용

2021년 10월 15일 5:23 오후