I'm looking for a way to combine a custom date value and a time field in django. My model only contains a time field. Now I have to annotate a new field combining a custom date and the time field. I thought the following code will slve my problem, but it only gives the date value. TimeField is ignored.
-- Please advise the right way to solve this issue.
class MyModel(models.Model): my_time_field = TimeField() custom_date = datetime.today().date() objects = MyModel.objects.annotate( custom_datetime=Func( custom_date + F('my_time_field'), function='DATE' ) )You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6750f328-a9c6-4807-add8-839f37779ff2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment