function' object has no attribute '_meta' django

from django.contrib.auth import login
from django.shortcuts import render, redirect

from .forms import SignUpForm

def frontpage(request):
    return render(request, 'core/frontpage.html')

def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)

        if form.is_valid():
            user =

            login(request, user)

            return redirect('frontpage')
        form = SignUpForm()

    return render(request, 'core/signup.html', {'form': form})

Here is my code, when i signup and hit the submit button, it tells me, that

function’ object has no attribute ‘_meta’ django

the error should be on

login(request, user)

. Thanks for help !

Here is html:

{% extends 'core/base.html' %}

{% block title %}Signup | {% endblock %}

{% block content %}
<div class="p-10 lg:p-20 text-center">
    <h1 class="text-3xl lg:text-6xl text-white">Djangochat</h1>

<form method="post" action="." class="lg:w-1/4 px-4 mx-auto">
    {% csrf_token %}

    <div class="mb-5">
        <label class="text-white">Username</label>
        <input type="text" name="username" class="w-full mt-2 px-4 py-2 rounded-xl">
    <div class="mb-5">
        <label class="text-white">Password</label>
        <input type="password" name="password1" class="w-full mt-2 px-4 py-2 rounded-xl">
    <div class="mb-5">
        <label class="text-white">Repeat password</label>
        <input type="password" name="password2" class="w-full mt-2 px-4 py-2 rounded-xl">

    {% if form.errors %}
        {% for field in form %}
            {% for error in field.errors %}
                <div class="mb-5 p-4 rounded-xl bg-red-300 text-white">
                    <p>{{ error|escape }}</p>
            {% endfor %}
        {% endfor %}
    {% endif %}

    <button class="px-5 py-3 rounded-xl text-white bg-teal-800 hover:bg-teal-700">Submit</button>
{% endblock %}

Usign user = you actually affect the save method to the user variable. Hence, you call login with user being a function (the form method) where it expects a User obejct.

You must change to user = to effectively call the method and retrieve its result (which is a User object)