ayush garg
ayush garg

Reputation: 11

CommandError: No model or app named in elastic search

Here I am creating indices for a django model using django_elasticsearch_dsl but getting error while creating the one. My django app name where the code lies is example_app

django_elasticsearch_dsl = 0.5.1
elasticsearch = 6.6.1

I have tried rebuilding indexes with some already existing indices that working prefectly fine and tried replacing the fields with the new model field and that also working fine. But when creating separate file throwing error.

from django_elasticsearch_dsl import DocType, Index, fields

from example_app.models import RandomTable

posts = Index('random_table')

@posts.doc_type
class ExampleDocument(DocType):
    class Meta:
        model = RandomTable
        fields = [
            'des',
            'quality',
            'con',
            'name',
            'prep',
            'sur_name',
            'issue_num'
          ]

when running the command python manage.py search_index --rebuild --models=example_app Actual output is CommandError: No model or app named example_app Expected output is creating index

Upvotes: 0

Views: 306

Answers (2)

Makhtar Diouf
Makhtar Diouf

Reputation: 11

Had the same issue and found out that the file where ExampleDocument is declared should be named documents.py.

In your case example_app/documents.py

Upvotes: 1

A.Rauan
A.Rauan

Reputation: 42

Did you add 'example_app.apps.ExampleAppConfig' in settings?

Upvotes: 0

Related Questions