Lead astray by the symptom

I was instantiating a Django subclass in a test, and it wasn’t setting one of the foreign key fields. We are subclassing an Order class, and was doing: OurOrder.objects.create(other=other)

When I retrieved the object from the database later, it wasn’t set. I was convinced it was some weirdness with multi-table inheritance. Turned out I had done other=Other(...) instead of other=Other.objects.create(...), so there was no database entry. Whoops…

This entry was posted in django. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s