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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:36:24+00:00 2026-06-14T02:36:24+00:00

i have a function in views.py , for example something like this : def

  • 0

i have a function in views.py , for example something like this :

def get_base_content():
    footer = SiteContent.objects.get(pk=1)
    return {
        "footer" : footer,
}

how can i call this function in my template and use footer variable in it ?

  • 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-14T02:36:25+00:00Added an answer on June 14, 2026 at 2:36 am

    If you want to have this variable shown on all templates, then you need to implement a template context processor.

    You just need minimal changes to your code:

    def get_base_content(request):
        footer = SiteContent.objects.get(pk=1)
        return {"footer" : footer}
    

    Now, add that to a separate file, call it custom_context.py. In your settings.py add it to your TEMPLATE_CONTEXT_PROCESSORS setting:

    TEMPLATE_CONTEXT_PROCESSORS = (
        "django.contrib.auth.context_processors.auth",
        "django.core.context_processors.debug",
        "django.core.context_processors.i18n",
        "django.core.context_processors.media",
        "django.core.context_processors.static",
        "django.core.context_processors.tz",
        "django.contrib.messages.context_processors.messages",
        "myapp.custom_context.get_base_content", # don't forget the comma!
    )
    

    Now, in your view code you just need to make sure you are using RequestContext. The easiest way to do that is to use the render shortcut:

    from django.shortcuts import render
    
    def myview(request):
       return render(request,'hello.html',{'foo': 'bar'})
    

    In hello.html you’ll have {{ foo }} and {{ footer }}

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

Sidebar

Related Questions

Let's say I have a function like this (it's only an example, so do
I have a table with number of page views per day. Something like this:
I have two functions that return simple strings. Both are registered. $.views.helpers({ parseDate: function
I have code like this in my view model: function ChatListViewModel(chats) { var self
I have a function defined in a module called DataAccess like this module DataAccess
I have something like this: SELECT id, fruit, pip FROM plant WHERE COUNT(*) =
I have a function in jQuery that does something like the following to allow
I have a site whose URLs look like http://www.example.com/NY-2010/ http://www.example.com/NY-2010/location/ http://www.example.com/NY-2010/something-else/ http://www.example.com/Washington-2009/ http://www.example.com/Washington-2009/location/ http://www.example.com/Washington-2009/something-else/
I have something like this on my view: <input type=checkbox value=1 name=services-for /> <input
I have the view function in django that written like a dispatcher calling other

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.