On Tue, Feb 17, 2009 at 2:32 PM, Tim <timster...@gmail.com> wrote: > > 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 > > > What Tim said is completely correct, just as a side note, you can't do this with any methods that actually require arguments though(other than self of course :P ).
Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---