[Python] There Are Some Basics I Need To Understand Regarding Python Custom User Models

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to delete a user. After a bit of struggling I ended up with:

    views.py

    the_user = get_user_model()

    @login_required
    def del_user(request):
    email = request.user.email
    the_user.objects.filter(email=email).delete()
    messages.warning(request, "bruker slettet.")
    return redirect("index")


    But I really do not understand the following line:

    email = request.user.email.


    And why not?

    email = request.the_user.email


    Is this because the user is referring to the AbstractBaseUser?

    Continue reading...

Compartilhe esta Página