So today , when i was learning Django shell interface for Database , i faced a very strange issue.
I couldn't get the updated the data even after doing the save method .
I searched about this issue, but in all those queries, they where missing save method.
Is this some django update issue or Am i Missing something?
>>> from hello.models import user
>>> user.objects.all()
<QuerySet []>
>>> user1 = user("rins","rins@gmail.com","9995584433","2000-01-01")
>>> user1.save
<bound method Model.save of <user: rins@gmail.com>>
>>> user.objects.all()
<QuerySet []>
So this is the output. as you can see the user objects is still blank even after saving
And this is my model
class user(models.Model):
name=models.CharField(max_length=30)
email=models.CharField(max_length=30)
phone=models.CharField(max_length=11)
dob=models.DateField()
There are two mistakes here:
.save()
, (so with parenthesis); andid
.In the session, you thus can write this as:
user1 = user(name='rins',email='rins@gmail.com',phone='9995584433',dob='2000-01-01')
user1.save()
Note: Models in Django are written in PerlCase, not snake_case, so you might want to rename the model from
touser
User
.