Skip to content Skip to sidebar Skip to footer

How To Make Custom Login In Django

i am very new in python django.i had create a register page now i want to make login.i have written code for login but when i want to get the data which is posted by login from is

Solution 1:

Update 1:

First of all UserProfile you created is not the correct way... by default django has the User modal

So please remove the UserProfile class from your models.py but if you wish to add additional field then extend with ForeignKey like

classUserProfile(models.Model):
    user = models.ForeignKey(User)
    phone_number = models.IntegerField()

Answer

Your form method is post so get the post values in views like this

def login_success(request):
    if request.method == 'POST':
        # do your code here
        username = request.POST.get('username')
        password = request.POST.get('password')

write your html like this

<formid="login_form"method="post"action="">
        {% csrf_token %}
        Username: <inputtype="text"name="username"size="50" /><br />
        Password: <inputtype="password"name="password"size="50" /><br /><inputtype="submit"value="submit" /></form>

Post a Comment for "How To Make Custom Login In Django"