Customizing django-comments -


Therefore, I am using django.contrib.comments. I have installed it properly but instead of the unwieldy default comment form, I want to use a custom form template that only shows one texture and submits the button.

The reason behind this is that the user only sees the form if those areas are already authenticated, and I want to keep the form simple and automatically lift my username.

I have applied a custom form, but when I try submit it.

What is with me in my template for the page with the comment form (the object passed from the entry scene):

  {% load comments%} {% entry% For example, if your HTML is here, user.is_authenticated%}, then% render_comment_form}  

and / html / html / html /

& Lt; P & gt; Submit a comment: & lt; / P & gt; & Lt; Form action = "/ comments / post /" method = "post" & gt; & Lt; Textarea name = "comment" id = "id_comment" rows = "2" style = "width: 90%;" & Gt; & Lt; / Textarea & gt; & Lt; Input type = "hidden" name = "option" value = "{{option}}" /> & lt; Input type = "hidden" name = "target" value = "{{target}}" /> & Lt; Input type = "hidden" name = "gonzo" value = "{{hash}}" /> & Lt; Input type = "hidden" name = "next" value = "{{entry.get_absolute_url}}" /> & Lt; Span style = "float: true;" & Gt; & Lt; Input type = "submit" name = "post" value = "add" & gt; & Lt; / Span & gt; & Lt; / Form & gt; {% Else%} & lt; P & gt; Please & lt; A href = "/ login /" & gt; Login & lt; / A & gt; To post a comment. & Lt; / P & gt; {% Endif%}

It renders properly initially, but when I try to submit the comment form, I get the following DJs error:

< Pre> Post comment is not allowed (400) Why: Unavailable content_type or object_pk field

Can anyone help?

The comment model uses the usual key to map the object in which the comment was made It is as if the hidden areas in the blog entry standard comment form are required.

from django.contrib.comments.models

  ... class comment security forms: "" "Security aspects (anti-spoofing) for comments forms Handles. " "" Content type = form. If you have not changed the form class and want to change only the html template, you will be able to change the HTML code in the form field. You can add these fields by adding them to the loop on all hidden areas.  
  {% Hidden form form.hidden_fields%} {{hidden}} {% endfor%}  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -