a work in progress test of custom filters

This commit is contained in:
Ivan Hörler 2018-01-19 15:40:55 +01:00
parent 9d6c4b308c
commit b53f52cac1
4 changed files with 15 additions and 7 deletions

View File

@ -9,7 +9,3 @@ class CurrencyForm(forms.Form):
CURRENCY_CHOICES = [(t.name, t.name) for t in
ExchangeRate_name.objects.all()]
type = forms.ChoiceField(choices=CURRENCY_CHOICES,
widget=forms.Select(attrs={
'onchange': 'get_vehicle_color();'}))

View File

@ -0,0 +1,11 @@
from django import template
register = template.Library()
@register.filter()
def boldcoffee(value):
return '%s !!gefiltert!!' % value
# excample filter: {{ article.price_in_chf|boldcoffee }}

View File

@ -8,7 +8,8 @@
},
dataType: 'json',
success: function (data) {
alert("es pop auf! --dies kommt von: static/js/app.js--.");
var foo = jQuery.parseJSON(data);
alert("es pop auf! --dies kommt von: static/js/app.js--." + foo.currency_update);
}
});

View File

@ -1,5 +1,5 @@
{% extends "webshop/base.html" %}
{% load customfilters %}
{% block section_title %}Articles{% endblock %}
{% block content %}
@ -22,7 +22,7 @@
</td>
<td scope="col">{{ article.category }}</td>
<td scope="col">{{ article.stock }}</td>
<td scope="col">{{ article.price_in_chf }}</td>
<td scope="col">{{ article.price_in_chf|boldcoffee }}</td>
</tr>
{% endfor %}
</table>