python - How to upload data in model through migrations in django? -


i using django. made new model named suggestion_title has 2 fields named fa_id , desc. , have data in form of text filled in that. there way upload data migration or something. don't want add data manually. heard fixture not able find solution. please help.

for older versions of django can use fixtures, versions >= 1.7, preferred way go data migration:

https://docs.djangoproject.com/en/1.8/topics/migrations/#data-migrations

# -*- coding: utf-8 -*- django.db import models, migrations  def create_objects(apps, schema_editor):     suggestiontitle.objects.create(fa_id="foo", desc="bar")  class migration(migrations.migration):      dependencies = [         ('yourappname', '0001_initial'),     ]      operations = [         migrations.runpython(create_objects),     ] 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -