Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with using Proxy models #103

Open
andrew-gibson opened this issue Jun 22, 2024 · 3 comments
Open

Issue with using Proxy models #103

andrew-gibson opened this issue Jun 22, 2024 · 3 comments

Comments

@andrew-gibson
Copy link

andrew-gibson commented Jun 22, 2024

take the case of :

class CoreModel(models.Model):
   name = models.TextField()

class ProxyModel(CoreModel):
   class Meta:
        proxy = True

in qs.py, when resolving a where a model has a relationship with ProxyModel, the code currently traverses::
related_descriptor.rel.field.model
however, if the related model is ProxyModel , then this resolution path ends up with CoreModel

If you instead follow: related_descriptor.rel.model._meta.proxy, you can check if it's a proxy model and then related_queryset = related_descriptor.rel.model.objects.all() will get you the right qs

@j4mie
Copy link
Member

j4mie commented Jun 26, 2024

Hi @andrew-gibson, thank you for reporting this! I'll see if I can reproduce this with a test case when I get some time.

@andrew-gibson
Copy link
Author

@j4mie thanks for the reply, i'm sure there was a move professional way of submitting this. Would you like me to submit a file which highlights where it falls down?

@j4mie
Copy link
Member

j4mie commented Jun 26, 2024

No, that's absolutely fine - the example you gave should be plenty. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants