I developed a django website on my local machine and now is the time to upload it on a server. I would like that during the time i work on it, only logged in users can see it. I thought about a
{% if is_logged_in %}
{% else %}
{% endif %}
structure in my base.py template but not all my views return a Context so it doesn't always work.
Is there any simple way without having to change much of code to hide every pages?
There are 2 reasonable solutions for this.
mod_wsgi
and mod_python
you can let Apache authenticate it's users via Django.Use django.contrib.auth.decorators.login_required
. It is a decorator, that will prevent users from viewing anything, if they are not logged in. Or you can find middleware for this: http://djangosnippets.org/snippets/1179/.
Middleware will be better, becuase it is unobtrusive and you can remove it later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With