query django date -


in ,models have

         class pick:           t1 =models.datetimefield(auto_now_add=true) 

in views.

the date variable in format s="2010-01-01"

         how o query date            pick.objects.filter(t1=date(s)) 

datetime.date() expected arguments datetime.date(year, month, day), creating date object s won't work. can use date string directly in filter

picks_at_date = pick.objects.filter(t1=s) 

or when try find before or after date

picks_before_date = pick.objects.filter(t1__lt=s) 

or

picks_after_date = pick.objects.filter(t1__gt=s). 

django's "making queries" docs @ retrieving specific objects filters has examples on making queries date fields well.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -