'function' object has no attribute 'info'

Viewed 26

am trying to create user authentication and i dont know exactly what i was doing wrong, this erro function user has no attribute 'info' could not permit me to proceed with my project. below is the code

this are my imports

from django.contrib.auth import login
from django.shortcuts import redirect, render, get_object_or_404
 
from .forms import CustomUserCreationForm, PostForm, CommentForm
from . models import About_us, My_blog, Like, Comment, Slider, Prayers, Description, Novena

from django.urls import reverse
from django.http import HttpResponseRedirect
from django.core.paginator import Paginator,  EmptyPage, PageNotAnInteger
from . like import new_likes
from django.contrib import messages

from django.contrib.auth.models import User, auth
from django.contrib.auth import authenticate

from django.views.generic import ListView, DetailView

this is the login

def login(request):
if request.method =='POST':
    username =request.POST.get('username')
    password =request.POST.get('password')

    user = authenticate(username=username, password=password)
    if user is not None:
        auth.login(request, user)
        return redirect('home')
    else:
        messages.info(request, 'Invalid credentials')
        return redirect('login')
else:
    return render(request, 'blog/authentication/login.html')

this the signup view

def signup(request):
    if request.method =='POST':
        username =request.POST.get('username')
        email =request.POST.get('email')
        password1 =request.POST.get('password1')
        passwrod2 =request.POST.get('password2')


        if password1 ==passwrod2:
            if User.objects.filter(username =username).exists():
                messages.info(request, 'Username already registered')
                return redirect('signup')
            elif User.objects.filter(email =email).exists():
                messages.info(request, 'Email already registered')
                return redirect('signup')
        
            else:
                user = User.objects.create_user(password=password1, username = username, email=email)
                user.save()
                messages.info(request, 'Registered successful')
                return redirect('home')
        else:
            messages.info(request, 'Password not match')
            return redirect('signup')

    else:
        return render(request, 'blog/authentication/signup.html')

please what am i doing wrong. i tried 'messages.info and even messages.success' but yet it refuse. i need help

0 Answers
Related