pybo/urls.py파일 공개 해주시면 안될까요?

잘 될것 같았는데 아무래도 urls.py파일이 잘못된것 같아서요
아래 질문글에도 답변해주시면 고맙겠습니다

kmyang 1184

M 2021년 4월 10일 4:18 오후

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

pybo.kr에서 사용하는 pybo/urls.py 파일내용입니다.

from django.urls import path

from .views import main_views, question_views, answer_views, comment_views, vote_views

app_name = 'pybo'

urlpatterns = [
    # base_views.py
    path('', main_views.index, name='index'),
    path('recent_list/', main_views.recent_list, name='recent_list'),

    # question_views.py
    path('question/list/<str:category_name>/', question_views.question_list, name='question_list'),
    path('question/detail/<int:question_id>/', question_views.question_detail, name='question_detail'),
    path('question/create/<str:category_name>/', question_views.question_create, name='question_create'),
    path('question/modify/<int:question_id>/', question_views.question_modify, name='question_modify'),
    path('question/delete/<int:question_id>/', question_views.question_delete, name='question_delete'),

    # answer_views.py
    path('answer/create/<int:question_id>/', answer_views.answer_create, name='answer_create'),
    path('answer/modify/<int:answer_id>/', answer_views.answer_modify, name='answer_modify'),
    path('answer/delete/<int:answer_id>/', answer_views.answer_delete, name='answer_delete'),

    # comment_views.py
    path('comment/create/question/<int:question_id>/', comment_views.comment_create_question, name='comment_create_question'),
    path('comment/create/answer/<int:answer_id>/', comment_views.comment_create_answer, name='comment_create_answer'),
    path('comment/modify/<int:comment_id>/', comment_views.comment_modify, name='comment_modify'),
    path('comment/delete/<int:comment_id>/', comment_views.comment_delete, name='comment_delete'),
    path('comment/all/question/', comment_views.comment_all_question, name='comment_all_question'),
    path('comment/all/answer/', comment_views.comment_all_answer, name='comment_all_answer'),

    # vote_views.py
    path('vote/question/<int:question_id>/', vote_views.vote_question, name='vote_question'),
    path('vote/answer/<int:answer_id>/', vote_views.vote_answer, name='vote_answer'),
    path('vote/comment/<int:comment_id>/', vote_views.vote_comment, name='vote_comment'),
    path('vote/question/users/<int:question_id>/', vote_views.vote_question_users, name='vote_question_users'),
    path('vote/answer/users/<int:answer_id>/', vote_views.vote_answer_users, name='vote_answer_users'),
    path('vote/comment/users/<int:comment_id>/', vote_views.vote_comment_users, name='vote_comment_users'),
]

박응용

2021년 4월 10일 4:52 오후

제가 처음 작성한 것과 차이가 없는데
이런 에러가 납니다

NoReverseMatch at /pybo/
Reverse for 'question_create' with no arguments not found. 1 pattern(s) tried: ['pybo/question/create/(?P[^/]+)/$']
Request Method: GET
Request URL: http://127.0.0.1:8000/pybo/
Django Version: 3.1.7
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'question_create' with no arguments not found. 1 pattern(s) tried: ['pybo/question/create/(?P[^/]+)/$']
Exception Location: C:\Users\ykm\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py, line 685, in _reverse_with_prefix
Python Executable: C:\Users\ykm\AppData\Local\Programs\Python\Python39\python.exe
Python Version: 3.9.2
Python Path:
['c:\projects\mysite20210403',
'C:\Users\ykm\AppData\Local\Programs\Python\Python39\python39.zip',
'C:\Users\ykm\AppData\Local\Programs\Python\Python39\DLLs',
'C:\Users\ykm\AppData\Local\Programs\Python\Python39\lib',
'C:\Users\ykm\AppData\Local\Programs\Python\Python39',
'C:\Users\ykm\AppData\Roaming\Python\Python39\site-packages',
'C:\Users\ykm\AppData\Local\Programs\Python\Python39\lib\site-packages']
Server time: Sat, 10 Apr 2021 17:56:04 +0900
Error during template rendering
In template C:\projects\mysite20210403\templates\base.html, error at line 0

Reverse for 'question_create' with no arguments not found. 1 pattern(s) tried: ['pybo/question/create/(?P[^/]+)/$']

kmyang

M 2021년 4월 10일 7:29 오후

+1 작성하신 템플릿 중에 question create 관련한 URL의 파라미터 매핑이 잘못된걸로 보이네요. - 박응용님, 2021년 4월 10일 8:33 오후 추천 , 대댓글
@박응용님 아! 잘됩니다 고맙습니다^^ - kmyang님, 2021년 4월 10일 8:52 오후 추천 , 대댓글