i think maybe you need a schedule job to delete the model.
you can mark the model with a ctime, and check whether any model with ctime
7 days from now and then delete it.
在 2016年11月6日星期日 UTC+8上午2:31:20,YOGITHA A N写道:
>
> So here are my models:
>
> * class Mess(models.Model):*
> muser = models.OneToOneField(User)
> MESS_NAME = (('GH','girls hostel top mess'),
> ('IH','girls hostel down mess'),
> ('MM','Mega mess'),
> ('FB','First Block mess'),
> ('SB','Second Block mess'),
> ('TB','Third Block mess'),
> )
> mess_name = models.CharField(max_length=25, choices =
> MESS_NAME,primary_key=True)
> per_day_cost = models.IntegerField()
> def __str__(self):
> return self.mess_name
>
> *class MessMenu(models.Model):*
> mess_name = models.ForeignKey(Mess)
> day = models.DateField()
> morning = models.TextField()
> afternoon = models.TextField()
> snacks = models.TextField()
> dinner = models.TextField()
> def __str__(self):
> return self.mess_name
>
> Once i create an object in MessMenu I want django to delete that object
> after 7 days. Please let me know how to delete a certain object after a
> given period of time.
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/dd363861-c507-4775-a709-deef03ef2aab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.