Thursday, July 26, 2018

Re: how to find activities dues for today and tommorow

Thank you Julio :)

On Thu, Jul 26, 2018 at 12:53 AM, Julio Biason <julio.biason@azion.com> wrote:
Hi Deepak,

You could set up another model to track when something should be done to the tree; something like this:

class Tree(models.Model):
    ...
    planted_date = models.DateField()

class Reminder(models.Model):
    tree = models.ForeignKey(tree)
    when = models.DateField()
    what = models.CharField()
    done = models.BooleanField()

So, when you create a tree, you get the current date and create the entries on the Reminder model. Somewhere, you can get the list of reminders with something like

to_do = Reminder.object.filter(Q(tree=tree_in_view) & Q(when_lte=datetime.datetime.today()) & Q(done_ne=True))

And throw this in the view -- it basically says "give me all the reminders for the tree I'm looking at in this point (say, you have a page for each tree, so this is the tree id), in which the reminder is from a date equal or before today (in case you don't want to show reminders for dates in the future) and which are not done (which you should also provide a way so the user can mark the reminder as "done" and not be bothered with it again).


On Wed, Jul 25, 2018 at 3:07 PM, deepak madan <deepakms.real@gmail.com> wrote:
suppose a model for the tree which is planted on some days. The second model has activities dues to be done after some regular interval like 1) giving fertilizer A after 5 days 2) giving fertilizer B after 15 days.
My question is when this 5th or 15th days arrives, to design a reminder page to show activities dues today and tomorrow.

Please help
Whats logic in views.py

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/dab4e417-4f94-4712-83d9-8c447bafc922%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101  |  Mobile: +55 51 99907 0554

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAEM7gE2TpCpVB8MKb6Yu_uiKSpNc%3DZRxYk5vs-q6aKaG-c8zZA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAMwf7ZAJhp2xgKmVs2%2BFbveYmLfAa6FDQedG3mrXhej-%3D2g6vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment