Customized Django template filters

This is a lazy post and more of a bookmark, but I found a really straightforward and clear tutorial for creating your own django template tags.



Django’s own documentation is unfortunately not very beginner friendly!

{% static %} files

Now i’ve finally moved on to creating my own¬†templates within django/wagtail. But first I have a bit of an issue with the static files.

When I attempt to add images in Wagtail,

Picture 12

I get the dreaded Internal Server Error

Internal Server Error
The server encountered an internal error or 
misconfiguration and was unable to complete 
your request.









Picture 11


Additionally, attempting to link to images in my static folder like so:

<p><img src="{% static "its_alive1.gif" %}" alt="Its Alive" /></p>

gives a broken image, although if I navigate to http://username.com/static/image.gif I can see the image in my browser.

Right now my settings.py are as follow:

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/home/clarayee/website/static/'

The STATIC_URL is a hard-rooted to test if it makes any difference. Nope, no difference!