Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda