You probably just want to use the login_required decorator. https://docs.djangoproject.com/en/2.1/topics/auth/default/#the-login-required-decorator
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of ??? Sent: Wednesday, February 6, 2019 12:40 AM To: Django users Subject: how to let django return response to web browser at my own function I want to write a function 'get_user_or_log_in' to check whether the user has logged or not. If logged, return user's name, if not, redirect to the login page. I want to use it like function 'get_object_or_404'. But I do not know how to let django response at my own function not just at the end of functions in views.py . -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1c4981ef-a3bc-40c3-a521-0287442f37b9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0893b59667aa435a948909a7dcc24bfa%40iss2.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.

