xml - Initial Data Django Fixtures Issue: Installed 0 object(s) from 0 fixture(s) -


i having little trouble importing initial data through xml files. example name file in 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> 

and model file looks like:

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) 

when run manage.py loaddata myapp/fixtures/initial_data.xml, get: installed 0 object(s) 0 fixture(s). have tried json , got same result. ideas?

you should format xml django expects it. 1 way go manually add , object using django's admin , dump data using

manage.py dumpdata --format=xml --indent=4 

for case, gives like

<?xml version="1.0" encoding="utf-8"?> <django-objects version="1.0">     <object pk="1" model="myapp.nutrition">         <field type="charfield" name="name">asiago cheese bagel</field>         <field type="integerfield" name="calories">370</field>         ...     </object> </django-objects> 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -