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

The Archive Base Latest Questions

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

I have such a question, i have googled a lot, read about decorators and

  • 0

I have such a question, i have googled a lot, read about decorators and middleware, but i didnt catch how to solve my question better.

i have base template base.html and templates template1.html and template2.html which are extended of base.html.

base.html has some general block, which is needed in template1.html and template2.html.
this block is with dinamic data, so i have to get data for this block in each view and then render template.

for example i have 2 views :

@render_to("template1.html")
def fun_1(request):
data = getGeneralData()
#...getting other data
return {
        "data" : data,
        "other" : other_data,
}

@render_to("template2.html")
def fun_2(request):
data = getGeneralData()
#...getting other data
return {
        "data" : data,
        "other2" : other_data2,
}

So general i need this getGeneralData in all of my views, have i to call getGeneralData() function in every my view or can i make any function which will get general_data and render it to template before any view gets its own data ?

Can you please provide me an example of code or give me a good link how to do it better?

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

    Will recommend you to write your own context processor and return required context data from there.

    Example :

    custom_context_processor.py

    def ctx_getGeneralData(request):
        ctx = {}
        ctx['data'] = getGeneralData()
        return ctx
    

    In settings file, update TEMPLATE_CONTEXT_PROCESSORS to have 'custom_context_processor.ctx_getGeneralData'

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

Sidebar

Related Questions

Such a decent question,how do I add images(I googled,but they say I have to
I have a question about why there is such a difference in speed between
I have a question about Parallel Object Hierarchies such as DTO. Theses hierarchies has
I have a question about the use of data structures such as ArrayLists in
I would like to ask such question, I have XML xsd`s, which generate beans
I have a question, that represents interest to me. Suppose I have such a
This seems like such a simple question. I have several Edit boxes on my
I have a simple question: how exactly are array variables such as $_SESSION and
I appreciate this is an incredibly noob question, but having Googled multiple combinations of
This may seem a common question but I googled to find the right answer

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.