django.db.utils.ProgrammingError, попробуйте makemigrations manage.py в приложении, которое клонировано из github - PullRequest
0 голосов
/ 30 августа 2018

У меня проблема с переносом базы данных из клонированного проекта django в postresql db.

ОС Ubuntu Server 18.04

установлен python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx.

настройка postgresql db, обновление pip3, установка virtualenv, создание /opt/projectdir.

Внутри projectdir создайте virtualenv moviesenv и активируйте его, установить django, gunicorn и psycopg2 с помощью pip создайте каталог фильмов, затем внутри каталога фильмов наберите: мерзавец клон https://username/reponame. настройка разрешенных разделов hosts и DB. набрал manage.py makemigrations и получить сообщение об ошибке psycopg2.ProgrammingError: отношение "movie_movie" не существует django.db.utils.ProgrammingError: отношение "movie_movie" не существует

это только небольшая часть вывода ошибок, но я не хочу вставлять все сюда. Если кто-нибудь может помочь, пожалуйста.

Хорошо, здесь полный возврат

Traceback (most recent call last):
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "movie_movie" does not exist
LINE 1: ...movie_movie"."plot", "movie_movie"."trailer" FROM "movie_mov...
                                                             ^


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

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute
    self.check()
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/management/base.py", line 366, in _run_checks
    return checks.run_checks(**kwargs)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 396, in check
    for pattern in self.url_patterns:
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/opt/myproject/myprojectenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/myproject/MovieHunter/MovieHunter/urls.py", line 19, in <module>
    from . import views
  File "/opt/myproject/MovieHunter/MovieHunter/views.py", line 6, in <module>
    from movie.initializer import search_index
  File "/opt/myproject/MovieHunter/movie/initializer.py", line 5, in <module>
    search_index = Index()
  File "/opt/myproject/MovieHunter/movie/search_index.py", line 12, in __init__
    self.__load_data_from_db()
  File "/opt/myproject/MovieHunter/movie/search_index.py", line 16, in __load_data_from_db
    for movie in Movie.objects.all():
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/models/query.py", line 268, in __iter__
    self._fetch_all()
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/models/query.py", line 1183, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/models/query.py", line 54, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
    cursor.execute(sql, params)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/myproject/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "movie_movie" does not exist
LINE 1: ...movie_movie"."plot", "movie_movie"."trailer" FROM "movie_mov...

1 Ответ

0 голосов
/ 30 августа 2018

Как упомянул @Alasdair, похоже, что проблема запроса заключается в том, что вы хотите сделать запрос из несуществующей таблицы. Вот ссылка , связанная , с которой Вы можете попытаться решить свою проблему. Это происходит в: File "/opt/myproject/MovieHunter/movie/search_index.py", line 16, in __load_data_from_db for movie in Movie.objects.all():

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...