model - Django - concat datetimeField/timeField and compare -


i want compare datefield , timefield in queryset current date. searched hours did not find anything. tried q/f-object no solution, too. , here , hope knows how solve :) - btw. splitting date , time not fault , there no way change datetimefield (too dependencies in other projects).

class model(models.model):     date = models.datefield()     time = models.timefield() 

in mysql like:
select * app_model cast(concat(cast(date char),' ',cast(time char)) datetime) >= now()

thanks suggestions!

you can or'd queryset contraints (q objects):

now = datetime.datetime.now() future_models = model.objects.filter(q(date__gt=now.date()) | (q(date=now.date()) & q(time__gte=now.time()))) 

that selects instances date past today, , instances date today , the time greater or equal current time.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -