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

  • SEARCH
  • Home
  • 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 7829191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:39:51+00:00 2026-06-02T10:39:51+00:00

I like SO’s effect on when you click a notification from the top-left where

  • 0

I like SO’s effect on when you click a notification from the top-left where it says “Stack Exchange”, then the SO will open a new page, jump to the specific section, then highlight the section in yellow and fade out.

Currently I have a comment form that is on the bottom of a long website. And when the comment posting fails the validation, I have jQuery to scroll to the form and do the same yellow highlight effect as SO.

Here is my (perfectly working) code:

$(document).ready(function() {
    {% if focus %}
        // Focus
        $('html, body').animate({scrollTop: $('#{{ focus }}').offset().top }, 'slow')
        $('#{{ focus }}').effect("highlight", {}, 3000)
    {% endif %}
})

I have this code in my base.html so every template checks for a template variable called focus. focus is simply a string that holds the id of the <div> to do the yellow highlight effect.

As you can see I feel this is a bit hacked. I need to pass focus in a dictionary using render() in Django’s views.py.

What I really want to do is pass it as a GET variable. Something like http://www.example.com/orders/2/?focus=comment_form. Then I can get that GET variable using Javascript and do the highlight effect. But I don’t know how to pass a GET variable using render().

Currently my render() looks like this:

dictionary = get_orders_detail_dictionary(order=order, user=request.user, comment_form=form)
dictionary['focus'] = 'comment_form'
return render(request, 'doors/orders/detail.html', dictionary)

The reason I want to use a GET is for like “permalinking” options.

  • 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-06-02T10:39:54+00:00Added an answer on June 2, 2026 at 10:39 am

    Since it’s a GET variable, it’s available from request.GET. And since you’re using the render shortcut, you can enable the request context processor to make the request object available in your templates, at which point you can just do {{ request.GET.focus }}.

    However, to me a better option would be to use your own custom context processor which extracts the focus param into a context variable:

    def get_focus(request):
        return {'focus': request.GET.get('focus', '')}
    

    and then you can use {{ focus }} exactly as you do now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like this:(with left click or shortcut) and that would open main.xml It would really
Like the title says, If I place an app_offline.htm in the application root, will
Like the title says, how can i remove the spinwheel from a Panel? I
Like any other hard disk, virtual hard discs (*.vhd) will suffer from fragmentation. So
Like the title says, I can't get Canvas/CanvasLayer working in PlayN. My sample code
Like it says.
Like the title says Where and How (i.e. if encrypted, with what method) does
Like the title says, how do you create custom code snippets in Visual Studio
For some reason, after submitting a string like this Jack’s Spindle from a text
Like the question says is there a better way to write this: SELECT clients_lists.*,

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.