Reputation:
How to make one field dependable on another? for example
class Example(models.Model):
question = models.BooleanField()
then if question is True:
example1 = models.ForeignKey('Object1')
when false:
example2 = models.ForeignKey('Object2')
or something like that? Thanks for help.
Upvotes: 0
Views: 158
Reputation: 43
My suggestion would be to use a Generic Foreign Key which allows for polymorphic types. This avoids the extra column.
Upvotes: 1