How can i get the id from request body in django

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})

I am using CKeditor in the frontend and is sending the whole text area in body

{{product.name.1}}
i want to extract this id

I am not sure if I have full understanding of your view, would you share the form and model as well?

If you need Id of the product you need to use product.id. The trouble is that in that I can't see the product in that view anywhere.

Вернуться на верх