2👍
✅
Works properly in 1.3:
class TestView(DetailView):
def get(self, request, **kwargs):
import ipdb; ipdb.set_trace()
ipdb> request.user
<User: zk>
ipdb> request.user.is_authenticated()
True
Possibly a bug?
1👍
Try using the decorators from django.contrib.auth.decorators
. In your urls.py
, you can do something like:
from django.contrib.auth.decorators import login_required
...
url(r'^something/?$', login_required(MyDetailView.as_view()))
...
For checking permissions, you can use the premissions_required
decorator. For more info, check out the docs: https://docs.djangoproject.com/en/dev/topics/auth/#the-login-required-decorator
- [Django]-How to call multiple views on one url in pinax
- [Django]-Mock a model method in Django
- [Django]-Django – CSS File Not Loading In Production (Debug: False)
- [Django]-Django – Find out which model the variable belongs to
- [Django]-How to sort records in python?
- [Django]-Django date YYYY-MM-DD
- [Django]-Django Celery, ImportError: Import by filename is not supported
Source:stackexchange.com