django-fixtures

Import data into Django model with existing data?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 13:14:27
问题 I'm working on an online form builder tool (specifically for insurance agents). One of the things we would like to offer our customers is to have pre-built forms for common products (auto, home, life, etc) be available by default, but still modifiable. Under normal circumstances, I would simply create the forms in my development environment, then create a fixture containing these forms, and run syncdb on all the live sites. Unfortunately that isn't a possibility, as some of our customers

Import data into Django model with existing data?

风流意气都作罢 提交于 2020-01-14 13:12:17
问题 I'm working on an online form builder tool (specifically for insurance agents). One of the things we would like to offer our customers is to have pre-built forms for common products (auto, home, life, etc) be available by default, but still modifiable. Under normal circumstances, I would simply create the forms in my development environment, then create a fixture containing these forms, and run syncdb on all the live sites. Unfortunately that isn't a possibility, as some of our customers

syncdb not adding fixtures in 3rd party project

大兔子大兔子 提交于 2020-01-06 23:42:10
问题 I've written a pretty simple Django application called django-locality which takes the headache out of working with countries and territories. It provides a lot of initial data for countries and territories. I just the 0.1 release up to PyPI, and installed it in my project which I'm currently working on. (I basically created it out of a need I found in my original project.) When I ran syncdb , however, it didn't install any of my fixtures from locality . In the output, it printed "No fixtures

How can I loaddata from a fixture remotely

橙三吉。 提交于 2020-01-03 19:30:34
问题 With Django-nonrel on GAE, how do I do I load in a fixture to the server after deploying? I'm able to do it locallay via python manage.py loaddata fixturename But how can I do it on a deployed app that is already on appspot.com? 回答1: I believe the answer is python manage.py remote loaddata fixturename with an additional 'remote' word. I've tested that (about five minute before I type this). It will prompt for your gmail account and password. You also need to enable remote_api in app.yaml (if

How to load Django fixtures from all apps?

血红的双手。 提交于 2019-12-12 12:19:37
问题 I'm using fixtures in my Django application but only two apps are getting their fixtures loaded. When I manually run loaddata with --verbosity=2 I can see that it only looks in two apps although I have more with fixtures directories created inside. All apps are correctly installed in settings.py. From the documentation it seems that Django is supposed to search in the fixtures/ directory of every installed application. Any ideas why some apps are ignored ? 回答1: Initial_data gets imported each

Couldn't load fixtures with South in Django project

十年热恋 提交于 2019-12-11 09:29:34
问题 I've Django project which is using South application to handle schema and data migration. In one of my applications I have migration (number 0004) which is responsible for loading data fixtures from json file: class Migration(DataMigration): def forwards(self, orm): from django.core.management import call_command call_command("loaddata", "dummy_data.json") In the same project I try to add functionality of 'soft delete' which needs adding one more filed, defined as: deleted_at = models

Django loaddata with Natural Keys not querying correct Foreign Key

喜夏-厌秋 提交于 2019-12-07 07:56:56
问题 Here is my problem. I am trying to load some data that has a natural key relationship to another model. I modified the parent model to generate natural keys. I exported the the data from the old database using the command: manage.py dumpdata resources.image -n --indent 4 > images.json I then tried to import into the new database using the command: manage.py loaddata images.json At this point I get the error: IntegrityError: Problem installing fixtures: The row in table 'resources_image' with

Error in django unittest while loading a fixture

房东的猫 提交于 2019-12-07 07:18:03
问题 I am making unittests for a django app. I need some data in the database for my tests so I am using a json fixture. I have two fixtures: for users and it works ok. for some webpages The fixture 2 cause the following error: Problem installing fixture 'C:\Users\luc\Dev\Hg\mnl-adminpub\website\fixtures\website-unittest.json': Traceback (most recent call last): File "C:\Python26\lib\site-packages\django\core\management\commands\loaddata.py", line 169, in handle obj.save(using=using) File "C:

Load Multiple Fixtures at Once

孤街醉人 提交于 2019-12-06 17:27:47
问题 Is there anyway to load one fixture and have it load multiple fixtures? I'd ideally like to type: python manage.py loaddata all_fixtures And have that load all of the data instead of having to type everything. Is this possible? 回答1: Using $ python manage.py loaddata myfixtures/*.json would work as Bash will substitute the wildcard to a list of matching filenames. 回答2: I have multiple apps on the project directory and have each app with its 'fixtures' directory. So using some bash I can do:

Django loaddata with Natural Keys not querying correct Foreign Key

随声附和 提交于 2019-12-05 12:44:40
Here is my problem. I am trying to load some data that has a natural key relationship to another model. I modified the parent model to generate natural keys. I exported the the data from the old database using the command: manage.py dumpdata resources.image -n --indent 4 > images.json I then tried to import into the new database using the command: manage.py loaddata images.json At this point I get the error: IntegrityError: Problem installing fixtures: The row in table 'resources_image' with primary key '340' has an invalid foreign key: resources_image.voyage_id contains a value '41890' that