2👍
✅
You can’t check if Foo
belongs to a category yet until you save it. But since it isn’t saved anyway, you can be sure that it doesn’t belong to a category yet.
One way to check wheter it has been saved already is by using if foo.pk
. The pk
is the primary key and it will be None
if it hasn’t been saved yet.
Source:stackexchange.com