Title: TypeError at /signin/ 'module' object is not callable
Tags: python,django,django-models,django-views,django-templates

Question: As I'm working on django for the first time, so I was trying to create a user authentication page. Everything works fine but when I try to signin Im getting an error.
app name : authentication
views.py
from django.shortcuts import redirect, render
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.contrib import messages
from django.contrib.auth import login, logout
import authentication


def home(request):
    return render(request, "authentication/index.html")


def signup(request):

   if request.method == "POST":
       username = request.POST['username']
       fname = request.POST.get('fname')
       lname = request.POST.get('lname')
       email = request.POST['email']
       pass1 = request.POST['pass1']     
       pass2 = request.POST['pass2']  
       myuser = User.objects.create_user(username,email,pass1)   
       myuser.first_name = fname or ''
       myuser.last_name = lname or ''
   
       myuser.save()

       messages.success(request, "Your account has been successfully created.")

       return redirect('signin')

   return render(request, "authentication/signup.html")

def signin(request):

    if request.method == "POST":
        username = request.POST['username']
        pass1 = request.POST['pass1']

        user = authentication (request,username=username,password=pass1)

        if user is  not None:
            login(request,user)
            fname = user.first_name
            return render(request,"authentication/index.html", {'fname':fname})

        else:
            messages.error(request,"Bad credentials!")
            return redirect('home')

    return render(request, "authentication/signin.html")

def signout(request):
    logout(request)
    messages.success(request, "logged out successfully!")
    return redirect('home')

urls.py
 from django.urls import path
 from . import views

 urlpatterns = [
    path('signup/', views.signup, name='signup'),   
    path('signin/', views.signin, name='signin'),
    path('signout/', views.signout, name='signout'),
 ]

templates/signin.html
<!DOCTYPE html>
<html>
    
    <body>
        <h3>SignIn</h3>
        
        {% for message in messages %}
        <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
        <strong>Message:</strong> {{ message }}
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
        </button>
        </div>
        {% endfor %}
        <form method="POST" action="{% url 'signin' %}">
            {% csrf_token %}    
            
            <label for="">Username</label>
            <input type="text" id="username" name="username" placeholder="Enter your username" Required>
            <br>

            <label for="">Password</label>
            <input type="password" id="pass1" name="pass1" placeholder="Enter your password" Required>
            <br>
 
            <button type="submit">Sign In</button> 
        </form>
    </body>
</html>

Error:
file "C:\Users\ab\project\authentication\views.py", line 49, in signin
    user = authentication (request,username=username,password=pass1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable

How can I solve this error?

Answer: My best guess is that you are calling authentication but it is not a function. I think what you are trying to do is
user = authenticate(request, username =username, password =password)
make sure that you have imported this from django.contrib.auth
 From django.contrib.auth import login, logout, authenticate
I hope this helps