Django List Admin Is Very Slow When Setting is_editable to use a Django Money Field

57 views Asked by At

I'm utilizing the django-money package in my model like so.

class MyModel(models.Model):

price_low = MoneyField(
        max_digits=10,
        default=0,
        decimal_places=2,
        null=True,
        blank=True,
        default_currency="USD",
    )
    price_medium = MoneyField(
        max_digits=10,
        default=0,
        decimal_places=2,
        null=True,
        blank=True,
        default_currency="USD",
    )
    price_high = MoneyField(
        max_digits=10,
        default=0,
        decimal_places=2,
        null=True,
        blank=True,
        default_currency="USD",
    )

And then loading the models in an Admin List with these fields set as editable like so.

class IssueAdmin(admin.ModelAdmin):
    
    list_editable = (
            "price_low",
            "price_medium",
            "price_high"
        )

     list_per_page = 20

With this setup and 400k records in the database it takes approx. 6 seconds to load the page.

I'm limiting the results returned to 20 just to get this page to return in somewhat of a respectable time frame.

If I remove the money fields from list_editable and put different fields that are basic inputs or even autocompletes the page loads in approx 1.5 seconds.

How can I improve the performance of this?

0

There are 0 answers