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

[Feature] Get this works with ForeignKey #3

Open
AndrejGorodnij opened this issue May 21, 2023 · 1 comment
Open

[Feature] Get this works with ForeignKey #3

AndrejGorodnij opened this issue May 21, 2023 · 1 comment

Comments

@AndrejGorodnij
Copy link

This feature will make life much simpler in e-commerce projects, where we need to create some constructions like:

class Image(models.Model):
    image = models.ImageField()

class Product(models.Model):
    name = models.CharField()

class ProductImage(models.Model):
    image = models.ForeignKey(Image)
    product = models.ForeignKey(Product)

Module can't access to Image fields using ForeignKey atributes.

AttributeError 'ForeignKey' object has no attribute 'get_internal_name'

Maybe I missed something in documentation?

@BigglesZX
Copy link
Owner

It would be useful to support this for sure. It’s not currently possible, though you can work around the limitation by adding a property on one model that returns the image field on the related model. I just added that feature recently.

I’ll have a think about how best to support ForeignKey relations. Maybe we could use the double-underscore syntax Django uses for various related lookups.

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