Skip to content
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

Fix #8924 - Speed up rendering of the script list #8925

Merged

Conversation

kkthxbye-code
Copy link
Contributor

Fixes: #8924

Loading the script list can become slow when having multiple large scripts. The reason is that django instantiates the Script class for each access in the template. This can be very slow in some cases.

The fix is simply to set do_not_call_in_templates = True on the callable before passing them to the template. Please let me know if there is a better option.

The template was changed slightly, as the script variable did not return the name when not instantiated. Name is now taken from Meta instead.

netbox/extras/views.py Outdated Show resolved Hide resolved
netbox/templates/extras/script_list.html Outdated Show resolved Hide resolved
- Fix the name classproperty
@kkthxbye-code
Copy link
Contributor Author

kkthxbye-code commented Mar 23, 2022

@jeremystretch - I moved do_not_call_in_templates to the base class.

I also changed the template to use script.name. I had to change it from self.__class__.__name__ to self.__name__. I tested on our production system (v3.1.5) and if you omit Meta.name the name of the script will be "type" (metaclass of new-style classes). I might be missing how it's supposed to work, but I think that's a bug.

@jeremystretch jeremystretch merged commit b6587c0 into netbox-community:develop Mar 23, 2022
@kkthxbye-code kkthxbye-code deleted the fast_script_list branch May 9, 2022 16:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Script list is slow when having large script files/a lot of scripts
2 participants