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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:16:14+00:00 2026-06-12T17:16:14+00:00

My situation is as follows. I have a django app that is a CMS,

  • 0

My situation is as follows.

I have a django app that is a CMS, and this one app generates page content and menus.

There is ‘default’ view that generates all the page content. One of the fields of the main model is designed to limit the visibility of pages depending on the setting:

  • ‘internal’ (limited to users on our network),
  • ‘worldwide’ (viewable by the www) and now, I would like to add an extra value
  • ‘secure’, which would limit viewing only to those who are logged in to the site.

I dont think @login_required would work, as it only works on whole functions.

We want the author or editor to be able to set this flag, rather than code a special function; and there will be instances where a page migrates from ‘internal’ to ‘secure’ then to ‘worldwide’ – so ideally the urls should stay the same.

What is the best way to go about this?
thanks in advance… patrick

  • 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-12T17:16:15+00:00Added an answer on June 12, 2026 at 5:16 pm

    As you want the flag set on your object, I’m assuming that flag can’t be read until you’re already within the view (i.e. you won’t be storing it in something accessible by the request object, like a session), so that precludes custom decorators. You could choose to go with something a bit crude but workable like this:

    if (val=="internal" and inrange(request.META['REMOTE_ADDR'])) or (val=="secure" and  request.user.is_authenticated()) or val=="worldwide":
         return render_to_response .... etc.
    else:
         return HttpResponseForbidden()
    

    Substituting your model values, and writing the inrange function, naturally.

    The more sophisticated approach, though, would be to write custom middleware and use the process_view() function. See the docs for more details.

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

Sidebar

Related Questions

Essentially, the situation is as follows: I have a class template (using one template
The situation is as follows: I have a ViewModel that has a property that's
Situation is as follows: There is a separate object that is responsible for generating
My situation is as follows: I have a script file ( somescript.js ) that
Interesting situation. I have a Html.Textbox() that I render from a view as follows:
the situation is as follows, i have a page to add/update user in the
I have situation as follows: GUI with several tabs. Every tab shows content of
I have a situation as follows <body> Test<br /> test<br /> test1<br /> </body>
Here is my situation, I have a string as follows 'a':1 'b':2 'c':3 I
Picture the following situation. I have an XML document as follows, <Form> <Control Type=Text

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.