I'd say you should check if the pagesize variable is a string or not on this line -
upperbound=self.pagesize * int(arg0) Remember in Python, 'hello' * 2 == 'hellohello'. On 24 December 2010 05:04, prasad iyer <p.c.i...@gmail.com> wrote: > Hi Everyone, > I am getting type error on integer. I have tried converting all the > possible variables to int but still the problem persist. Can anyone > help me out with this type error > following is the stack trace > http://dpaste.com/289886/ > > following are the 2 functions which are giving me the problem > > def list_movies(request,page_no=1, orderby=None): > try: > > page=int(page_no) > except ValueError: > page=1 > if orderby is None: > orderby='-date_pub' > latest_movies=Movies.objects.all().order_by(orderby) > pagination=TubePagination(latest_movies, 20) > try: > page=int(page) > assert (type(page) is IntType) > movies=pagination.get_page(page) > except InvalidPage: > errorcontent='[{"error":"10001"}]' > return HttpResponse(content=errorcontent,mimetype='application/ > json') > json_serializer=serializers.get_serializer('json')() > jsonobj=json_serializer.serialize(movies, ensure_ascii=False) > return HttpResponse(content=jsonobj, mimetype="application/json") > > > > > class TubePagination: > def __init__(self, arg0, arg1=1): > self.objs=arg0 > self.pagesize=arg1 > def get_page(self, arg0): > upperbound=self.pagesize * int(arg0) > if upperbound > len(self.objs): > k=upperbound - len(self.objs) > > if k > self.pagesize : > raise InvalidPage(arg0) > else: > lowerbound=len(self.objs) - (len(self.objs) % > self.pagesize) > else: > lowerbound=upperbound-self.pagesize > if lowerbound < 0: > lowerbound = 0 > return self.objs[lowerbound:upperbound] > > -- > 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. > > -- 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.