I have a simple model:
class Sheker(models.Model):
name = models.CharField(max_length=90)
display_name = models.CharField(max_length=90, null=True)
search_name = models.CharField(max_length=90, null=True)
def __unicode__(self):
return self.search_name
class Sod(models.Model):
name = models.CharField(null=False, blank=False, max_length=100)
sheker = models.ManyToManyField(Sheker, blank=True, name='sheker')
With a simple form:
from django import forms
from django.contrib.admin.widgets import FilteredSelectMultiple
from rosh.models import *
class SodForm(forms.ModelForm):
sheker = forms.ModelMultipleChoiceField(
queryset=Sheker.objects.all(),
widget=FilteredSelectMultiple("sheker", is_stacked=False),
required=False
)
The model Sheker
have more then 12K rows in the db (postgres with geo extensions)- and the problem is that it makes the form to load super slow = more then 5 seconds to load the html.
Is the problem is queryset=Sheker.objects.all()
? How can I make it load faster/cache it or something else to load the page fast (as normal web page).
What is the best practice for such issue?