First answer: {{ something|capfirst }} RTFM

The second is not only for template but easy.
functional example concentrated on 4 lines

./manage.py shell
  from django.template import Template, Context
  p = Product.objects.all()[0]
  t = Template('{% for name,value in prod_dict %}{{ name|capfirst }}:
{{ value }}\n{% endfor %}')
  print t.render(Context({'prod_dict': sorted(p.__dict__.items())}))


--Hy

On 31 bře, 16:15, Thomas <[email protected]> wrote:
> Sorry I wasn't being too clear. I would like to use the name of the field
> (just with the first letter capitalized) as a label. e.g. the field named
> 'email' would be labeled 'Email'. I just don't know how to do that.
>
>
>
>
>
>
>
> On Saturday, March 31, 2012 3:13:56 PM UTC+2, BoulderDave wrote:
>
> > Well, if contact, email, and phone were some sort of relationship instead
> > of just a charfield/email field, you could loop through them (lets say they
> > were a many2many to 'field'), and have a label (maybe help_text) associated
> > with each field... but thats making it more complicated then it needs to
> > be... it isn't breaking the DRY principle really.. these are each a unique
> > field that need to be handled individually.. your not hardcoding them..
> > that's like saying you hardcoded the code of your application because code
> > was written.
>
> > Dave
>
> > On Sat, Mar 31, 2012 at 8:51 AM, Thomas <[email protected]> wrote:
>
> >> I am convinced that there must be a way to this in a loop in the template:
>
> >>     <table class="indented">
> >>         <tr><td>Contact :</td><td>{{
> >> product.extendedproductfields.contact }}</td></tr>
> >>         <tr><td>Email :  </td><td>{{ product.extendedproductfields.email
> >> }}</td></tr>
> >>         <tr><td>Phone :  </td><td>{{ product.extendedproductfields.phone
> >> }}</td></tr>
> >>     </table>
>
> >> How can I print the 'Email', 'Phone', .. fields automatically in the
> >> table above rather than hard-code them?
>
> >> Many thanks,
> >> Thomas
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Satchmo users" group.
> >> To view this discussion on the web visit
> >>https://groups.google.com/d/msg/satchmo-users/-/TF5dAJEINYIJ.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/satchmo-users?hl=en.
>
> > --
> > Dave Brown
> > CEO/Founder
> > Rampframe.com - Action Sports Network

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to