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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:27:22+00:00 2026-06-01T04:27:22+00:00

I have a website with a menu. To generate the menu, I need some

  • 0

I have a website with a menu. To generate the menu, I need some queries in the database. So I created a context processor to do it in all my views.

Some of the views I have are actually forms. I get them using ajax and display them with jquery ui dialog, when my users click on some buttons.

I can’t remove all context processors for those pretty complex forms, I need the auth, static and il8n context processors in particular.
But I don’t want to make the menu based queries in the database to display those forms.

Is there a way to exclude a context processor in a view ?
I tried to put a variable in “request.session” in the view, then remove it and return an empty dictionary in my context processor. But it’s pretty bad and there is possible concurrency issues.
I can also parse the url in “request” in my context processor and return an empty dictionary, but it sounds like an hack again.

Any idea or advice ?
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-06-01T04:27:24+00:00Added an answer on June 1, 2026 at 4:27 am

    This is what Django’s lazy objects are for. Rather than calculate the actual contents in the context processor, you provide a lazy object with an associated function; when something actually tries to use the object, e.g. in a template, then it calls the function. This answer gives an example for the same problem.

    Be careful about memoization if you use the variable more than once; some of the options will re-call the function, while some will save the result. You can look at the source to be sure. I think SimpleLazyObject (as in the answer above) does what you want, but I haven’t used this recently enough to be sure.

    (An answer by request….)

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

Sidebar

Related Questions

I have a JavaScript menu in my website with ul and li structure like
I am building a website www.etutornetwork.com, in top menu I have included a link
I have website, usually all looks fine but sometimes one div is on the
I'm creating a model for a website top-menu structure - I have a MenuObject
I have a website using asp.net mvc in which I need to embed a
I have a website that has a fixed menu, header, etc. and loads the
in my asp.net website I have menu control and there are those items: <asp:menuitem
I have a Telerik Menu in usercontrol that located in aspx page, I need
I have a website with a menu, when menu item is clicked I display
I have a website that has a menu div at the top and a

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.