Reputation: 251
If I do
obj = Object()
obj.att1 = 'test'
obj.att2 = 'test'
obj.save()
obj.id --> works fine
But if I do
obj=Object(att1='test',att2='test').save()
Doing obj.id --> obj seems to be Nonetype at this stage
Is this the case?
Upvotes: 3
Views: 5816
Reputation: 3638
I don't know the exact framework you are using, but I am going to take a guess as to the problem:
Object(att1='test',att2='test').save()
The save()
function doesn't appear to return the Object
instance, it returns None
. So you would normally:
obj=Object(att1='test',att2='test')
obj.save()
Then check obj.id
.
Upvotes: 8