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 7688233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:52:23+00:00 2026-05-31T19:52:23+00:00

I have a client that has an app built with django. On every page

  • 0

I have a client that has an app built with django. On every page of
their app is a link to their admin site. They tell me the admin site
is generated entirely by django, and they’ve never customized it
before. On the very first line of the admin page it says:

Django administration          Welcome, admin. Change password / Log out

They want me to add a link to that line, to the left of “Django
administration” that will take them back to the page they were on when
they clicked on the link to get them to the admin site.

So I have 2 issues here:

  1. How do I override that line to add the link? It appears that page
    is generated by contrib/admin/templates/admin/base.html, and I tried
    to override it by following the directions at
    https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-a…,
    but whatever I do seems to have no effect.

  2. How can I get the link of the page of the app they came from? It’s
    not simply just going back one page, as they could have navigated all
    over the place of the admin site before clicking the “Back to app”
    link.

  • 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-31T19:52:24+00:00Added an answer on May 31, 2026 at 7:52 pm

    There are many ways to store the last visited non-admin url in request.session. For example, a middleware:

    import re
    
    class LastSiteUrl(object):
        def is_admin_url(self, url):
            return re.search('^(http:\/\/.*){0,1}\/admin\/', url) is not None
    
        def process_request(self, request):
            if self.is_admin_url(request.path) and \
                not self.is_admin_url(request.META.get('HTTP_REFERER','')):
                request.session['last_site_url'] = request.META.get('HTTP_REFERER','')
    

    Then override the template:

    1. Store the last non admin url in request.session, e.g. put the above class in yourproject/middleware.py, add to settings.MIDDLEWARE_CLASSES: middleware.LastSiteUrl

    2. Prepare the admin base site template for overriding, copy django/contrib/admin/templates/admin/base_site.html to yourproject/templates/admin/base_site.html

    3. Link to request.session.last_site_url, e.g. in yourproject/templates/admin/base_site.html, find {% block branding %}, before the H1 tag of this block, add an HTML link to {{ request.session.last_site_url }}.

    It should look like that:

    {% block branding %}
        {% if request.session.last_site_url %}
            <a href="{{ request.session.last_site_url }}">back to site</a>
        {% endif %}
        <h1 id="site-name">{% trans 'Django administration' %}</h1>
    {% endblock %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a client that has Oracle Standard , and a project that would
I have a client that has a requirement to display PDFs directly within a
I have a client that has a PostgreSQL database and he cannot remember the
We have a Japanese client that has source code in COBOL on an mainframe.
I have a .NET web-service client that has been autogenerated from a wsdl-file using
I have a client apllication that run in very restricted area - it has
I have a jar file that has a file named client.ts in (when viewing
I work at a company that has many clients that have their own website
I have an Android client that needs to authenticate with a python Google App
I have a Facebook app that is built as an iFrame. I am using

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.