I am using Django to create a user and an object when the user is created But there is an error

0 votes

I am using Django to create a user and an object when the user is created. 

But there is an error

Logs

Models.py

class doct(models.Model):

    username = models.CharField(max_length=30)
    pin = models.CharField(max_length=30)
    mobile = models.CharField(max_length=30)
HTML.logs
<form action="update_data" method="POST">
    {% csrf_token %}
    <input type="text" name="username" placeholder="username"><br><br>
    <input type="text" name="pin" placeholder="Password"><br><br>
    <input type="text" name="mobile" placeholder="Mobile no"><br><br>

    <button type="submit">submit</button>

</form>
Views.py
=========
def update_data(request):

    if request.method=="POST":

        username=request.POST["username"]
        pin=request.POST["pin"]
        mobile=request.POST["mobile"]
        apppp =doct(username=username,pin=pin,mobile=mobile)
        apppp.save()


error:
apppp =doct(username=username,pin=pin,mobile=mobile)
TypeError: doct() got an unexpected keyword argument 'username'
[30/Jun/2021 12:56:34] "POST /update_data HTTP/1.1" 500 65059

Jun 30, 2021 in Python by Sudhir

edited 5 days ago 9 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP