anhtran
anhtran

Reputation: 2034

Django Templates: How about just "load" and "load * from" in performance?

I have many templatetags in use. I just want to comfirm that {% load mytag1 mytag2 from alltags %} is faster than {% load alltags %}. In fact, I don't use all of functions in alltags.

Upvotes: 2

Views: 175

Answers (1)

bmihelac
bmihelac

Reputation: 6323

In both cases load will load the whole template library module (via get_library function), so I guess that using one or another has no impact on performance.

Using load mytag1 mytag2 from alltags is usable to avoid collisions when same tag name exists in more than one template library or for readability.

Source code for load templatetag and Parser:

https://github.com/django/django/blob/master/django/template/defaulttags.py#L999

https://github.com/django/django/blob/master/django/template/base.py#L345

Upvotes: 1

Related Questions