-1

I have been trying to dump and load data from sqlite to PostgreSQL referring to this page.
However, I got following error when I tried to load data which is dumped by following code.

python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission > database.json

I tried to dump data removing natural argument as below. But got same error.

python manage.py dumpdata -e contenttypes -e auth.Permission > database.json

Could anyone tell me what should I do to solve this problem?

(webEP) C:\Users\obakatsu\Documents\Python_scripts\Django\DjangoEP>python manage.py loaddata database.json
Traceback (most recent call last):
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: リレーション"auth_user"は存在しません
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
                                                             ^


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

Traceback (most recent call last):
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\json.py", line 81, in Deserializer
    for obj in PythonDeserializer(objects, **options):
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\python.py", line 183, in Deserializer
    obj = base.build_instance(Model, data, db)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\base.py", line 227, in build_instance
    obj.pk = Model._default_manager.db_manager(db).get_by_natural_key(*natural_key).pk
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\contrib\auth\base_user.py", line 48, in get_by_natural_key
    return self.get(**{self.model.USERNAME_FIELD: username})
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 373, in get
    num = len(clone)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 232, in __len__
    self._fetch_all()
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 1102, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\sql\compiler.py", line 876, in execute_sql
    cursor.execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 80, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: リレーション"auth_user"は存在しません
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
                                                             ^


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\commands\loaddata.py", line 69, in handle
    self.loaddata(fixture_labels)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\commands\loaddata.py", line 109, in loaddata
    self.load_label(fixture_label)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\management\commands\loaddata.py", line 166, in load_label
    for obj in objects:
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\json.py", line 87, in Deserializer
    six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\json.py", line 81, in Deserializer
    for obj in PythonDeserializer(objects, **options):
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\python.py", line 183, in Deserializer
    obj = base.build_instance(Model, data, db)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\base.py", line 227, in build_instance
    obj.pk = Model._default_manager.db_manager(db).get_by_natural_key(*natural_key).pk
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\contrib\auth\base_user.py", line 48, in get_by_natural_key
    return self.get(**{self.model.USERNAME_FIELD: username})
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 373, in get
    num = len(clone)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 232, in __len__
    self._fetch_all()
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 1102, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\sql\compiler.py", line 876, in execute_sql
    cursor.execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 80, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.core.serializers.base.DeserializationError: Problem installing fixture 'C:\Users\obakatsu\Documents\Python_scripts\Django\DjangoEP\database.json': リレーション"auth_user"は存在しません
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2
  • 1
    Can you please disable locale language settings or translate the error message to english? Thanks Commented Oct 7, 2018 at 11:17
  • 1
    Google Translate: Relation "auth _ user" does not exist. Commented Oct 7, 2018 at 12:08

3 Answers 3

0

From Google Translate the error message is:

Relation "auth _ user" does not exist

So it seems that you are querying an entity (table, view, function, ...) that just not exist at this moment. Maybe you have to create a table auth_user before you execute your code or maybe the whole database schema?

Sign up to request clarification or add additional context in comments.

Comments

0

this same happen to me , first take a backup for your database in .json file and the change the settings.py to your desired datatbase and then run commands

python manage.py migrate 

this gradually works for me ! so try once .

Comments

0

python manage.py migrate would help if you didn't do it after changing database.

1 Comment

Note: answers that are very brief and/or are questions back to the poster should probably be comments. You only need 50 rep points to comment under a question - could you move this there?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.