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

[Question] Explanation of books plural from book? #295

Open
scheung38 opened this issue Aug 13, 2022 · 0 comments
Open

[Question] Explanation of books plural from book? #295

scheung38 opened this issue Aug 13, 2022 · 0 comments
Labels

Comments

@scheung38
Copy link

scheung38 commented Aug 13, 2022

Questions

Can someone please explain where we get the plural for book, books? From the docs:

https://django-elasticsearch-dsl-drf.readthedocs.io/en/latest/quick_start.html#full-database-sync:

search_indexes/signals.py

@receiver(post_save)
def update_document(sender, **kwargs):
    """Update document on added/changed records.

    Update Book document index if related `books.Publisher` (`publisher`),
    `books.Author` (`authors`), `books.Tag` (`tags`) fields have been updated
    in the database.
    """
    app_label = sender._meta.app_label
    model_name = sender._meta.model_name
    instance = kwargs['instance']

    if app_label == 'book':
        # If it is `books.Publisher` that is being updated.
        if model_name == 'publisher':
            instances = instance.books.all()
            for _instance in instances:
                registry.update(_instance)

i.e for my use case if I have instead of book, address then

instances = instance.addresses.all()

But where is the plural addresses defined? If defined here: books.Author first parameter:

authors = models.ManyToManyField('books.Author', related_name='books')

then if based on first or second parameter ? Since using Djongo.models there is no related_name key

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

No branches or pull requests

1 participant