[Django]-Django model object initialization

8👍

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.

Leave a comment