Django unable to load test-fixtures, IntegrityError

Ich bin mit Saleor/Satchless macht-und e-commerce-Website (vererbt das Projekt). Ich konnte es nicht finden Saleor mailing-Liste hier veröffentlichen, statt.

Ich warf die DB zu erstellen Sie einige test-VORRICHTUNGEN.

./manage.py dumpdata -e contenttypes -e sessions -e south -e > payments_data.json

Wenn ich die tests ausführen und django versucht zu laden, die Leuchten es barfs dieses. Ich bin mit Postgres als DB, und obwohl nicht sehr vertraut, es scheint, wie es möglicherweise ein problem mit der Reihenfolge, in der Daten geladen wird

Irgendwelche Ideen, wie man um ihn herum?

======================================================================
ERROR: test__hometryon_extra_pair_sizes (payment.tests.InterstitialTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 259, in __call__
self._pre_setup()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 479, in _pre_setup
self._fixture_setup()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 849, in _fixture_setup
'skip_validation': True,
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/__init__.py", line 161, in call_command
return klass.execute(*args, **defaults)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
output = self.handle(*args, **options)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 224, in handle
connection.check_constraints(table_names=table_names)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 132, in check_constraints
self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 56, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 54, in execute
return self.cursor.execute(query, args)
IntegrityError: Problem installing fixtures: insert or update on table "product_ship" violates foreign key constraint "product_ship_product_ptr_id_fkey"
DETAIL:  Key (product_ptr_id)=(1) is not present in table "product_product".

Update: Begann das Spiel mit django-Leuchte-magic ich entdeckt, dass product.product ist eigentlich nicht weggeworfen, auch wenn ich eine
$ python manage.py dumpdata --indent=4 --all -e contenttypes -e sessions -e south > fulldb.json

Update 2: Nach dem einbinden von contenttypes in den dumpdata, Produkt.Produkt-fehlte noch in der tatsächlichen Daten. Musste ich manuell durchführen, eine dump_object und merge_fixture für das Produkt.Produkt-und order_deliverygroup. Beim beladen der Vorrichtung, beide Gaben ähnliche Fehler, die der folgenden:

IntegrityError: Problem installing fixtures: insert or update on table "order_shippeddeliverygroup" violates foreign key constraint "order_shippeddeliverygroup_deliverygroup_ptr_id_fkey" DETAIL:  Key (deliverygroup_ptr_id)=(1) is not present in table "order_deliverygroup".

Jetzt bin ich Links mit diesem problem herum Contenttypes

IntegrityError: Problem installing fixture '/Users/andres/Documents/projects/rpmwest/rpmwest/payment/fixtures/payments_data.json': Could not load contenttypes.ContentType(pk=5): duplicate key value violates unique constraint "django_content_type_app_label_model_key"DETAIL:  Key (app_label, model)=(product, digitalship) already exists.

Blick auf die Daten in der Vorrichtung sicher genug, es ist da, aber es ist nur einer von Ihnen. Ist es dann Aufeinandertreffens mit der DB erstellen contenttypes, wenn es ursprünglich synchronisiert die Modelle?

Wenn ich die contenttypes bekomme ich die folgende Fehlermeldung:

Traceback (most recent call last):
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 259, in __call__
self._pre_setup()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 479, in _pre_setup
self._fixture_setup()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/test/testcases.py", line 849, in _fixture_setup
'skip_validation': True,
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/__init__.py", line 161, in call_command
return klass.execute(*args, **defaults)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
output = self.handle(*args, **options)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 224, in handle
connection.check_constraints(table_names=table_names)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 132, in check_constraints
self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 56, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 54, in execute
return self.cursor.execute(query, args)
IntegrityError: Problem installing fixtures: insert or update on table "django_admin_log" violates foreign key constraint "django_admin_log_content_type_id_fkey" DETAIL:  Key (content_type_id)=(22) is not present in table "django_content_type".
  • Sind Sie mit der Völkerwanderung und so?
  • ja, ich bin mit Migrationen auf die Entwicklung der Datenbank, aber nicht in den tests. Ist es das, was du meintest?
  • Für zukünftige Referenz, im anderen Fall gelandet, weil hier der spezielle Fehler, werfen Sie einen Blick auf stackoverflow.com/a/29670681/940098
  • Öffnen Sie ein Problem auf der Saleor github-Seite und die Mirumee team wird in der Regel reagieren.
InformationsquelleAutor Andres | 2013-11-08
Schreibe einen Kommentar