开发者

How to make posted text expire in django?

im wondering how to make some posted texts be deleted on some certain date/time on a django site. Is it done with scripts to delete content i开发者_高级运维n the database?


Yes, this is what management commands are for. You start these usually with a cronjob.

Further information: http://docs.djangoproject.com/en/dev/howto/custom-management-commands/


I believe the most straightforward way to go about this is to hide the data to the clients. This is done by adding some expiration_date field to the model. Then you may have a custom manager that looks like:

class ValidObject(Manager):
    def filter_valid(self):
        return self.filter(expiration_date__gt=datetime.date.today())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜