Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect back to same page when errors in Django comments
    primarykey
    data
    text
    <p>How do you get Django comments to redirect back to the same page where you're filling out a comment if there are errors in the comment submission form?</p> <p>So basically I have a template like this:</p> <pre><code>{% block content %} {% render_comment_form for show %} {% get_comment_count for show as comment_count %} &lt;div id="comments-count"&gt; {% if comment_count == 0 %} No comments yet. Be the first! {% else %} Number Of Comments: {{ comment_count }} {% endif %} &lt;/div&gt; {% if comment_count &gt; 0 %} {% render_comment_list for show %} {% endif %} {% endblock %} </code></pre> <p>I created my own list.html and form.html and everything looks fine. In the form.html template there is some code like this:</p> <pre><code>&lt;ul class="form-errors"&gt; {% for field in form %} {% for error in field.errors %} &lt;li&gt;{{ field.label }}: {{ error|escape }}&lt;/li&gt; {% endfor %} {% endfor %} &lt;/ul&gt; </code></pre> <p>So obviously, if there is an error in the comment submission form, I would like the user to see the same page as before only with some errors displayed in the comments form. Or alternatively if this is not possible, just ignore the error and instead of transitioning to the preview.html template, it would just not save the comment and again go back to the page.</p> <p>Any help? Note ideally I dont want to have to create a custom comments app. This functionality should be there already. I know there's a next variable you can pass (and I am doing this), but it only works if the comment form is successful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload