I think the problem is in "Datetime field" format test_start_date please could you make it sure?plz
On Mar 22, 9:23 pm, NavaTux <navaneetha...@gmail.com> wrote: > Here just i had written django script to calculate in my data > > MarketUpdate in my django model > Here i am passing two custom fields 'ticker' and 'test_start_date'(datetime > format) > this script is finely working while executing in django shell > It displays error after calling as a method "stock_up()" > > from optionsAlpha.models import MarketUpdate > > from datetime import datetime > > from django.db.models import Q > > def stock_up(ticker, test_start_date): > > #stock_value=0 > > mu1 = MarketUpdate.objects.filter(Q(stock_symbol=ticker) & > Q(update_timestamp__gt=datetime(test_start_date))).order_by('stock_value') > > #print mu1[0].stock_value > > max_stock=mu1[0].stock_value > > count=0 > > for i in mu1: > > if i.stock_value >= max_stock: > > max_stock = i.stock_value > > count+=1 > > return count > > Output when calling this method from django shell: > > >>> dat > > datetime.datetime(2011, 3, 19, 8, 58, 28, 999615) > > >>> ticker > > 'GOOG' > > >>> stock_up(ticker,dat) > > Traceback (most recent call last): > > File "<console>", line 1, in <module> > > File "/home/hirelex/optionsalpha/optionsAlpha/trade_count.py", line 6, in > stock_up > > mu1 = MarketUpdate.objects.filter(Q(stock_symbol=ticker) & > Q(update_timestamp__gt=datetime(test_start_date))).order_by('stock_value') > > TypeError: an integer is required > > > > Here Stock_value is another field (float) in my model. just i need to order > it > what is the meaning of this error? How to resolve it? could you suggest it -- 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.