iamjazzar / django-mako

The first simple, elegant Django Mako library
https://www.ahmedjazzar.com
MIT License
18 stars 10 forks source link

The recommended `static` URL is not optimal #1

Closed OmarIthawi closed 7 years ago

OmarIthawi commented 7 years ago

Thank you @ahmedaljazzar for creating the library!

In the README.md file this library recommends the following:

  1. To include a static file url: ${ static }/home.png

Which has been added with in djangomako/backends.py:

context['static'] = staticfiles_storage.url

I think this variable should not be used directly. Instead we should use the static helper instead. Quoting a StackOverflow answer:

Since this is the top result on Google, I thought I'd add another way to do this. Personally I prefer this one, since it leaves the implementation to the Django framework.

from django.contrib.staticfiles.templatetags.staticfiles import static

url = static('x.jpg')
# url now contains '/static/x.jpg', assuming a static path of '/static/'

I'm recommending this approach since it will correctly renames x.png to x.f0de3f9.png when needed for cache busting.

Let me know if I should clarify more!

iamjazzar commented 7 years ago

No need @OmarIthawi, and thanks for your suggestion. Please find your comment addressed in #2. If you have any other comments please feel free to write them. 😄

OmarIthawi commented 7 years ago

Awesome 😃

iamjazzar commented 7 years ago

Solved in #2