Ok. So it seems you can't access the field verbose_name without a little
trickery. So here is how I did it.
Model:
def get_fields(self):
return [(field.name, field.value_to_string(self)) for field in
self._meta.fields]
Template Filter:
@register.filter
def get_verbose_name(model, field):
Pardon the continued confusion, but the problem is that I don't know how to
access the model field to get it's associated label like I can when
rendering a form. I don't want to manually type out each label text in my
template because I like knowing that if I do need to change the label, I can
On Wednesday, February 23, 2011 04:16:51 pm Greg Corey wrote:
> Thanks for your reply. One question.
>
> > make sure to reference the model field you want as the label if
> > 'Requester' isn't it.
>
> Not sure what you mean by this. Do you just mean manually change
> 'Requester' to whatever I
Thanks for your reply. One question.
> make sure to reference the model field you want as the label if 'Requester'
> isn't it.
>
Not sure what you mean by this. Do you just mean manually change 'Requester'
to whatever I want, or that I really can reference the model field to get
the label?
On Wednesday, February 23, 2011 02:15:40 pm geraldcor wrote:
> Hello all,
>
> When rendering a list of data for a particular model instance, I am
> wondering how to access the label_tag attribute for a field when not
> using a form.
>
> In my view I get a model instance and pass the object in my
Hello all,
When rendering a list of data for a particular model instance, I am
wondering how to access the label_tag attribute for a field when not
using a form.
In my view I get a model instance and pass the object in my context
inspection = inspection.objects.get(pk=3)
Then in my template I
6 matches
Mail list logo