dominno / django-moderation

django-moderation is reusable application for Django framework, that allows to moderate any model objects.
BSD 3-Clause "New" or "Revised" License
268 stars 91 forks source link

django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed #185

Closed djjudas21 closed 4 years ago

djjudas21 commented 4 years ago

Hi there. I'm running into a problem when adding django-moderation to an existing Django project. Simply adding moderation to INSTALLED_APPS makes it fail. It also fails if I add moderation.apps.ModerationConfig but does not fail if I add moderation.apps.SimpleModerationConfig.

My project is open source so you can view settings.py and requirements.txt in the repo. Runtime output below.

[jonathan@latitude camerahub]$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[0](_exception[1]).with_traceback(_exception[2])
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/jonathan/.local/lib/python3.7/site-packages/moderation/apps.py", line 13, in ready
    auto_discover()
  File "/home/jonathan/.local/lib/python3.7/site-packages/moderation/helpers.py", line 48, in auto_discover
    import_moderator(app)
  File "/home/jonathan/.local/lib/python3.7/site-packages/moderation/helpers.py", line 27, in import_moderator
    app_path = import_module(app).__path__
  File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'schema.apps.SchemaConfig'; 'schema.apps' is not a package

Traceback (most recent call last):
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/apps/registry.py", line 155, in get_app_config
    return self.app_configs[app_label]
KeyError: 'auth'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/contrib/auth/__init__.py", line 165, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/apps/registry.py", line 205, in get_model
    app_config = self.get_app_config(app_label)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/apps/registry.py", line 162, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'auth'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 60, in execute
    super().execute(*args, **options)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 95, in handle
    self.run(**options)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 102, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 564, in start_django
    reloader.run(django_main_thread)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/autoreload.py", line 272, in run
    get_resolver().urlconf_module
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/urls/resolvers.py", line 564, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/camerahub/urls.py", line 20, in <module>
    path('', include('schema.urls')),
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/schema/urls.py", line 3, in <module>
    from schema import views
  File "/home/jonathan/git/camerahub/schema/views.py", line 6, in <module>
    from django.contrib.auth.mixins import LoginRequiredMixin
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/contrib/auth/mixins.py", line 3, in <module>
    from django.contrib.auth.views import redirect_to_login
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/contrib/auth/views.py", line 28, in <module>
    UserModel = get_user_model()
  File "/home/jonathan/.local/lib/python3.7/site-packages/django/contrib/auth/__init__.py", line 170, in get_user_model
    "AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
djjudas21 commented 4 years ago

Any hints on this? Thanks

DmytroLitvinov commented 4 years ago

@djjudas21, are you sure that you have 'django.contrib.auth' in INSTALLED_APPS variable in your settings file?

djjudas21 commented 4 years ago

Thanks for the response @DmytroLitvinov. Yes I have django.contrib.auth in my INSTALLED_APPS as per https://github.com/djjudas21/camerahub/blob/306fcdb90a38c50841bd321eb8d1410cc39b9db5/camerahub/settings.py#L38

DmytroLitvinov commented 4 years ago

@djjudas21 , could you also add next line default_app_config = 'schema.apps.SchemaConfig' to your __init__.py file inside schema folder and check if it fails?

djjudas21 commented 4 years ago

Sure. I've added that line and this is the new error:

(venv) [jonathan@poseidon camerahub]$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/apps.py", line 13, in ready
    auto_discover()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/helpers.py", line 48, in auto_discover
    import_moderator(app)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/helpers.py", line 27, in import_moderator
    app_path = import_module(app).__path__
  File "/home/jonathan/git/camerahub/venv/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'schema.apps.SchemaConfig'; 'schema.apps' is not a package
DmytroLitvinov commented 4 years ago

@djjudas21 also in settings file inside INSTALLED_APPS it should be just schema

djjudas21 commented 4 years ago

Oh, thanks. I made this change

(venv) [jonathan@poseidon camerahub]$ git diff
diff --git a/camerahub/settings.py b/camerahub/settings.py
index be5973e..b26eab5 100644
--- a/camerahub/settings.py
+++ b/camerahub/settings.py
@@ -41,7 +41,7 @@ INSTALLED_APPS = [
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.sites',
-    'schema.apps.SchemaConfig',
+    'schema',
     'djmoney',
     'favicon',
     'django_tables2',

This now results in an error that looks like it's caused by migrations, so I'll reset my database and try again

(venv) [jonathan@poseidon camerahub]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: moderation_moderatedobject

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 584, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/jonathan/git/camerahub/venv/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/camerahub/urls.py", line 20, in <module>
    path('', include('schema.urls')),
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/home/jonathan/git/camerahub/venv/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/schema/urls.py", line 3, in <module>
    from schema import views
  File "/home/jonathan/git/camerahub/schema/views.py", line 21, in <module>
    from schema.forms import AccessoryForm, ArchiveForm, BatteryForm, BulkFilmForm, CameraForm, CameraModelForm, DeveloperForm, EnlargerForm, FilmStockForm, FilterForm
  File "/home/jonathan/git/camerahub/schema/forms.py", line 10, in <module>
    class AccessoryForm(ModelForm):
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/forms/models.py", line 256, in __new__
    apply_limit_choices_to=False,
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/forms/models.py", line 172, in fields_for_model
    formfield = f.formfield(**kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/fields/related.py", line 954, in formfield
    'queryset': self.remote_field.model._default_manager.using(using),
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/managers.py", line 59, in get_queryset
    return self.filter_moderated_objects(query_set)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/managers.py", line 37, in filter_moderated_objects
    if annotated_queryset.exists():
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 766, in exists
    return self.query.has_results(using=self.db)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/query.py", line 522, in has_results
    return compiler.has_results()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1103, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1133, in execute_sql
    cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: moderation_moderatedobject
djjudas21 commented 4 years ago

There were no migrations to apply so I deleted the sqlite database file to start fresh. Unfortunately it now bombs out with this error, which I have never seen before:

(venv) [jonathan@poseidon camerahub]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: django_content_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 584, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/jonathan/git/camerahub/venv/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/camerahub/urls.py", line 20, in <module>
    path('', include('schema.urls')),
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/home/jonathan/git/camerahub/venv/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/jonathan/git/camerahub/schema/urls.py", line 3, in <module>
    from schema import views
  File "/home/jonathan/git/camerahub/schema/views.py", line 21, in <module>
    from schema.forms import AccessoryForm, ArchiveForm, BatteryForm, BulkFilmForm, CameraForm, CameraModelForm, DeveloperForm, EnlargerForm, FilmStockForm, FilterForm
  File "/home/jonathan/git/camerahub/schema/forms.py", line 10, in <module>
    class AccessoryForm(ModelForm):
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/forms/models.py", line 256, in __new__
    apply_limit_choices_to=False,
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/forms/models.py", line 172, in fields_for_model
    formfield = f.formfield(**kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/fields/related.py", line 954, in formfield
    'queryset': self.remote_field.model._default_manager.using(using),
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/managers.py", line 59, in get_queryset
    return self.filter_moderated_objects(query_set)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/moderation/managers.py", line 37, in filter_moderated_objects
    if annotated_queryset.exists():
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 766, in exists
    return self.query.has_results(using=self.db)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/query.py", line 522, in has_results
    return compiler.has_results()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1103, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1120, in execute_sql
    sql, params = self.as_sql()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 488, in as_sql
    from_, f_params = self.get_from_clause()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 760, in get_from_clause
    clause_sql, clause_params = self.compile(from_clause)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 405, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/datastructures.py", line 84, in as_sql
    compiler.query.where_class, self.table_alias, self.parent_alias)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/fields/reverse_related.py", line 140, in get_extra_restriction
    return self.field.get_extra_restriction(where_class, related_alias, alias)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/contrib/contenttypes/fields.py", line 466, in get_extra_restriction
    contenttype_pk = self.get_content_type().pk
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/contrib/contenttypes/fields.py", line 462, in get_content_type
    for_concrete_model=self.for_concrete_model)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/contrib/contenttypes/models.py", line 51, in get_for_model
    ct = self.get(app_label=opts.app_label, model=opts.model_name)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 402, in get
    num = len(clone)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 256, in __len__
    self._fetch_all()
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1133, in execute_sql
    cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/jonathan/git/camerahub/venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: django_content_type
djjudas21 commented 4 years ago

Don't worry, this was due to a different mistake in setting up django-moderation both via normal and alternative methods. I've now got it set up via normal method only. I think it's OK now - I will close the issue when I've confirmed this. Thanks

DmytroLitvinov commented 4 years ago

@djjudas21 it is related to issue https://github.com/dominno/django-moderation/issues/183. Please, see workaround from the issue above. Hope it helps :pray:

djjudas21 commented 4 years ago

Thanks, I will read it. Thanks for your help :beer: