'Why my exports are limited to 100 records only in django-import-export?
I am using Django import export in my project.
I have ~5000 records in the model.
In local, The export is working fine. [exporting all the records in csv] But in production, when I export to csv, Only 100 records are exported.
The django app is hosted on Cpanel. I am using mysql phpmyadmin in production.
Is there any limit in the cpanel to export in django import-export module which I can change because the problem I am facing in production only.
database config in settings.py
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': '********',
'USER': '*********',
'PASSWORD': '*********',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'sql_mode': 'STRICT_ALL_TABLES',
},
}
}
Model
class Treatment(models.Model):
clinic = models.ForeignKey(Clinic,on_delete=models.CASCADE,related_name='alltreatments', null=True)
slug = models.SlugField(null= True, blank= True)
language = models.ForeignKey(Language, on_delete=models.CASCADE, related_name='treatmentlanguage', blank= True, null=True)
searched_treatment = models.CharField(max_length= 256, blank= False, null= False)
price = models.FloatField(blank= False, null= False)
price_type = models.CharField(max_length= 256, blank= True, null= True)
package_info_1 = models.CharField(max_length= 556, blank= True, null= True)
package_info_2 = models.CharField(max_length= 556, blank= True, null= True)
package_info_3 = models.CharField(max_length= 556, blank= True, null= True)
package_info_4 = models.CharField(max_length= 556, blank= True, null= True)
currency=models.ForeignKey(Currency,on_delete=models.CASCADE,related_name='currency',blank=True,null=True)
created= models.DateTimeField(auto_now=True)
status = models.BooleanField(default= True)
class Meta:
# unique_together = ('clinic', 'searched_treatment', 'language')
ordering=('-created',)
verbose_name_plural='Treatments'
def __str__(self):
return self.searched_treatment
def save(self, *args, **kwargs):
slug = self.searched_treatment
self.slug = slugify(slug)
super(Treatment, self).save(*args, **kwargs)
Model Resource
class TreatmentResource(resources.ModelResource):
currency = fields.Field(column_name='currency',attribute='currency', widget=ForeignKeyWidget(Currency, 'name'))
language = fields.Field(column_name='language',attribute='language', widget=ForeignKeyWidget(Language, 'code'))
clinic = fields.Field(column_name='clinic',attribute='clinic', widget=TreatmentForeignKeyWidget(Clinic, 'code'))
class Meta:
model = Treatment
fields = ('searched_treatment', 'price_type', 'price', 'package_info_1', 'package_info_2', 'package_info_3', 'package_info_4')
exclude = ('id',)
import_id_fields = ('searched_treatment', 'price_type', 'price', 'package_info_1', 'package_info_2', 'package_info_3', 'package_info_4', 'currency', 'language', 'clinic')
Model Admin
class TreatmentAdmin(ImportExportModelAdmin, admin.ModelAdmin, ExportCsvMixin):
resource_class = TreatmentResource
search_fields = ['searched_treatment' ]
actions = ["export_as_csv"]
field_names = ["slug"]
def get_import_formats(self):
formats = (
base_formats.CSV,
)
return [f for f in formats if f().can_export()]
THANKS IN ADVANCE
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
