Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Django initial data for built-in app

I'm starting to use the "redirects" app built into Django to replace some existing redirects I have in my urls.py. I was wondering if there was any generally accepted way to include initial data in the code base for other apps. For example, if it was for an app I created I could create a migration file that had a RunPython section where I could load some initial data. With a built-in or third-party app there doesn't seem to be any way to create a migration file to add initial data.

The best I can think of right now is to include a .sql file in my repository with the initial data and just manually import the data as I push the code to the different instances.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you can do it by using fixtures

create a folder name fixtures in your app directory

use this command to create a json file that you want to make as initial data.

 python manage.py dumpdata you_app_name.model_name --indent 2 > model_name.json

copy this model_name.json to fixtures folder.

upload the code to the repo.

then after the migrate command . Type this command to load the initial data.

  python manage.py loaddata model_name.json

reference

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!