It sounds like you should have a look at:
http://docs.djangoproject.com/en/dev/ref/templates/

Instead of rendering straight to html you can structure the html as a
template and then feed your dictionary context in. Then your view points to
the template. If your template was called test.html then it would probably
work.

-Tim


On Tue, Feb 23, 2010 at 4:35 PM, soFh <ahmed...@gmail.com> wrote:

> my prefix could be changed and hence its length too ,
> so let me show you what i did to get the price from Rates table
> against prefix used in Ast.dst
>
> from cdr.cdrs.models import Ast,Rates
> price=0
> for i in Ast.objects.all():
>        for x in Rates.objects.all():
>                l = len(x.prefix)
>                if x.prefix == i.dst[0:l]:
>                price = x.rate
>      cost = price * i.billsec
>
> it gives me what i want ..but its on interactive console :$ i am
> really not getting where should i deploy it in my view to show this
> calculation (cost of call ) .
> cause in my view i am just using it like this :
>
> def mytest(request):
>
>        cdr_table = Rates.objects.all()
>        return render_to_response('clients/test.html',
> {"calls":cdr_table,},context_instance =RequestContext(request))
>
> now in html table defined in test.html i can see all the data coming
> in table Ast . But how i add a column in that html table having cost
> of each call as i got in my console.
>
> thanks for your help
>
>
> On Feb 24, 2:16 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> > On Feb 23, 9:10 pm, soFh <ahmed...@gmail.com> wrote:
> >
> >
> >
> > > Well i was already  thinking that i am not so clear in my question.
> > > so better let me post my model and what i want here .
> >
> > >http://dpaste.com/163776/
> >
> > > sorry I missed by mistake "C" of class Rates while pasting it on
> > > dpaste.
> >
> > > Anyways there are two models.
> > > there is one field billsec in model named "Ast" which is duration of
> > > call. there is one field named "dst" which is "dialed Number " .
> > > What i want is is to compare this dialed number by the prefix given in
> > > Rates Model and then multiply that Rate with duration to show  the
> > > cost of call.
> > > hope i am bit  clear now .
> > > Thanks in advance for any tip..
> > > regards
> >
> > I don't see where you are having a problem. Your logic, as you give it
> > above, is quite clear:
> >
> >     my_prefix = my_ast.dst[:5] # or however long the prefix is
> >     my_rate = Rate.objects.get(prefix=my_prefix)
> >     cost = my_rate.rate * my_ast.billsec
> >
> > --
> > DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> 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 post to this group, send email to django-us...@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