Following the Basic Usage example at http://django-rest-elasticsearch.readthedocs.io/en/latest/
from app.serializers import BlogSerializer
from app.models import Blog
from rest_framework_elasticsearch import (es_views, es_client, es_pagination, es_filters)
from .search_indexes import BlogIndex
class BlogView(es_views.ListElasticAPIView):
es_client = es_client
es_model = BlogIndex
es_pagination_class = es_pagination.ElasticLimitOffsetPagination
es_filter_backends = (
es_filters.ElasticFieldsFilter,
es_filters.ElasticFieldsRangeFilter,
es_filters.ElasticSearchFilter,
es_filters.ElasticOrderingFilter,
)
es_ordering = 'created_at'
es_filter_fields = (
es_filters.ESFieldFilter('tag', 'tags'),
)
es_range_filter_fields = (
es_filters.ESFieldFilter('created_at', 'created_at'),
)
es_search_fields = (
'tags',
'title',
)
Gives me the stacktrace:
`Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10de071e0>
Traceback (most recent call last):
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/andrew/projects/drfmonoengine/django-rest-framework-mongoengine-example/project/project/urls.py", line 5, in <module>
from app.views import UNDocumentViewSet, index_view, BlogViewSet
File "/Users/andrew/projects/drfmonoengine/django-rest-framework-mongoengine-example/project/app/views.py", line 7, in <module>
from rest_framework_elasticsearch import es_views, es_client, es_pagination, es_filters
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/rest_framework_elasticsearch/es_views.py", line 6, in <module>
from .es_mixins import ListElasticMixin
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/rest_framework_elasticsearch/es_mixins.py", line 9, in <module>
from .es_inspector import EsAutoSchema
File "/Users/andrew/projects/drfmonoengine/venv/lib/python3.6/site-packages/rest_framework_elasticsearch/es_inspector.py", line 1, in <module>
from rest_framework.schemas import AutoSchema
**ModuleNotFoundError: No module named 'rest_framework.schemas**'`
I am using MongoDB for persistence and this is almost certainly related.
Has anyone successfully used Django Rest Framework with Mongo and Elasticsearch that would point me toward a solution or packages that can handle Django-REST, Mongo and Elasticsearch? Or has anyone encountered this problem and have a workaround?
Thank you in advance!
In case you are still wondering, you can use haystack. It is library that integrates Django with Elasticsearch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.