django-fixtures

IntegrityError when loading fixture during django testing

妖精的绣舞 提交于 2019-11-28 19:16:30
I'm loading a fixture created with dumpdata, and getting the following exception: Problem installing fixture 'db_dump.json': Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 174, in handle obj.save(using=using) File "/usr/lib/python2.6/site-packages/django/core/serializers/base.py", line 165, in save models.Model.save_base(self.object, using=using, raw=True) File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 526, in save_base rows = manager.using(using).filter(pk=pk_val)._update(values) File "/usr

Django Sites Framework: Initial Data Migration Location

南笙酒味 提交于 2019-11-27 17:41:45
问题 Before Django 1.7, when using the Django Sites Framework one could/should define the initial data using Initial Fixtures. myproject/fixtures/initial_data.json [ { "pk": 1, "model": "sites.site", "fields": { "domain": "domain1", "name": "name1" } }, { "pk": 2, "model": "sites.site", "fields": { "domain": "domain2", "name": "name2" } }, { "pk": 3, "model": "sites.site", "fields": { "domain": "domain3", "name": "name3" } } ] Since it is a global project setting, I added a "fixtures" folder to

Images in Django fixtures?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 14:34:35
问题 I was looking at Django fixtures in the docs, there was no mention of preloading images into the database. I can't be the only who needed to do this. Is this possible? If so how? If not, are there any workarounds available? Please and thank you. 回答1: Yes, it's possible. You have to put your image in your project MEDIA_ROOT. In fixtures it will look like [{ "pk": 1, "model": "pictures.picture", "fields": { "image": "/media/gebakken_kip_met_korianderrijst_1152_x_1728.png" } }] 回答2: this has

IntegrityError when loading fixture during django testing

孤人 提交于 2019-11-27 12:11:05
问题 I'm loading a fixture created with dumpdata, and getting the following exception: Problem installing fixture 'db_dump.json': Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 174, in handle obj.save(using=using) File "/usr/lib/python2.6/site-packages/django/core/serializers/base.py", line 165, in save models.Model.save_base(self.object, using=using, raw=True) File "/usr/lib/python2.6/site-packages/django/db/models/base