[PYTHON] Django non-logged-in users want to transition to login.html

For class, use LoginRequiredMixin

from django.contrib.auth.mixins import LoginRequiredMixin
#Abbreviation
 
class Top(LoginRequiredMixin, generic.TemplateView):
    template_name = 'hogehogeapp/index.html'☛☛☛ Enter the application name for the hogehogeapp part

For functions use the login_required decorator

from django.contrib.auth.decorators import login_required

@login_required
def hogehoge(request, pk):
    hogehoge

Recommended Posts

Django non-logged-in users want to transition to login.html
[Django] Want to customize your admin page?
I want to pin Datetime.now in Django tests
I want to upload a Django app to heroku
I want to transition with a button in flask
I want to scroll the Django shift table, but ...
TemplateView patterns you'll want to learn first in Django
[Django] How to redirect unlogged-in users to the login page
Transition from WSL1 to WSL2
unable to import django
update django version 1.11.1 to 2.2
[Django] A memorandum when you want to communicate asynchronously [Python3]
I want to make a blog editor with django admin
Display the time in Django according to the user's region (UTC)
[Django] I want to log in automatically after new registration