2👍
✅
{% if user.is_staff %}
code code code...
{% endif %}
And in views.py add this:
@login_required
def pamokosLOG(request):
return render(request, 'NEpamokosLOG.html',
{'full_name': request.user.username, 'pamokos': Pamoka.objects.all() })
2👍
Current user can be accessible by request.user
if your add 'django.core.context_processors.request'
to your TEMPLATE_CONTEXT_PROCESSORS
And if you want to check superuser status, use is_superuser and is_staff:
{% if request.user.is_staff and request.user.is_superuser %}
code
{% endif %}
Do not forget to assign those attributes to your users.
👤Zulu
- [Django]-How to put an class on specific (first element) inside loop?
- [Django]-Error in django interactive shell on pydev eclipse
- [Django]-Intercepting a Django 500 error for logging, without creating/serving a custom 500.html
- [Django]-How to submit data to database using Django ModelForm?
- [Django]-Django + Sqlite: database is locked
Source:stackexchange.com