Expiring Objects

14 views
Skip to first unread message

Faris Sbahi

unread,
Nov 22, 2016, 2:18:42 AM11/22/16
to Django REST framework
I've been trying to tackle the question of having object relations expire after a set period of time using Django REST framework. Here's the general idea:

I have a view that presents a list of objects i.e. accepts GET requests to retrieve information about this list:

  • These objects have a one-to-many (foreign key) relationship with another type of object
  • The other type of object provides useless information after 24 hours

Therefore, I'd like to be able to have these related objects disappear from the view after one day. I figure there are three possible solutions, of which I'm not sure how to implement:

  1. Have relationship expire after 24 hours
  2. Related object deletes after 24 hours
  3. View filters against related objects that were created >24 hours ago

Has anyone carried out something similar in the past and could provide a code snippet that demonstrates performing said implementation? Thanks for your help. 
Reply all
Reply to author
Forward
0 new messages