-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
I've created a brand new project & come to the initial migration to start my database.
django-multisite is included with what I'd call the "basic" setup, with the following settings;
INSTALLED_APPS = [
# Django
'django.forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.gis',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.redirects',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'multisite',
'project',
]
MIDDLEWARE = [
'multisite.middleware.DynamicSiteMiddleware',
# everything else follows...
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'project', 'templates'),
],
'OPTIONS': {
'context_processors': [
...
],
'loaders': [
'multisite.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
],
},
},
]Running migrate with an empty database, the project appears to raise the following with it's attempt to access the Site table seemingly from the following flow;
https://github.com/ecometrica/django-multisite/blob/master/multisite/template/loaders/filesystem.py#L15
https://github.com/ecometrica/django-multisite/blob/master/multisite/hacks.py#L47
(.venv) mwalker@mymac my-project % python manage.py migrate
Traceback (most recent call last):
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 31, in <module>
main()
File "manage.py", line 27, in main
execute_from_command_line(sys.argv)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/cms/apps.py", line 12, in ready
setup()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/cms/utils/setup.py", line 40, in setup
plugin_pool.validate_templates()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/cms/plugin_pool.py", line 83, in validate_templates
loader.get_template(template)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/template/loader.py", line 15, in get_template
return engine.get_template(template_name)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/template/backends/django.py", line 34, in get_template
return Template(self.engine.get_template(template_name), self)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/template/engine.py", line 143, in get_template
template, origin = self.find_template(template_name)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/template/engine.py", line 125, in find_template
template = loader.get_template(name, skip=skip)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/template/loaders/base.py", line 18, in get_template
for origin in self.get_template_sources(template_name):
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/multisite/template/loaders/filesystem.py", line 15, in get_template_sources
domain = Site.objects.get_current().domain
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/contrib/sites/models.py", line 58, in get_current
return self._get_site_by_id(site_id)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/multisite/hacks.py", line 47, in SiteManager_get_site_by_id
site = self.get(pk=site_id)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 402, in get
num = len(clone)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 256, in __len__
self._fetch_all()
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/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 "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1140, in execute_sql
cursor.execute(sql, params)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 99, in execute
return super().execute(sql, params)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/mwalker/Sites/my-project/.venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
^
I'm fairly new to this project, but it would appear that there might be potential for exception handling in SiteManager_get_site_by_id to deal with ProgrammingError on the assumption that it's an initial migration perhaps?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels