tickets urls.py
from django.urls import path
from .views import (
TicketListView,
TicketDetailView,
TicketCreateView,
TicketUpdateView,
TicketDeleteView,
UserTicketListView,
)
from . import views
urlpatterns = [
path('', TicketListView.as_view(), name='ticket-home'),
path('user/<str:username>', UserTicketListView.as_view(), name='user-tickets'),
path('tickets/<int:pk>/', TicketDetailView.as_view(), name='ticket-detail'),
path('tickets/new/', TicketCreateView.as_view(), name='ticket-create'),
path('tickets/<int:pk>/update/', TicketUpdateView.as_view(), name='ticket-update'),
path('tickets/<int:pk>/delete/', TicketDeleteView.as_view(), name='ticket-delete'),
path('about/', views.about, name='tickets-about'),
]
traceback
Request Method: POST
Request URL: http://localhost:5000/tickets/1/comments/new/
Django Version: 4.0.1
Python Version: 3.10.0
Installed Applications:
['tickets.apps.TicketsConfig',
'users.apps.UsersConfig',
'comments.apps.CommentsConfig',
'demo.apps.DemoConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Request Method: POST
Request URL: http://localhost:5000/tickets/1/comments/new/
Django Version: 4.0.1
Python Version: 3.10.0
Installed Applications:
['tickets.apps.TicketsConfig',
'users.apps.UsersConfig',
'comments.apps.CommentsConfig',
'demo.apps.DemoConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "C:\Users\mikha\bug_env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\mikha\bug_env\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\contrib\auth\mixins.py", line 71, in dispatch
return super().dispatch(request, *args, **kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\base.py", line 101, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\edit.py", line 174, in post
return super().post(request, *args, **kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\edit.py", line 144, in post
return self.form_valid(form)
File "C:\Users\mikha\issuetracker\comments\views.py", line 38, in form_valid
return super().form_valid(form)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\edit.py", line 128, in form_valid
return super().form_valid(form)
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\edit.py", line 59, in form_valid
return HttpResponseRedirect(self.get_success_url())
File "C:\Users\mikha\bug_env\lib\site-packages\django\views\generic\edit.py", line 118, in get_success_url
url = self.object.get_absolute_url()
File "C:\Users\mikha\issuetracker\comments\models.py", line 18, in get_absolute_url
return reverse('tickets:ticket-detail', kwargs={'pk': self.ticket_id})
File "C:\Users\mikha\bug_env\lib\site-packages\django\urls\base.py", line 86, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File "C:\Users\mikha\bug_env\lib\site-packages\django\urls\resolvers.py", line 729, in _reverse_with_prefix
raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /tickets/1/comments/new/
Exception Value: Reverse for 'ticket-detail' with keyword arguments '{'pk': None}' not found. 1 pattern(s) tried: ['tickets/(?P<pk>[0-9]+)/\\Z']
Removing the space creates a different error