-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a component inside a loop will duplicate the database query (or rendering the entire page) for each element #643
Comments
Hello, I'm sorry you are running into this issue. Off the top of my head, I wonder if this is an One thing to see what might be going on is to change the I render a component for every row in a table in this example: https://github.com/adamghill/django-unicorn/blob/main/example/unicorn/templates/unicorn/nested/table.html#L38. The backend code is here: https://github.com/adamghill/django-unicorn/blob/main/example/unicorn/components/nested/table.py#L31. You can see I have a There should be minimal overhead when rendering components with |
Hi, context['filtered_object_list'] = [
AvailableProjectPresenter(project, ...) for project in Project.objects.select_related(...).prefetch_related(...).filter(...).annotate(...)
] Unfortunately, we are sure that this is not an
We suspect it may be a problem with the way components render themselves and the use of beautifulsoup4 to find a component's parent, but we haven't been able to test that yet. |
Ah, thanks for the further clarification here -- that is frustrating! I'm going to try to replicate your set up in the example app in this repo to see if I get the same results. Or let me know if there is a minimal way to reproduce, thanks. |
Hi!
While trying to use this wonderful library in our project, we encountered a performance issue. A table that contains only 80 rows renders about 12 seconds through this piece of code:
According to django-debug-toolbar:
If instead of using the component
{% unicorn ... %}
we generate the table in the "classic" way using pure html, the page load time is less than a second (with around 90 database queries). What we have already tried:UnicornView
class.Therefore, we guess that the problem may be the way individual components are rendered, but we have not been able to find the cause or solution to the problem so far.
Due to the fact that this is a project with no access to the source code, I am not able to share the full data of the data but only an illustrative one:
Currently we are stuck and do not know what we can do next, and we want to integrate our project with this library because it will improve our work and provide better code clarity.
The text was updated successfully, but these errors were encountered: