找不到带有关键字参数'{'PK':'的'PLAN_EDIT'的反向。1个已尝试的图案:['Palan/EDIT$']

发布时间:2022-09-29 / 作者:清心寡欲
本文介绍了找不到带有关键字参数';{';PK';:';的';PLAN_EDIT';的反向。1个已尝试的图案:[';Palan/EDIT$';]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

找不到关键字参数为‘{’pk‘:’‘}的’PLAN_EDIT‘的反向。已尝试1个模式:[‘Palan/EDIT$’]`。

有人知道如何解题吗?

urls.py

urlpatterns = [
    url(r'^$', views.post_list, name='post_list'),
    url(r'^palan/(?P[0-9]+)/$', views.palan_detail, name='palan_detail'),
    url(r'^palan/new/$', views.plani_new, name='plani_new'),
    url(r'^nn1/new/$', views.plani_new1, name='plani_new1'),
    url(r'^palan/edit$', views.edit, name='plan_edit'),
]

views.py

def edit(request, pk):
    post = get_object_or_404(Planning, pk=pk)
    if request.method == "POST":
        form = PostFormP(request.POST, instance=post)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.published_date = timezone.now()
            post.save()
            return redirect('palan_detail', pk=post.pk)
    else:
        return render(request, 'pages/plan_edit.html')

def palan_detail(request, pk):
    palan = get_object_or_404(Planning, pk=pk) 
    j = Jour.objects.all().count() 
    return render(request, 'pages/palan_detail.html', {'palan': palan, 'j':j},) 

Palan_Detail.html


    

{{ palan.parcours }}

{{ palan.semestre|linebreaksbr }}

{{ palan.jour.jour1}}

推荐答案

您的视图中没有名为post的上下文变量。更改以下行



这篇关于找不到带有关键字参数';{';PK';:';的';PLAN_EDIT';的反向。1个已尝试的图案:[';Palan/EDIT$';]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持吉威生活!



[英文标题]Reverse for 'plan_edit' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['palan/edit$']


声明:本媒体部分图片、文章来源于网络,版权归原作者所有,如有侵权,请联系QQ:330946442删除。