This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Through relationship with a polymorphic model
Post Body

I'm trying to use a through relationship between a polymorphic and a non-polymorphic table with the the RankedAthlete model:

class ChoiceBlank(PolymorphicModel):
    pass

class ChoiceAthlete(ChoiceBlank):
    choice = models.ForeignKey('SomeModel', on_delete=models.CASCADE)

class BetMultiple(models.Model):
    answer = models.ManyToManyField('ChoiceBlank', blank=True, through='RankedAthlete')

class RankedAthlete(models.Model):
    choiceAthlete = models.ForeignKey('ChoiceBlank', on_delete=models.CASCADE)
    bet = models.ForeignKey('BetMultiple', on_delete=models.CASCADE)
    rank = models.IntegerField()

This doesn't work because RankedAthlete expects a ChoiceBlank and a ValueError is raised when I create one. Conversely, I can't migrate my db if I replace choice with a ChoiceAthlete.

Django-polymorphic doc doesn't mention my use case, is it unsupported? Is there a way to make this work?

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
5,458
Link Karma
1,171
Comment Karma
4,206
Profile updated: 21 hours ago
Posts updated: 6 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago