0

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?

James Parker
  • 2,095
  • 3
  • 27
  • 48
  • One way to improve the performance of this page is to use Django's `select_related()` and `prefetch_related()` methods to reduce the number of queries being executed. I dumped the code [here](https://www.codedump.xyz/py/ZBDRoIWQqhUkUMQ-) at codedump.xyz, see it and then tell me. – Sunderam Dubey Mar 14 '23 at 19:57
  • Another way to improve performance is to use Django's pagination feature to load only a subset of the data at a time. – Sunderam Dubey Mar 14 '23 at 19:58

0 Answers0