如何在 Django 中的特定时间后自动从数据库中删除记录
How to automatically delete records from database after a specific time in Django
我有一个名为 'Complaint' 的模型,其中包含大量条目,如果该条目在数据库中超过 3 天,我想删除该条目。如果有任何指定时间的查询,我该怎么做。我还存储条目的存储时间。这是我的 models.py 文件。
complaint_for = models.CharField(max_length=25, choices=COMPLAINT_CHOICES, default='Misbehave')
name = models.CharField(max_length=50)
created = models.DateTimeField(auto_now_add=True)
我有一个名为 'Complaint' 的模型,其中包含大量条目,如果该条目在数据库中超过 3 天,我想删除该条目。如果有任何指定时间的查询,我该怎么做。我还存储条目的存储时间。这是我的 models.py 文件。
complaint_for = models.CharField(max_length=25, choices=COMPLAINT_CHOICES, default='Misbehave')
name = models.CharField(max_length=50)
created = models.DateTimeField(auto_now_add=True)