Models in Django: Saving Form Data To The Database | Django Tutorial #10
ฝัง
- เผยแพร่เมื่อ 9 ก.พ. 2025
- In this Django course, We will see how to create awesome django websites from starting to the end. Also we will see how to build few of amazing projects in Django.
This course is a part of this complete Django Playlist: • Django Tutorials For B...
Here is the playlist: th-cam.com/play/PLK8cqdr55Tsv-D2HMdrnD32oOVBNvmxjr.html
If possible please share it with your friends :)
what is models.model argument? How it works ?
My problem is almost solved. thank you so much!! How do I solve the "unexpected keyword arguement" problem
I M getting typeerror
Why didn't youtube recommend me your channel is beyond my comprehension . Dude , you are damn good . I could have saved days on learning the concepts.
Your Django tutorials are by far the best tutorials on this platform.
LLLLLLLLpLLllllLL
I realised i was not patient enough. Your tutorial is actually the best on this youtube platform
It is very helpful. You are best coder in you tube.
It helped me a lot in my career thanks man keep working
You are make me happy 🔥...I did it my 1st django website..❤️
This is the video I was looking for. Thanku, my conecpt is clear now
I only get contact() got an unexpected keyword argument 'name' when i clicked on submit, what could be the problem?
This is my code:
def contact(request):
if request.method=="POST":
name = request.POST["name"]
email = request.POST["email"]
phone = request.POST["phone"]
desc = request.POST["desc"]
#print(name, email,phone,desc)
ins = contact(name=name,email=email,phone=phone,desc=desc)
ins.save()
print("The data has been saved.")
return render(request, "contact.html")
did you solve this error? then please tell how to solve this?
Thanks Harry, this was very helpful.
Excellent!!!
Excellent Tutorial, worked perfectly for me, Thank You.
please any help? at the end it says "unexpected keyword argument"
@@hommastonlimited3187 check your names of html ,model and function it should be same while passing into the function
Thanks! this solved my problem pretty neatly!
Hello having issues with the contact section the submit is no going through
Well Explained. God bless you sir.
Love From Gujarat Dhiren Nathvani
😍😍😍😍
I wrote the exact code but iam getting an error saying"MultiValueDictKeyError at /contact
'name'" plz help me to get rid of this error
did you solve this error? then please tell how to solve this?
Thats very good video harry bhai
unbelievable !!
Awesome work bhai
Bro, Need a quick help.... I have been learing Django from ur videos and stuck somewhere. I am working on a page which has 2 fields - years and months as fields and trying to store in SQLite. In the data base both are defined as models.PositiveIntegerField(default=0, blank=True)
Now from the html page I am trying to enter the data and keeping one of the fields as blank. I keep getting the below mentioned error
Field 'years' expected a number but got ''.
Can you help and tell me how to fix this issue?
Great.. Thanks for the video
21:24 getting an error
DataError : integer out of range
I searched on Google it says replace int to bigint but im not using thatt . Can anyone help. Thanks in advance
Everything is working. Thanks.
Hi! I NEED HELP! PLEASE! How can i do post method when I have only one html file where the pages are created using id? Please explain
I was very nice to know how to going data to the database
Very clear
Thank you so much! Extremely helpful. ^_^
Cool
I got problem in 24:10 that IntegrityError NOT NULL constraint failed: app_user.cat_id
I too get same ..any solution?
Hello Harry bhai ,
I was stuck at 7:12 of this video .
Please help me .
Having issue in Contact section Submit not going through . Please help me
Just add {% csrf_token %}
After the tag
@@javedbakshi9793 did you solve this error? then please tell how to solve this?
In the beginning, my app folder name was home2, then after few tutorial and work i rename it as home. Now when I add home at installed app and save it ,it show that " django.core.exceptions.ImproperlyConfigured: Cannot import 'home2'. Check that 'home.apps.Home2Config.name' is correct." how can I solve this probelm. Someone please help me. I am stuck here
In this case we've use raw html form. Can't we use django forms or Model form for this? With the same bootstrap styles? Bcz, those are very powerful forms. But I don't know how to make those form with interactive designs. Hope u will answer for this. Thanks.
7.20 everything is fine but my form is not responded. I am clicking on submit button but no response, no error found . I am sad. Anyone suggest me what's the issue?
use "POST" like this in views.py not this "post"
Same issue 😭😭 please help me i have used 'POST' LIKE only
@@Alqama_Rashid i had the same problem, and i do it like u mentioned and It's work, thank you :D
Hello , i want to ask if your mithod contact has another argument, means like this :
Contact(request,mynumber)
How you will write form action ?
in this course this #10 part is the most important.
Thank you sir ji..!!
I'm getting Multilevel dictkey error.
Plese solve this error
Can we create table directly in sql instead of creating in django?
thanks
ur too good
Love you Harry.
thank you for this
i spent like 2h to solve the issue, it seems that the action field was wrong, silly me
how is this possible. I did everything you did but I still get UNEXPECTED KEYWORD ARGUEMENT ERROR
Sir python practice program main chatbot bananekha video bana dijiye pls
please abeg which one is 'endpoint'
sir i m still getting the same issue please dont run from it help us by making the problem go away
thank u
i am getting this error while executing the same code
'local variable 'name' referenced before assignment' Can anyone help me?
ModuleNotFoundError: No module named 'models what can i do for resolve this
In settings.py
Put comma after adding
[
'home',
]
why you do not upload this video in the main channel?
so helpful. thanks!
How can we save dropdown in database
Hello Harry Sir ! kindly read comments here ..everyone have one common issue which is when we submit data to db.we are getting an error (Typeerror at contact: contact got an unexpected arguments name.....so plz give us a solution....
hey to fix this issue, you can try renaming either the function or the model to have a different name. Make sure that the function and model names are not the same to avoid naming conflicts.
from django.shortcuts import render, HttpResponse
from home.models import Contact
def home(request):
return render(request, 'home.html')
def about(request):
return render(request, 'about.html')
def projects(request):
return render(request, 'projects.html')
def contact_form(request):
if request.method == "POST":
name = request.POST['name']
email = request.POST['email']
phone = request.POST['phone']
desc = request.POST.get('desc', '')
contact = Contact(name=name, email=email, phone=phone, desc=desc)
contact.save()
print('Data has been saved to the database')
return render(request, 'contact.html')
from django.db import models
class Contact(models.Model):
name = models.CharField(max_length=30)
email = models.EmailField()
phone = models.CharField(max_length=10)
desc = models.TextField()
try this 🇲🇦💪
How to comment out?
I have a data type as (input type="radio") in HTML file and I cant find appropriate model attribute for the same please help me out someone!
How to store data in django models if the method ="GET" ???
Are you an Indian or a Jewish guy doing an Appu.... Subscribed
20:45
Submit doesn't return any data 🥴 please help me resolve this
oops I finally got the error. I wrote contact name as phone in HTML but in view file I wrote request.POST['contact']. which should be. request.POST['phone']. :)
I'm got an error
10:34
anyone can please tell me how to submit pdf file and restore in database?
9:43
contact() got an unexpected keyword argument 'name'
same any solution?
have you found any solution??
@@AnkurSharma-xb8mj yes
did you get any solution?
@@shubhamjaiswal7925 share the solution with me, please
my data is not going in db
did u resolved..?
Contact() got an unexpected keyword argument 'email'
Are you solve this? Tell me that
did you solve this error? then please tell how to solve this?
7th
👌
Give us thé link of code in github thanks
where is source code?
please code
atleast put github link
Heart plzz
First
20:12