Davansh:
The tables are made already in Admin Django, you only have to build
template (html), and the view. For example, in views.py:

def login_ini(request):
    variable1 = 'Pantalla de Acceso al Sistema'
    error_log = 'ok'
    username = request.POST.get('username')
    password = request.POST.get('password') # valor del template
    user = auth.authenticate(username=username, password=password)
    if request.method == "POST":
        if user is not None and user.is_active:
            #Correct password, and the user is marked "active"
            auth.login(request, user)
            request.session['username_x'] = username # variable gobal
            request.session['id_x'] = user.id   # variable gobal
            return HttpResponseRedirect("principal")
            error_log = "error"

    context = {'user':user,"variable1":variable1,"error_log":error_log,}

    return render(request,'login_ini.html',context)


def log_out(request):
logout(request)
return redirect('login_ini')

Where login_ini.html, is the authentication template.

Only you must to build authentication template


Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El mié, 3 mar 2021 a las 13:54, Devansh Soni (<honey25s...@gmail.com>)
escribió:

> Hi,
>
> I'm currently working on a Django project in which I have to create a User
> model with fields such as username, email, college, branch, semester,
> password, etc. And use this model to authenticate a user with an email and
> password.
>
> How can I achieve this? Or what are the ways to achieve this?
>
> Thank you
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc2401f3-c80d-4b03-8b02-e62c90645ee8n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fc2401f3-c80d-4b03-8b02-e62c90645ee8n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVvSDCiWju%3D9B29mJaDkr5e94yXbBdtZx0B2G01nptiqQjKrA%40mail.gmail.com.

Reply via email to