Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#11125 closed (duplicate)

comment redirect does not work with preview

Reported by: james_stevenson Owned by: nobody
Component: contrib.comments Version: 1.1-beta
Severity: Keywords: next redirect
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'm using rev. 10790, the latest version as of the time this ticket was submitted.

The django docs say that you can redirect after a comment is posted by including a field like this in your comment form:

<input type="hidden" name="next" value="{% url my_comment_was_posted %}" />

However, this is incorrect. The post_comment view in django.contrib.comments.views.comments does not preserve this field for the comment preview form. Thus in the preview form template, the next variable is always None. The reason why is clear:

def post_comment(request, next=None):

There is never a "next" keyword argument passed to this view, so next is always None.

Attachments (2)

comments.py (4.4 KB) - added by james_stevenson 5 years ago.
patch which fixes the problem by assigning the correct value to next is available
comments.patch (451 bytes) - added by leanmeandonothingmachine 5 years ago.

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by james_stevenson

patch which fixes the problem by assigning the correct value to next is available

comment:1 Changed 5 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Can you please upload a real patch (run svn diff from the root of your Django SVN checkout)? This isn't a patch (it's just the whole file), so it's impossible to see what's changed.

comment:2 Changed 5 years ago by jacob

  • Resolution set to invalid
  • Status changed from new to closed

On further review, don't bother: this isn't a bug. The redirect handling is handled in django.contrib.comments.views.utils.next_redirect; the value of next is first taken from request.POST, and then from the variable passed to the view.

comment:3 Changed 5 years ago by leanmeandonothingmachine

Actually this is a bug. django.contrib.comments.views.utils.next_redirect is never called if the preview template gets rendered which means that in the preview template next is always none.

comment:4 Changed 5 years ago by leanmeandonothingmachine

  • Resolution invalid deleted
  • Status changed from closed to reopened

Changed 5 years ago by leanmeandonothingmachine

comment:5 Changed 5 years ago by russellm

  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #9268

comment:6 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.