0

On my website, users will be redirected to the profile update page right after logging in, and I want to avoid users going to other URLs if some field of update form is empty. Because having profile informations will be a condition for each user.

I got a result after my all search that this is possible with writing custom decorator. But I still don't have any idea about how to do.

I would really appreciate if someone could give an idea.

Mehmet Can
  • 116
  • 5

1 Answers1

0

add this to your settings.py

LOGIN_REDIRECT_URL = '/'    # change the content to url where you want to redirect
jmrcas
  • 83
  • 2
  • 2
  • 12
  • I already have this. URLs which are implemented with decorator `@login_required` can't be viewed by user who is not logged in. Thanks, but this is not what I need. I need to redirect user to profile update page as long as user doesn't fill the form properly. – Mehmet Can May 23 '20 at 16:07
  • I think you need to put a attribute required so the user will be required to put data into form. try to check [this] (https://stackoverflow.com/questions/7562573/how-do-i-get-django-forms-to-show-the-html-required-attribute) – jmrcas May 23 '20 at 17:20
  • I have this as well. It just prevents form to be submitted without required data. User still can access other URLs although all form is empty. – Mehmet Can May 23 '20 at 18:57