menudeleted = MessMenu.objects.filter( day__lt = timezone.now())
    for m in menudeleted:
        m.delete()
menu = MessMenu.objects.all()

use basic comparison filter 
<https://code.djangoproject.com/wiki/BasicComparisonFilters> to filter the 
dates


On Sunday, November 6, 2016 at 12:01:20 AM UTC+5:30, YOGITHA A N wrote:
>
> 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/9b01d53c-1a96-4eab-91e1-dc9d6be51eeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to