How to make password hashing in django project, i am using custom autentication for login?

I want to make password hashing possible for a django project.

views.py for login.

def asset_login(request):
if request.method == 'POST':
    username = request.POST.get('user_id')
    password = request.POST.get('password')
    try:
        user = UserTable.objects.get(username=username, password=password)
        if user:
            if user.status == 'inactive':
                messages.error(request, 'Your account is inactive.')
                return redirect('asset_login')
            request.session['name'] = user.name
            request.session['role'] =user.role
            if user.role == 'admin':
                return redirect('admin_dashboard')
            elif user.role == 'ciso':
                return redirect('ciso_dashboard')
            elif user.role == 'fnhead':
                return redirect('fnhead_dashboard')
            elif user.role == 'systemadmin':
                return redirect('systemadmin_dashboard')
            elif user.role == 'assetowner':
                return redirect('assetowner_dashboard')
            else:
                messages.error(request, 'Unknown user position')
                return redirect('asset_login')  # Redirect to clear form and message
    except UserTable.DoesNotExist:
        messages.error(request, 'Invalid username or password')
        return redirect('asset_login')  # Redirect to clear form and message
return render(request, 'asset.html')

models.py for username and password

class UserTable(models.Model):
sl_num = models.CharField(max_length=100)
name = models.CharField(max_length=100)
phone_no = models.CharField(max_length=100)
email = models.EmailField(blank=False, null=False)
location = models.CharField(max_length=100)
department = models.CharField(max_length=100)
status = models.CharField(max_length=100)
role=models.CharField(max_length=100)
username=models.CharField(max_length=100)
password=models.CharField(max_length=100)

def __str__(self):
    return self.name

I want to make paasword hasing possible on django project , i am using custom authentication instead of django build in autentication.

The set_password method on the User object performs the password hashing for you. (Note that your password field is too short to store the hashed password. The current password field is 128 characters.)

I am curious as to exactly what you mean by this. Is it that you’re using your own views, or are you saying that you’re creating your own authentication backend?

you should read Customizing authentication in Django | Django documentation | Django

make hash

from django.contrib.auth.hashers import make_password
make_password(string)