Skip to content

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

Open
@scheung38

Description

@scheung38

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions