Performance Error with Django Import/export
I am experiencing a performance issue with Django import-export in my production environment. When importing a spreadsheet with around 3k rows, the process ends up with only an
Internal Server Error
However, when I run the tests in the development environment, despite the delay, it successfully completes the upload of the rows.
Am I missing any configuration, or does it really need to be faster to work correctly?
Here are my configurations:
class AtivosAssetAllocationResource(resources.ModelResource):
class Meta:
use_bulk = True
batch_size = 1000
model = AtivosAssetAllocation
fields = ('id', 'grupo', 'ticker', 'siglacmd', 'ativo', 'nomeComercial', 'conservador', 'moderado', 'agressivo', 'descricao', 'aprovado',
'classe', 'subclasse', 'range', 'previdencia')
And for reference, here is the model:
class AtivosAssetAllocation(models.Model):
ticker = models.CharField(max_length=40, unique=True)
siglacmd = models.CharField(max_length=20, blank=True, null=True)
ativo = models.CharField(max_length=100)
nomeComercial = models.CharField(max_length=100, blank=True, null=True)
conservador = models.FloatField(blank=True, null=True)
moderado = models.FloatField(blank=True, null=True)
agressivo = models.FloatField(blank=True, null=True)
descricao = models.TextField(blank=True, null=True)
classe = models.CharField(max_length=100, blank=True, null=True)
subclasse = models.CharField(max_length=100, blank=True, null=True)
range = models.FloatField(blank=True, null=True)
previdencia = models.BooleanField(default=False)
aprovado = models.BooleanField(null=True, blank=True, default=None)
def __str__(self):
return self.ativo
Previously, the import was done normally, but due to this error, I ended up adding the method bulk
use_bulk = True
batch_size = 1000
And in settings.py:
# Import Export
IMPORT_EXPORT_USE_TRANSACTIONS = True
IMPORT_EXPORT_SKIP_ADMIN_LOG = True
PS: In development, the total time takes around 10 minutes to export.
Should the solution involve some Django configuration, or is it a server error?