0

Im new to Django, and im trying to understand, why my code instead of redirect to :

http://127.0.0.1:8000/object/2/

redirect me to:

http://127.0.0.1:8000/object/2/?c=14

Where is the code, that adds this parameters?

Template:

{% if user.is_authenticated %}
    {% get_comment_form for object as comment_form %}

    <form action="{% comment_form_target %}" method="POST">
        {% csrf_token %}
        {{ comment_form.comment }}
        {{ comment_form.content_type }}
        {{ comment_form.object_pk }}
        {{ comment_form.timestamp }}
        {{ comment_form.security_hash }}
        <input type="hidden" name="next" value="{{ object.get_absolute_url }}" />
        <input type="submit" value="post comment" />
    </form>
{% else %}
    <p>Please <a href="{% url 'auth_login' %}">log in</a> to leave a comment.</p>
{% endif %}

views.py:

class realiz_photo_view(DetailView):

    template_name = 'realization/realiz_photo.html'
    model = realiz_photo

    def get_context_data(self, **kwargs):
        context = super(realiz_photo_view, self).get_context_data(**kwargs)
        context["form"] = RealizationForm()
        return context

urls.py:

url(r"^comments/", include("django.contrib.comments.urls")),
url(r'^object/', include('realization.urls')),

realization/urls.py:

urlpatterns = patterns('',
url(r'^(?P<pk>\d+)/$', realiz_photo_view.as_view()),
)
Harkonnen
  • 149
  • 3
  • 11

1 Answers1

0

See my solution here: Django: Redirect to current article after comment post

It basically uses a view that's triggered by the comment post url which redirects back to the original referrer page.

Community
  • 1
  • 1
Corey
  • 166
  • 3
  • 14