user can't login back when he's logged out after creating an account

this is my

from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.decorators import login_required

from userprofile.models import *
from .models import *
from medicale.forms import *

# Create your views here.

def index(request):


    return render(request, 'index.html')

# authentication

def loggin(request):

    if request.method =='POST':

        username = request.POST['username']

        password1 = request.POST['password']

        user = authenticate(request, username= username, password= password1)

        if user is True:

            login(request, user)

            messages.success(request, f'Welcome back {user.fullname}')

            return redirect('index')


  , 'Make sure both the username and password is correct')

            return redirect('loggin')

    return render(request, 'loggin.html')

def loggout(request):


    return redirect('index')

this is my

from django.urls import path

from . import views


    path('', views.index, name='index'),

    path('loggin/', views.loggin, name='loggin'),

    path('loggout/', views.loggout, name='loggout'),

    path('signup/', views.signup, name='signup'),

    path('contact_us/', views.contact_us, name='contact_us'),

    path('department/', views.department, name='department'),

] i’m not using django’s login form

# used for users to create account for theirs

from dataclasses import field

from logging import PlaceHolder

from django.contrib.auth.models import User

from django.contrib.auth.forms import UserCreationForm

from django import forms

from django.forms import ModelForm

from userprofile.models import Contact_us, Profile

class SignupForm(UserCreationForm):

    username = forms.CharField(max_length=10)

    fullname = forms.CharField(max_length=250)

    phone_number = forms.CharField(max_length = 150)

    email = forms.EmailField(max_length=50)

    class Meta:

        model = User

        fields = ['username', 'fullname','phone_number','email', 'password1', 'password2']


{% extends 'base.html' %}

{% load static %}

<!-- title section -->

{% block title %} |Login{% endblock title %}

<!-- content section -->

{% block content %}

<div class="login-page">

    <div class="container-fluid">

        <div class="login-writting container">

            <h2 class="log"><a href="{% url 'index' %}" class="i text-decoration-none text-primary"><strong> M<span class="log text-danger">E</span>D<span class="log text-danger">I</span>C<span class="log text-danger">A</span>L<span class="log text-danger">E</span></strong></a></h2>

            <h4 class="m text-center mt-5 pt-5"><strong> Welcome Back </strong><br><span class="log text-primary"> Login to view your personal details and records</span></h4>


        <div class="container mt-3 pt-4 mb-4 align-items-center">

            <div class="row justify-content-around login-row">

                <div class="col-sm-4 mt-5 pt-2 acct">

                    <h2>Create Your Account</h2>

                    <span class="de ">

                        Please create an account if you have not yet scheduled

                        online us. <b>Note: This account information is stored both

                        on the servers and on premises.</b>


                    <a href="{% url 'signup' %}" class="btn btn-primary w-50 mt-5">Create Account <i class="fa-solid fa-angle-right text-primary 2x"></i></a>


                <div class="col-sm-4 mb-4 pb-5 mt-5 pt-2">

                    <h4>Account Sign-In</h4>

                    <form action="{% url 'index' %}" method="POST">

                        {% csrf_token %}

                        <div class="form-group">

                            <label for="inputName">Username</label>

                            <input type="text" name="username" class="form-control border-1 bg-transparent " id="inputName" required>

                            <i class="fas fa-user ml-auto" style="position: absolute;top: 31%;left: 90%"></i>


                        <div class="form-group">

                            <label for="inputPassword4">Password</label>

                            <input type="password" name="password" class="form-control bg-transparent" id="inputPassword4" required>

                            <i class="fas fa-lock ml-auto" style="position: absolute;top: 60%;left: 90%"></i>


                        <button type="submit" class="btn btn-primary h-100 w-50">Submit</button>







{% endblock content %}

i’ll really appreciate if anyone can help

The error is more likely to be in your signup view.

You’re using raw html for the input fields. Since you’re creating a form, you should be rendering your form on the page and not trying to render individual fields as html tags.

See Working with forms | Django documentation | Django.