I am very sorry for this newbie question... I have data stored in the database (mysql) as tuples. These data look like (datetime, frequency, current) ... etc.
How to retrieve all data from database at a certain time? for example, I want to get all the saved data at "2015-9-9 8:23:10"
can you show your model.
You can add created and updated fields to your model and query them to retrieve your data
class Test(models.Model):
created = models.DateTimeField(
default=django.utils.timezone.now, blank=True)
updated = models.DateTimeField(
default=django.utils.timezone.now, blank=True)
you can query the Test model then using the time you want
Test.objects.all(created=datetime.now())
如果datetime field
是创建数据的日期,您可以执行以下操作:
Test.objects.all(datetime__gte=timezone.now)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.