python - How to manually populate Many-To-Many fields through JSON fixture in Django -


i have json fixture , want populate many-to-many field json fixture seems django wants 1 pk need pass in lot of integers representing pks other related fields.

is there anyway go this.

i have used raw_id = ['reference(my table name)'] in modeladmin pks can used reference related fields.

the error message is

file "/usr/local/lib/python2.7/dist-packages/django/core/serializers/python.py", line 142, in deserializer raise base.deserializationerror.withdata(e, d['model'], d.get('pk'), pk) django.core.serializers.base.deserializationerror: problem installing fixture '/home/user/desktop/file/data/file.json':

[u"',' value must integer."]: (kjv.verse:pk=1) field_value ','

you can use jsonfield() django model

from django.contrib.postgres.fields import jsonfield raw_id=jsonfield(primary_key=true,db_index=true,null=true) 

s0 database {raw_id:[1,2,3,4]}


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -