开发者

Programatically populate sample data for Django Image/File fields?

I need to populate sample data for Django Image/File fields in automated python code.

I want to initialize Django ImageFields开发者_StackOverflow社区 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 autopopulate sample data into my Django website user's accounts (including this sample Imgae/File media.)

This should be done in python code without using fixtures.


If I understand you correctly you want to use fixtures, basically a JSON formatted file that holds data that will be put into the project database. They can be executed through the django-admin command like :

 django-admin.py loaddata mydata.json

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜