Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate joins on overlapping ForeignKeys in Django?
I noticed something nasty. Let's say there is a model that is linked by two others that have the same ForeignKey.
class File(models.Model):<br/>
#some stuff<br/>
pass<br/>
<br/>
class ServerFile(models.Model):<br/>
<b>file = models.ForeignKey('File')</b><br/>
#some stuff<br/>
<br/>
class UserFile(models.Model):<br/>
<b>file = models.ForeignKey('File')</b><br/>
#some stuff<br/>
<br/>
class Link(models.Model): <br/>
user_file = models.ForeignKey('UserFile')<br/>
server_file = models.ForeignKey('ServerFile')<br/>
#some stuff
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question