Closed djjudas21 closed 4 years ago
Any hints on this? Thanks
@djjudas21, are you sure that you have 'django.contrib.auth'
in INSTALLED_APPS
variable in your settings file?
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
@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?
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
@djjudas21 also in settings file inside INSTALLED_APPS it should be just schema
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
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
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
@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:
Thanks, I will read it. Thanks for your help :beer:
Hi there. I'm running into a problem when adding django-moderation to an existing Django project. Simply adding
moderation
toINSTALLED_APPS
makes it fail. It also fails if I addmoderation.apps.ModerationConfig
but does not fail if I addmoderation.apps.SimpleModerationConfig
.My project is open source so you can view settings.py and requirements.txt in the repo. Runtime output below.