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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 theObjectinstance, it returnsNone. So you would normally:Then check
obj.id.