mirror of https://github.com/snachodog/mybuddy.git
Use get_FOO_display for choices fields in templates
This commit is contained in:
parent
cce4855b52
commit
b6733650dc
|
@ -154,11 +154,11 @@ class DiaperChange(models.Model):
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
attributes = []
|
attributes = []
|
||||||
if self.wet:
|
if self.wet:
|
||||||
attributes.append(DiaperChange._meta.get_field('wet').name)
|
attributes.append(self._meta.get_field('wet').verbose_name)
|
||||||
if self.solid:
|
if self.solid:
|
||||||
attributes.append(DiaperChange._meta.get_field('solid').name)
|
attributes.append(self._meta.get_field('solid').verbose_name)
|
||||||
if self.color:
|
if self.color:
|
||||||
attributes.append(self.color)
|
attributes.append(self.get_color_display())
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<th scope="row"><a href="{% url 'core:child' change.child.slug %}">{{ change.child }}</a></th>
|
<th scope="row"><a href="{% url 'core:child' change.child.slug %}">{{ change.child }}</a></th>
|
||||||
<td class="text-center">{{ change.wet|bool_icon }}</td>
|
<td class="text-center">{{ change.wet|bool_icon }}</td>
|
||||||
<td class="text-center">{{ change.solid|bool_icon }}</td>
|
<td class="text-center">{{ change.solid|bool_icon }}</td>
|
||||||
<td>{{ change.color }}</td>
|
<td>{{ change.get_color_display }}</td>
|
||||||
<td>{{ change.time|date:'n/j/y G:i' }}</td>
|
<td>{{ change.time|date:'n/j/y G:i' }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">
|
<div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
{% for feeding in object_list %}
|
{% for feeding in object_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></th>
|
<th scope="row"><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></th>
|
||||||
<td>{{ feeding.method }}</td>
|
<td>{{ feeding.get_method_display }}</td>
|
||||||
<td>{{ feeding.type }}</td>
|
<td>{{ feeding.get_type_display }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if feeding.amount %}
|
{% if feeding.amount %}
|
||||||
{{ feeding.amount }}
|
{{ feeding.amount }}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if feeding %}
|
{% if feeding %}
|
||||||
{{ feeding.type }}, {{ feeding.method }}
|
{{ feeding.get_type_display }}, {{ feeding.get_method_display }}
|
||||||
{% if feeding.amount %}
|
{% if feeding.amount %}
|
||||||
({{ feeding.amount }})
|
({{ feeding.amount }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% if feeding %}
|
{% if feeding %}
|
||||||
<div class="display-4 text-center">{{ feeding.method }}</div>
|
<div class="display-4 text-center">{{ feeding.get_method_display }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans "None" %}
|
{% trans "None" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue