That's exactly how you would do it: {{ item.cost }}
No extra code is required in your model.

This of course requires that you have an item instance in your view
and pass it to the template.

For example...

def view_example(request):
    item = Item.objects.get(pk=1)
    render_to_response('template.html', {'item':item})


On Feb 17, 1:37 pm, wotaskd <wota...@gmail.com> wrote:
> Howdy,
>
> I have a model where one of the fields shouldn't be persistent.
> Instead, I'd like to add a method that always returns a calculation in
> the form of an integer value. Ex:
>
> http://dpaste.com/hold/121785/
>
> The question is... can I make the method - in the example, cost() -
> available to a web template (ex: by calling something like
> {{ item.cost }} )?
>
> Thanks!
>
> wotaskd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to