I'm trying to import data from a model which has nullable BinaryField
. The data doesn't contain the field and I want it to be imported with a null value in the field. If the field already exists in the database for a given id
, it should keep the value as it is.
I removed the field from the fields
whitelist in the corresponding Resource
object and added it to the exclude
blacklist. However, I'm getting this error while importing - can't pickle memoryview objects
.
Traceback:
Traceback (most recent call last):
File "/lib/python3.5/site-packages/import_export/resources.py", line 451, in import_row
original = deepcopy(instance)
File "/lib/python3.5/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/lib/python3.5/copy.py", line 297, in _reconstruct
state = deepcopy(state, memo)
File "/lib/python3.5/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/lib/python3.5/copy.py", line 243, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/lib/python3.5/copy.py", line 174, in deepcopy
rv = reductor(4)
TypeError: can't pickle memoryview objects
Package versions - django==1.11, django-import-export==0.6
EDIT:
class ABC(models.Model):
name = models.CharField('Name', max_length=128, blank=False, null=False)
binary_field = models.BinaryField('Some name', null=True, blank=True)
class ABCResource(resources.ModelResource):
class Meta:
model = ABC
fields = (
'id',
'name',
)
import_id_fields = ('id',)
exclude = ('binary_field',)
class ABCAdmin(ImportExportModelAdmin):
form = ABCModelForm
list_display = (
'id',
'name',
)
exclude = ('binary_field',)
resource_class = ABCResource
class ABCModelForm(forms.ModelForm):
class Meta:
model = ABC
exclude = ['binary_field']
django-import-export
are you using? – Mores