Presuming deleted sometime on the day is close enough, write a management command that queries for items beyond their expiration and deletes them. Run this script nightly using cron, or you O/S's equivalent.
Bill On Sun, Aug 28, 2011 at 3:09 PM, Goran <thego...@gmail.com> wrote: > I have model with DateTimeField where I store date when object will be > deleted. > > class Something(models.Model): > ... > end_date = models.DateTimeField(editable=False, blank=True, > null=True) > > after some request my app store future date in that field using: > > something.end_date = datetime.datetime.now() + timedelta(days=60) > something.save() > > Now I need the easy way to delete it from db when this date come and > need advice from you. To use cron job to check all once a day or to > check on every queryset like > > today = datetime.datetime.now() > for_delete = Something.objects.all().filter(end_date >= today) > for x in for_delete: > x.delete() > > I expect a lot of page requests so I don't like example below. Does > anyone have some better way to suggest? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.