Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 543339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:32:28+00:00 2026-05-13T10:32:28+00:00

im using the comment system, now, i would like to re-write the segment form

  • 0

im using the comment system, now, i would like to re-write the segment form the url comment and append a symbol #, i want to move the page seccion to the comment list exactly to the last comment user with <a name=#{{comment.id}}?> username </a>

Im using next for redirect the usen when the comment was posted:

{% get_comment_form for object as form %}
<form action="{% comment_form_target %}" method="POST">
  {{ form }}
  <input type="hidden" name="next" value="{{ object.get_absolute_url }}" />
  <input type="submit" name="preview" class="submit-post" value="Preview"></td>  
</form>

But in the Django Doc dont say nothing about rewrite or customizer the comment redirect / url

Any idea?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:32:28+00:00Added an answer on May 13, 2026 at 10:32 am

    I just stumbled across this little bit of ugliness. After reading the source code I didn’t see any nice way to override this behavior. By default you are redirected to the URL in the template’s {{ next }} variable and Django appends a ?c=1 to the URL where the 1 is the ID of the comment. I wanted this to instead be #c1 so the user is jumped down the page to the comment they just posted. I did this with a little bit of “monkey patching” as follows:

    from django.contrib.comments.views import utils
    from django.core import urlresolvers
    from django.http import HttpResponseRedirect
    
    def next_redirect(data, default, default_view, **get_kwargs):
        next = data.get("next", default)
        if next is None:
            next = urlresolvers.reverse(default_view)
        if get_kwargs:
            next += '#c%d' % (get_kwargs['c'],)
        return HttpResponseRedirect(next)
    
    # Monkey patch
    utils.next_redirect = next_redirect
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to move my photo management system from XML to MySQL and
I am using the built in comment system with Django but it has started
I want to comment a line using the pre-processor: #define open /##* #define close
I am using NERD commenter Let's say that I want to comment out lines
I am using the Quickflip 2 plugin ( http://jonraasch.com/blog/quickflip-2-jquery-plugin/comment-page-3#comment-3562 ) to have images flip
I'm creating a comment system for my website. Right now its just a basic
Currently finalising the coding for my comment system, and it want it to work
I am using Ruby on Rails 3 and I would like to handle user
I would like to make my own compenents using, and for, VC9 & Visual
I am using a login system. When I navigate to comments/index.php without logging in,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.