simonw / django-sql-dashboard

Django app for building dashboards using raw SQL queries
https://django-sql-dashboard.datasette.io/
Apache License 2.0
437 stars 37 forks source link

Error on initial install: 'relation "django_sql_dashboard_dashboard" does not exist' #151

Open loganwilliams opened 2 years ago

loganwilliams commented 2 years ago

I'm trying to explore the functionality of the project for exploring a Postgres database, however I'm encountering the following exception immediately after installation. Maybe I am missing a configuration step? Any help is appreciated.

Internal Server Error: /dashboard/
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "django_sql_dashboard_dashboard" does not exist
LINE 1: ...id", "auth_group"."name", T6."id", T6."name" FROM "django_sq...
                                                             ^

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django_sql_dashboard/views.py", line 121, in dashboard_index
    return _dashboard_index(
  File "/usr/local/lib/python3.8/dist-packages/django_sql_dashboard/views.py", line 325, in _dashboard_index
    saved_dashboards = [
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 320, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 1507, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 57, in __iter__
    results = compiler.execute_sql(
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py", line 1361, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 103, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "django_sql_dashboard_dashboard" does not exist
LINE 1: ...id", "auth_group"."name", T6."id", T6."name" FROM "django_sq...
                                                             ^
simonw commented 2 years ago

Have you run the migrations?

./manage.py migrate

This was only recently added to the README: b3ac3708ab396b27a63ce1547d29e4bd4604b1b8 in #147