我如何从django

问题描述 投票:0回答:1
def index(request):
    form = Postform()
    if request.method == 'POST':
        template_string = request.POST.get("body")
>! here i want the id for some reason
        print("Original", template_string)

        rendered_content = render_template_content(template_string)
        print("Rendered", rendered_content)

        form = Postform(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.body = rendered_content
            post.save()
            form = Postform(initial={'body':rendered_content})
        else:
             form=Postform()
    
    return render(request, 'index.html', {"form": form})

我正在前端使用CKeditor,并在Body中发送整个文本区域

{{product.name.1}}

我想提取这个ID


python django django-templates request ckeditor5
1个回答
0
投票
如果您需要产品的ID,则需要使用

product.id

。问题在于,我在任何地方都看不到该产品。


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.