I have a table with 3500 entries and foreign keys.
I'm using client-sided processing datatables with: django-rest-framework and Ajax.
It takes up to 10 seconds to load.
Is there a way to show the first 10 entries (first page results) - for the user not to think that my website is broken, because it's taking too long - while the rest of the entries loads in the background?
Also looking for optimizations for the load speed. Thank you for your time.
EDIT: models.py
class Bibrest51(models.Model):
cadastro_id = models.AutoField(primary_key=True)
autor = models.CharField(db_column='Autor', max_length=255, blank=True, null=True)
tema = models.ForeignKey('BibTema', models.DO_NOTHING, blank=True, null=True)
tipo = models.ForeignKey('Tipo', models.DO_NOTHING, blank=True, null=True)
class Meta:
managed = False
db_table = 'bibrest51'
@property
def bib_tipo_nome(self):
return self.tipo.tipo_nome
class BibTema(models.Model):
tema_id = models.AutoField(primary_key=True)
tema_nome = models.CharField(max_length=150, blank=True, null=True)
class Meta:
managed = False
db_table = 'tema'
def __str__(self):
return self.tema_nome
serializers.py
class TemaSerializer(serializers.ModelSerializer):
class Meta:
model = BibTema
fields = '__all__'
depth = 1
class TipoSerializer(serializers.ModelSerializer):
class Meta:
model = Tipo
fields = '__all__'
depth= 1
class BibSerializer(serializers.ModelSerializer):
temas = TemaSerializer(read_only=True)
tipos = TipoSerializer(read_only=True)
class Meta:
model = Bibrest51
fields = (
'autor', 'ano', 'titulo', 'referencia','tipos','temas'
)