Really interesting solution, I didn't think about using template filters, 
thank you.
I think it's too complicated for this task, but I'll surely keep this in 
mind, this can be very useful.

четверг, 31 января 2013 г., 15:29:54 UTC+4 пользователь ke1g написал:
>
> The template language does not allow for the passing of arguments to model 
> methods.
>
> Two methods does not seem ugly to me.  But if you feel that you need 
> something else, you could write a template filter used something like:
>
>   {{ album|get_photo_url:"thumbnails" }}
>
> The implementation of the filter is in python, and could pass the argument 
> when calling album's method.  (I'd suggest not calling the method 
> "get_absolute_url", however, because that name is special to Django, and is 
> not expected to take such an argument.)
>
> Bill
>
> On Thu, Jan 31, 2013 at 12:35 AM, Sammael <s4m...@gmail.com 
> <javascript:>>wrote:
>
>> Thank you for your answer!
>>
>> I have a photo album which can be displayed in two modes: full (with url 
>> like 'album/id/full') and thumbnails ( like 'album/id/thumbnails' ). I 
>> would like 'get_absolute_url' to return a corresponding url depending on 
>> the given mode, something like {{ album.get_absolute_url full }} and {{ 
>> album.get_absolute_url thumbnails }}
>>
>> The only solution I could find is to use two different functions: 
>> get_absolute_url_full and get_absolute_url_thumbnails. It works but it's 
>> ugly, I don't like it at all.
>>
>> Any advice is greatly appreciated.
>>
>> среда, 30 января 2013 г., 23:34:38 UTC+4 пользователь somecallitblues 
>> написал:
>>>
>>> You can't pass parameters to model functions from within a template. 
>>> What exactly are you trying to achieve?
>>>
>>>
>>> On 30 January 2013 21:34, Sammael <s4m...@gmail.com> wrote:
>>>
>>>> Hello friends,
>>>>
>>>> Is the any way to pass an extra parameter to get_absolute_url method of 
>>>> a model instance from template?
>>>>
>>>> Thank you for your answer.
>>>>
>>>> -- 
>>>> 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 django-users...@**googlegroups.com.
>>>> To post to this group, send email to django...@googlegroups.com.
>>>> Visit this group at 
>>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>> .
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>  
>>>>  
>>>>
>>>
>>>  -- 
>> 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 django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to