2👍
✅
Remove the foreign keys which you don’t need, rather than trying to find the empty value, i.e. your fixture block should look something like this instead:
<django-objects version="1.0">
<object model="ipmanager.network" pk="459124212">
<field name="mask" type="CharField">30</field>
<field name="site" type="CharField">place</field>
<field name="network" type="CharField">1.1.1.1</field>
<field name="category" type="CharField">category</field>
<field name="description" type="CharField">enum amun set ra</field>
<field name="vlan" type="CharField" />
<field name="designation" type="CharField">supernet</field>
</object>
👤wim
0👍
The accepted answer works for a foreign key, however it’s still valuable to be able to import null (if the db accepts nulls for that field).
In order to do so, the json fixture should look like this:
{
"model": "Foo",
"pk": "1",
"fields":
{
"attribute_1": "42",
"nullable_int_field": null,
....
Note the absence of quotes around null – this is the json null. In that case, assuming nullable_int_field accepts nulls, the error wouldn’t come up. Also works with date fields (which throw similar error with "" as value in the fixture).
- [Answered ]-Django file-browser and error 404
- [Answered ]-Django rest framework: Do I really need two separate serializers?
0👍
Instead of removing the None value field altogether, you can also use "" (maybe this will also work "")
<object model="ipmanager.network" pk="459124212">
<field name="mask" type="CharField">30</field>
<field name="site" type="CharField">place</field>
<field name="network" type="CharField">1.1.1.1</field>
<field name="category" type="CharField">category</field>
<field name="description" type="CharField">enum amun set ra</field>
<field name="vlan" type="CharField"><None></None></field>
<field name="designation" type="CharField">supernet</field>
<field name="parent" rel="ManyToOneRel" to="networks.id"><None></None></field>
<field name="vrf" rel="ManyToOneRel" to="vrfs.id"><None></None></field>
</object>
- [Answered ]-How can I combine 2 django query into one with object limit
- [Answered ]-Test Django Forms submitted through Ajax view
- [Answered ]-How to collect Django static files with the same name?
- [Answered ]-Custom view does not show results in Django Haystack with Elastic Search
Source:stackexchange.com