Вопрос

On https://docs.djangoproject.com/en/dev/howto/initial-data/, it says to run manage.py loaddata <fixturename> to re-load data, or to name a fixture "initial_data" to load it with every migrate.

On the page https://code.djangoproject.com/wiki/Fixtures, it says that a fixture can be loaded using python manage.py syncdb, but it looks like the database has to be reset first (true or false?).

Finally, on https://docs.djangoproject.com/en/dev/ref/django-admin/, it says to use django-admin.py loaddata <fixturename> to reload. Are these all options for the same thing? Or what are the differences?

Это было полезно?

Решение

The two loaddata are the same thing, but syncdb is a command that creates database tables loads the initial data for that app.

You would use loaddata to load a fixture into a database and syncdb to set up your database for a new app.

manage.py is a wrapper around django-admin.py that adds your project to the path and sets up the DJANGO_SETTINGS_MODULE environment variable. Normally, you'll use manage.py once your project has been set up.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top