A
A
Alex Xmel2021-03-06 11:36:20
Django
Alex Xmel, 2021-03-06 11:36:20

How to populate a database in django with initial data?

There is a project, at its initial launch we have a new database, in which many different directories must be entered.
I see the following options:
1. Create a database in advance with all directories and, at a new start, replace the new database with a pre-created one (I don’t use this option myself, since the database can change with all the consequences in the process of changing the project, but by the way, I never tried it this option)
2. Create a second admin panel, where to throw various buttons with the words "Add XXX" and when they are pressed, the necessary directories are added to the database. The directories themselves are taken from simple txt files that lie nearby. After creating the database, I disable this admin panel. (I myself use this option, but damn it hemorrhoids)
3. Ideally, I want this: There is a standard admin panel, add to it approximately the following buttons: "Enter initial values". I understand that you can inherit from the base admin template and do whatever you want there, but I don’t want to fence it, because in the future there may be problems when updating django. Is there a standard way to do this? Or is option number 1 still quite acceptable and I bother in vain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-03-06
@Desead

It's strange that you don't see the fixture option. It looks like you haven't read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question