django-fluent/django-fluent-comments

Reload the page after posting the comment

popovvasile opened this issue · 1 comments

How should look like the "action" attribute to send the user to the same page where he posted the comment?

`{% load comments i18n %}
{% if user.is_authenticated %}
<form action="??????????????" method="post">{% csrf_token %}
  {% if next %}
    <div><input type="hidden" name="next" value="{{ next }}"/></div>{% endif %}
  {% for field in form %}
    {% if field.is_hidden %}
      <div>{{ field }}</div>
    {% else %}




      {% if field.errors %}{{ field.errors }}{% endif %}
      <p
              {% if field.errors %} class="error"{% endif %}
              {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
        {{ field.label_tag }} {{ field }}
      </p>
    {% endif %}
  {% endfor %}
  <p class="submit">
    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}"/>

  </p>
</form>
{% else %}
    Trebuie să fiți <a href="javascript:alert('send to login page')">logat(ă)</a> pentru a lăsa comentarii.
{% endif %}
`

The JavaScript code loaded in the page makes sure there is no reload, and instead, you get a smooth comment experience. If you avoid loading the JavaScript code, everything works with normal refreshes.