I donβt know what the difference should be, but I found the difference in use (using django 1.9.1 running via apache, wsgi on Python 3.4). In my application, I have several images in ImageFields in the database. If I use this code in my template:
<a href="object-{{object.id}}"><img src="{% static object.image %}" height="200px"></a>
then if I use {% load static %} , django will have a TypeError value ( Cannot mix str and non-str arguments ). This is probably due to the fact that object.image not a string, but ImageField , which is converted to a string at a later stage. However, if you use {% load staticfiles %} , this error does not occur.
Unfortunately, I found this difference by spending hours debugging the problem. I managed to find a workaround for using the first option, namely to add the string converter method for the object as follows:
#image string def image_str(self): return str(self.image)
We hope that this knowledge will be useful for someone.
Deleet Jan 27 '16 at 19:56 2016-01-27 19:56
source share