xml ファイルを介して初期データをインポートする際に少し問題があります。たとえば、myapp/fixtures/initial_data.xml でこのファイルに名前を付けます。
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<model>myapp.nutrition</model>
<name>Asiago Cheese Bagel</name>
<calories>370</calories>
<protein >17</protein >
<carbs>56</carbs>
<fats>8</fats>
<restaurant >Au Bon Pain</restaurant >
<price>1.29</price>
</row>
</rows>
そして、これは私のモデルファイルがどのように見えるかです:
from django.db import models
class Nutrition(models.Model):
name= models.CharField(max_length=100)
calories= models.IntegerField()
protein= models.IntegerField()
carbs= models.IntegerField()
fats= models.IntegerField()
restaurant= models.CharField(max_length=100)
price= models.DecimalField(decimal_places=2, max_digits=10)
manage.py loaddata myapp/fixtures/initial_data.xml を実行すると、次のようになります。 0 個のフィクスチャから 0 個のオブジェクトがインストールされました。JSONも試してみましたが、同じ結果が得られました。何か案は?