При переходе на страницу редактирования постов выдает ошибку, а теги без проблем можно изменить
хотя оба (пост, тег) используют один и тот же миксин
Traceback
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/posts/new-post-1555763604/update/
Django Version: 2.1.5
Python Version: 3.7.2
Installed Applications:
['blog',
'engine',
'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:
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
Exception Type: TypeError at /posts/new-post-1555763604/update/
Exception Value: get() got an unexpected keyword argument 'slug'
urls.py
from django.urls import path
from . views import *
urlpatterns = [
path('', index, name='main_url'),
path('posts/', post, name='posts_url'),
path('posts/create/', PostCreate.as_view(), name='post_create_url'),
path('posts/<str:slug>/update/', PostUpdate.as_view(), name='post_update_url'),
path('posts/<str:slug>/', PostInfo.as_view(), name='post_url'),
path('tags/', tag, name='tags_url'),
path('tags/create/', TagCreate.as_view(), name='tag_create_url'),
path('tags/<str:slug>/', TagInfo.as_view(), name='tag_url'),
path('tags/<str:slug>/update/', TagUpdate.as_view(), name='tag_update_url'),
]
post_update.html
{% extends 'main/index.html' %}
{% block title %}
Update post
{% endblock %}
{% block content %}
<form action="{{ post.get_update_url }}" method="POST">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
{% if field.errors %}
<div class="alert alert-danger">{{ field.errors }}</div>
{% endif %}
{{ field.label }}
{{ field }}
</div>
{% endfor %}
<a href=""><button type="submit" class="btn btn-primary">Изменить пост</button></a>
</form>
{% endblock %}