3👍
seems a duplicate of
How to use method parameters in a Django template?
one solution would be to pass result of your method to template. something like:
object = Mymodel.objects.get(id=17)
return render_to_response('x.html', {
'mymodel': object,
'mymodel_getp': object.getp(request),
'request': request
}, context_instance = RequestContext(request))
other solution would be to write a custom template tag:
@register.simple_tag(name="model_getp", takes_context=True)
def model_getp(context, object=None):
return object.getp(context)
and then in template:
{% model_getp mymodel %}
👤fsw
Source:stackexchange.com