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

related_models attribute raises object has no attribute 'get_instances_from_related' #45

Closed
jlariza opened this issue Nov 10, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@jlariza
Copy link
Contributor

jlariza commented Nov 10, 2023

Good day,

I'm trying to use the related_models field in my documents to update the index when the related models is updated. However, If I add a model to that field, It always raises object has no attribute 'get_instances_from_related'

I'm not sure what I'm missing. The documentation mentions nothing and the example shows no extra configuration so it is impossible to know what's happening.

Thank you,

@qcoumes qcoumes added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jan 11, 2024
@qcoumes
Copy link
Member

qcoumes commented Jan 11, 2024

You're right, the documentation about this method is missing.

You can use django-elasticsearch-document's explanation in the meantime, it works exactly the same way.

To summarise, get_instances_from_related should be a method of your Document class which expects an instance of one of the models declared in Django.related_models and returns the associated instance(s) of your Django.model.
Another way to explain it is that it is used to know what instance(s) of Django.model should be reindexed when an instance of one of the related models is updated.

@qcoumes
Copy link
Member

qcoumes commented Mar 22, 2024

Documentation added in #53

@qcoumes qcoumes closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants