Programmatically populate sample data for Django Image / File fields?

I need to fill in sample data for Django Image / File fields in automatic python code.

I want to initialize Django ImageFields and FileFields with some sample images and data files that are stored in my "site_media" directory of my Django project.

What would the code look like? This is not for testing, I want to auto-sample data into user accounts of the Django website (including this Imgae / File media sample.)

This should be done in python code without using appliances.

+3
source share
1 answer

, , JSON, , . django-admin, :

 django-admin.py loaddata mydata.json

. http://docs.djangoproject.com/en/1.2/ref/django-admin/#loaddata-fixture-fixture

-1

Source: https://habr.com/ru/post/1756349/


All Articles