Login problem

I have created the users from admin page and when I’m trying to login. It is not working

Here is the users and when I’m trying to login it is not working out.

The login view and html files are as follows and also I’m unable to register using aluminiregister there also the same problem.Can anyone help me out to find the mistake what I’ve done .

please, help me, It’s a multiple user type and i have a registered alumini (which i’ve created using admin page bcoz i’m unable to register using the alumini register page) and when i’m trying to login after clicking login .It’s not logging me in and sometimes it’s showing csrf_token not defined properly though i’ve defined it

When you want to post code here, please don’t post images. They’re hard to read and impossible to quote lines.

When posting source code, enclose it between lines consisting of only three backtick - ` characters. That means you’ll have one line of ```, then your code, then another line of ```. This preserves the formatting of the code making it a lot easier to read - especially with statements where indentation is critical.


# The line above this is ```
def function(self):
    return self
# The line after this is ```



def login_view(request):
    if request.method == 'POST':
        form = AuthenticationForm(request=request, data=request.POST)
        if form.is_valid():
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = authenticate(username=username, password=password)
            if user is not None:
                login(request, user)
                messages.info(request, f"You are now logged in as {username}")
                return HttpResponseRedirect(reverse('Users:index'))
                messages.error(request, "Invalid username or password.")
            messages.error(request, "Invalid username or password.")
    form = AuthenticationForm()
    return render(request = request,
                    template_name = "Users/login.html",

And the login html is

{% extends "Users/home.html" %}

{% block content %}
  {% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
  <form method="post" action="{% url 'Users:login' %}">
    {% csrf_token %}
    {{ form.as_p }}
  <button name="submit">log in</button>
<input type="hidden" name="next" value="{% url 'Users:index' %}" />
{% endblock content %}

I’m able to login as a admin but cannot able to register as alumini when i click register after filling the form it is not saving and not logging me in.Here is the alumini_register view

def alumini_register(request):
    if request.method !='POSt':

        if form.is_valid():
            # log the user in and then redirect to home page.
            return HttpResponseRedirect(reverse('Users:index'))
    return render(request,'Users/alumini_register.html',context)

And sometimes it showing csrf token not defined properly when i tried to register
Here is the code for alumini_register.html

{% extends "Users/home.html" %}

{% block content %}
<form method="post" action="{% url 'Users:alumini_register' %}">
  {% csrf_token %}
  {{ form.as_p }}
  <button name="submit">register</button>
{% endblock content %}

And here is the code for urls.py for the app

from django.urls import  path,re_path
from django.conf.urls import url
from .views import classroom
from django.contrib.auth import login


    path('topics/',classroom.topics, name='topics'),
    url(r'^new_topic/$', classroom.new_topic, name='new_topic'),
    url(r'^edit_entry/(?P<entry_id>\d+)/$', classroom.edit_entry,name='edit_entry'),


sorry I’m new here and I’ll not repeat it again.
Please look at my issue

The ‘t’ in your conditional above should be a capital T. (It should be POST, not POSt.)

If that’s not the issue, then I think we also need to see the AlumniSignUpForm.


Thank you ,Sir for your instant response .
That was the error .
This community is really amazing