Mmm maybe creating a tag
https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/#writing-custom-template-tags
In template {% mytag obj prop %}
In tag function
def mytag(obj, prop):
return getattr(obj, prop)
El miércoles, 20 de mayo de 2015, rishi sijariya <[email protected]>
escribió:
> Hi Hayyan Rafig,
>
> did you find your solution of adding two variable , if yes pls share
with us, or any one can help pls
>
> On Wednesday, 10 August 2011 03:07:25 UTC+5:30, Hayyan Rafiq wrote:
>>
>> Okay then which way do u recommend that i should follow in case
>> i need to displays objects with different no of properties
>> Example obj has propA and PropB
>> {{obj.propA}}
>> {{obj.propB}}
>> would work but i want it to be dynamic since the no and name of
properties may vary..
>> I tried writing all the properties of an object in a list and passing
that list obj to template
>> but it seems this is not just possible.. since
>> {% for prop in properties %}
>> <td>{{obj}}+{{.prop}}</td>
>> {% endfor %}
>> or other things similar to above do not work
>>
>> Any suggestions..
>>
>> > Date: Tue, 9 Aug 2011 17:25:42 -0400
>> > Subject: Re: How to concatenate two variables in a template for
evaluation..
>> > From: [email protected]
>> > To: [email protected]
>> >
>> > You have to write it as {{ obj.title }} in your template. Django
>> > templates are designed to allow very little in the way of logic; that
>> > should take place in your views.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
Groups "Django 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/django-users?hl=en.
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/bbe5399f-15e3-43b5-ae7d-d79e5f54191b%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>
--
"La utopía sirve para caminar" Fernando Birri
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAG%2B5VyMVdUVzhFzVsj54SZoiR5NDLx9RYZoqgYJ0Am6za%3D3pHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.