question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 1.11 slow ChoiceField rendering

See original GitHub issue
  • Package version: 1.6.1
  • Django version: 1.11
  • Python version: 3.6.1

Description:

I just upgrade to Django 1.11 and I noticed that in a specific form that we render timezones from pytz.common_timezones (currently 439 items) I’m getting error 503. After some tests, it seems that rendering ChoiceFields is extremely slow. If i trim the list down to a few items (<100) the form is displayed in a reasonable time. So I replaced the code for something like forms.ChoiceField(choices=[('test', 'test')] * 100) and the response time increases almost exponentially by the number os itens in the list.

Downgrade to 1.10.7 and everything is fast as always.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
xbellocommented, Apr 10, 2017

@mdalpi Do you have the Django Debug Toolbar enabled while testing this? I had the same problem, and finally found that disabling DDT solved the problem. See

https://github.com/jazzband/django-debug-toolbar/issues/910

0reactions
EugeneDaecommented, May 26, 2017

Wow, I was about to downgrade to 1.10 because of this. Indeed DDT is the culprit. Thanks for bringing this up @mdalpi and thanks @xbello for the solution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poor Performance for Form Rendering In Django 1.11
If you have truly isolated the widget rendering as the performance bottleneck, ... ChoiceField(choices=XXX, widget=OptimizedSelectWidget).
Read more >
[Answered]-Django render is very slow-django
This is my training django project. I am using GeoIP, django-modeltranslation, i18n. Showing video gallery page is very slow. The database contains about...
Read more >
Degraded performance when rendering ChoiceField with lots ...
One ChoiceField with 1k options took 6s instead of 0.5s after updating to django 1.11 with DEBUG=True. apollo13 created a reduced test case:...
Read more >
forms - Simple is Better Than Complex
How to Implement Grouped Model Choice Field Jan 2, 2019 • 6 minutes read • 12 comments • views; Advanced Form Rendering with...
Read more >
PDF - Django Documentation
1.11 Internationalizationandlocalization . ... from django.shortcuts import render ... Doing the following is potentially quite slow:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found