Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python __init__()得到一个意外的关键字参数';用户id';在django_Python_Django - Fatal编程技术网

Python __init__()得到一个意外的关键字参数';用户id';在django

Python __init__()得到一个意外的关键字参数';用户id';在django,python,django,Python,Django,我有一个更新视图的表单,如下所示: class editpost(forms.ModelForm): 类元: 模型=员额 字段=['body'] 还有这样一种观点: @需要登录\u def post_编辑(请求、用户id、post_id): 如果request.user.id==user\u id: post=获取对象或404(post,pk=post\U id) 如果request.method==“POST”: form=editpost(request.POST,instance=POS

我有一个更新视图的表单,如下所示:

class editpost(forms.ModelForm):
类元:
模型=员额
字段=['body']
还有这样一种观点:

@需要登录\u
def post_编辑(请求、用户id、post_id):
如果request.user.id==user\u id:
post=获取对象或404(post,pk=post\U id)
如果request.method==“POST”:
form=editpost(request.POST,instance=POST)
如果form.is_有效():
ep=form.save(commit=False)
ep.slug=slugify(form.cleaned_data['body'][:30])
ep.save()
messages.success(请求“您的帖子编辑成功”、“成功”)
返回重定向('帐户:仪表板',用户id)
其他:
form=EditPostForm(实例=post)
返回呈现(请求'editpost.html',{'form':form})
其他:
返回重定向('Posts:index')
和url.py,如下所示:

从django.url导入路径
从…起导入视图
应用程序名称='Posts'
URL模式=[
路径(“”,views.index.as_view(),name='index'),
路径('//',views.detailPost,name='detail'),
路径('addpost/',views.addpost,name='addpost'),
路径('delpost/',views.delpost,name='delpost'),
路径('editpost/',views.editpost,name='editpost'),
]

当我打开editpost url时,我遇到了这个错误,我应该怎么做才能修复它?

editpost的路径应该指向您的查看方法:
视图。post\u edit
不是
视图。editpost

path('editpost/<int:user_id>/<int:post_id>', views.post_edit, name='editpost'),
path('editpost/',views.post\u edit,name='editpost'),

editpost的路径应指向您的查看方法:
视图。post\u edit
视图。editpost

path('editpost/<int:user_id>/<int:post_id>', views.post_edit, name='editpost'),
path('editpost/',views.post\u edit,name='editpost'),

您可以包括account/url.py吗您可以包括account/url.py吗