MongoEngine / django-mongoengine

django mongoengine integration
Other
750 stars 206 forks source link

Appconfig models is empty OrderedDict #137

Closed cleverdb closed 4 years ago

cleverdb commented 4 years ago

django : 2.1.4 django_mongoengine-0.3-py3-none-any.whl mongoengine-0.16.3.tar.gz

AppConfig.get_model() will raise LookupError("App '%s' doesn't have a '%s' model." % (self.label, model_name))

debugger find Appconfig.models is empty OrderedDict

cleverdb commented 4 years ago

Traceback (most recent call last): File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, *callback_kwargs) File "D:\PycharmProjects\venv\lib\site-packages\haystack\views.py", line 49, in call self.results = self.get_results() File "D:\PycharmProjects\venv\lib\site-packages\haystack\views.py", line 89, in get_results return self.form.search() File "D:\PycharmProjects\venv\lib\site-packages\haystack\forms.py", line 112, in search return sqs.models(self.get_models()) File "D:\PycharmProjects\venv\lib\site-packages\haystack\forms.py", line 106, in get_models search_models.append(haystack_get_model(*model.split('.'))) File "D:\PycharmProjects\venv\lib\site-packages\haystack\utils\app_loading.py", line 34, in haystack_get_model return apps.get_model(app_label, model_name) File "D:\PycharmProjects\venv\lib\site-packages\django\apps\registry.py", line 207, in get_model return app_config.get_model(model_name, require_ready=require_ready) File "D:\PycharmProjects\venv\lib\site-packages\django\apps\config.py", line 168, in get_model "App '%s' doesn't have a '%s' model." % (self.label, model_name))``

last-partizan commented 4 years ago

There is not enough info, use support chat.

cleverdb commented 4 years ago

@last-partizan
Thank you for your reply. I hope to get your help again

runing environment: pyhton:3.6.7 django :2.1.4 django_mongoengine:0.3 mongoengine:0.16.3

description: I want to implement the search system with django-haystack(v:2.8.1)+elastaicsearch,but always prompt the following error message : Traceback (most recent call last): File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "D:\PycharmProjects\venv\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:\PycharmProjects\venv\lib\site-packages\haystack\views.py", line 49, in call self.results = self.get_results() File "D:\PycharmProjects\venv\lib\site-packages\haystack\views.py", line 89, in get_results return self.form.search() File "D:\PycharmProjects\venv\lib\site-packages\haystack\forms.py", line 112, in search return sqs.models(*self.get_models()) File "D:\PycharmProjects\venv\lib\site-packages\haystack\forms.py", line 106, in get_models search_models.append(haystack_get_model(*model.split('.'))) File "D:\PycharmProjects\venv\lib\site-packages\haystack\utils\app_loading.py", line 34, in haystack_get_model return apps.get_model(app_label, model_name) File "D:\PycharmProjects\venv\lib\site-packages\django\apps\registry.py", line 207, in get_model return app_config.get_model(model_name, require_ready=require_ready) File "D:\PycharmProjects\venv\lib\site-packages\django\apps\config.py", line 168, in get_model "App '%s' doesn't have a '%s' model." % (self.label, model_name))

****: Track the problems found ..\lib\site-packages\django\apps\config.py `class AppConfig: """Class representing a Django application and its configuration."""

def __init__(self, app_name, app_module):
    # Full Python path to the application e.g. 'django.contrib.admin'.
    self.name = app_name

    # Root module for the application e.g. <module 'django.contrib.admin'
    # from 'django/contrib/admin/__init__.py'>.
    self.module = app_module

    # Reference to the Apps registry that holds this AppConfig. Set by the
    # registry when it registers the AppConfig instance.
    self.apps = None

    # The following attributes could be defined at the class level in a
    # subclass, hence the test-and-set pattern.

    # Last component of the Python path to the application e.g. 'admin'.
    # This value must be unique across a Django project.
    if not hasattr(self, 'label'):
        self.label = app_name.rpartition(".")[2]

    # Human-readable name for the application e.g. "Admin".
    if not hasattr(self, 'verbose_name'):
        self.verbose_name = self.label.title()

    # Filesystem path to the application directory e.g.
    # '/path/to/django/contrib/admin'.
    if not hasattr(self, 'path'):
        self.path = self._path_from_module(app_module)

    # Module containing models e.g. <module 'django.contrib.admin.models'
    # from 'django/contrib/admin/models.py'>. Set by import_models().
    # None if the application doesn't have a models module.
    self.models_module = None

    # Mapping of lower case model names to model classes. Initially set to
    # None to prevent accidental access before import_models() runs.
    self.models = None`

reason the Appconfig.class models field is empty OrderedDict

last-partizan commented 4 years ago

https://gitter.im/MongoEngine/django-mongoengine

Welcome to chat.