Skip to content

Conversation

@glowka
Copy link

@glowka glowka commented Apr 11, 2020

Hey,

current util get_related_model implementation does not take into account that reverse relations (descriptor can be both forward and reverse) so for reverse relations it leads to bugs like this:

class Member(models.Model):
    pass

class Project(models.Model):
   members = models.ManyToMany(Member, related_name='projects')

get_related_model(Member, 'projects')
# returns models.Member instead of models.Project

New implementation robustly checks type of relation and returns appropriate model.

It supports all kind of descriptors: OneToOne, ManyToOne, ManyToMany.

@glowka glowka force-pushed the fix-get-related-model branch 3 times, most recently from 0eacfc9 to 6814a67 Compare April 13, 2020 22:53
@glowka glowka force-pushed the fix-get-related-model branch from 6814a67 to da5f800 Compare April 13, 2020 22:57
@JoelLefkowitz JoelLefkowitz changed the base branch from master to 1.21.x July 17, 2022 17:18
@JoelLefkowitz JoelLefkowitz added 1.21.x Release target in 1.21.x bug Bug report labels Jul 17, 2022
@JoelLefkowitz JoelLefkowitz deleted the branch axnsan12:master October 17, 2024 11:55
@JoelLefkowitz JoelLefkowitz reopened this Oct 17, 2024
@JoelLefkowitz JoelLefkowitz changed the base branch from 1.21.x to master October 17, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.21.x Release target in 1.21.x bug Bug report

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants