Hello, I have quite interesting problem with password protected content in Django. I can successfully protect my content or URLs in Django by using "@login_required" decorator. Example: Urls.py
Views.py
So basically this example would work like this: Dynamic urls from DB all protected by password - because of "@login_required" decorator http://www.example.com/category1/ http://www.example.com/category2/ http://www.example.com/category3/ What I want to achieve is that for example in admin I want to specify that some pages are with login and some not like in the example that with login: http://www.example.com/category1/ http://www.example.com/category3/ Without login: http://www.example.com/category2/ That during creation in admin specifying the url (thats easy) but also specify with checkmark do not need to login something like that. Can I use python in the views:
Disregard the syntax only explaining where I am going. Can you help me? Thanks |
That is basically what you would do. You would add a Boolean value to your model that represented 'login required'. You would than have a nested for-loop that would look something like this,
answered 14 Apr '12, 17:03 johns Thanks for the answer... Would you be able to write full syntax for that? I know it would go to models.py
Views.py I want to write "if the value in that model for that record is True, find out if the user is logged in if not show him login page ELSE just show the page without login" I know there is script for checking the user:
I would like to see it to write it properly I am not advanced in python but learning :) Thanks a lot
(16 Apr '12, 16:29)
rentgeeen
Submit a support ticket so I can see your live code, its hard to say what exactly you will need without seeing what objects it is going to effect in real-time. In the support ticket I want to see the full paths to the view and model this will be in effect on and the line numbers to the relevant code, I also need the URLs to the site that these views effect. Do not just say the name of the project and general info, I will need specifics. I can't promise I can write the full syntax, you are the developer who will be ultimately responsible for the security of your site, it is your responsibility to learn how to write the code that does that so you can know how it works. I will take a look and write as much of it as I can and answer any questions to enable you do do this yourself in the future.
(16 Apr '12, 17:10)
johns
|