Answer the question
In order to leave comments, you need to log in
DJ CRUD update?
When going to the post editing page, it gives an error, and tags can be changed without problems,
although both (post, tag) use the same
Traceback mixin
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'
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'),
]
{% 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 %}
Answer the question
In order to leave comments, you need to log in
Test the screw (vicrotia, mhdd), if everything is in order, then stop hitting the laptop during operation :)
Another fault may be the cable of the screw.
Do not produce questions How to fix recovery win 10 error?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question