PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] how to perform population in django

 April 14, 2022     django, migration     No comments   

Issue

What is the django or pythonic way to setup a folder which contains populations that are applied to both the production database and also to any local database that a user can spin up when working on the django project locally?


Solution

If you want to automatically include initial data you can populate the database using fixtures. Django supports fixtures that are in JSON, YAML or XML. Basically, you can dump database data into fixture files using python manage.py dumpdata or you can create those files manually (or automate it with simple python script) and then with python manage.py loaddata <fixturename> you can populate the database anytime you need it for any environment (production, development etc.).
Django way of storing fixtures is to have folder named fixtures that contains data for the model inside model's application folder.
Find more on this topic in Django Documentation.



Answered By - Aleksandar Mijatović
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing