Не удалось исключить идентификатор, даже пытался с существующим вопросом в stackoverflow: django-import-export: невозможно исключить поле идентификатора во время импорта: KeyError: u'id '
resource.py
from import_export import resources
from .models import Bugdata
class BugDataResource(resources.ModelResource):
class Meta:
model = Bugdata
skip_unchanged = True
report_skipped = True
exclude = ('id',)
import_id_fields = ['Created_date', 'BugID', 'ID_Link', 'Summary', 'Status', 'Severity', 'Tags']
models.py
from django.db import models
class Bugdata(models.Model):
Created_date = models.DateField()
BugID = models.CharField(max_length=50,primary_key=True)
ID_Link = models.URLField(max_length=300)
Summary = models.CharField(max_length=600)
Status = models.CharField(max_length=10)
Severity = models.CharField(max_length=10)
Tags = models.CharField(max_length=10)
def __str__(self):
return self.Summary
admin.py
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from .models import Bugdata
# Register your models here.
@admin.register(Bugdata)
class NewtaskAdmin(ImportExportModelAdmin):
pass
Traceback
Error:
Traceback (most recent call last):
File "C:\Users\gomathis\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\django_import_export-1.0.1-py3.6.egg\import_export\resources.py",
line 453, in import_row
instance, new = self.get_or_init_instance(instance_loader, row)
File "C:\Users\gomathis\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\django_import_export-1.0.1-py3.6.egg\import_export\resources.py",
line 267, in get_or_init_instance
instance = self.get_instance(instance_loader, row)
File "C:\Users\gomathis\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\django_import_export-1.0.1-py3.6.egg\import_export\resources.py",
line 261, in get_instance
return instance_loader.get_instance(row)
File "C:\Users\gomathis\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\django_import_export-1.0.1-
py3.6.egg\import_export\instance_loaders.py", line 31, in get_instance
field = self.resource.fields[key]
KeyError: 'id'