?????????л?????Χ????django???????request??????????format???????Χ???ú???????????
??????????????????????web??????????????????Χ?????????????в???????Χ????????
????????????model????????????
class book(models.Model):
name = models.CharField(max_length=50?? unique=True)
date = models.DateTimeField()
def __unicode__(self): return self.name
???????????????????request.GET????????Χ???????????
request.GET = {'year_from': 2010?? 'month_from': 1?? 'day_from': 1??
'year_to':2013?? 'month_to': 10?? 'day_to': 1}
????????model?????date??????models.DateTimefield()????????????request?????????????datetime????(????django???????????????)??
import datetime
def filter(request):
if 'year_from' and 'month_from' and 'day_from' and
'year_to' and 'month_to' and 'day_to' in request.GET:
y = request.GET['year_from']
m = request.GET['month_from']
d = request.GET['day_from']
date_from = datetime.datetime(int(y)?? int(m)?? int(d)?? 0?? 0)
y = request.GET['year_to']
m = request.GET['month_to']
d = request.GET['day_to']
date_to = datetime.datetime(int(y)?? int(m)?? int(d)?? 0?? 0)
else:
print "error time range!"