On Nov 12, 7:51 am, Denis Bahati <djma...@gmail.com> wrote:
> Hi All,
>
> I have a field with an integer value which needs to be incremented
> every time any user updates its status within a week. If that week has
> passed it should insert a new row. Now i was trying to figure out but
> didn't get any concept on how to go through. Please any idea?

You don't mention how you're tracking dates or weeks (is that a
related model, or... ?) but this would be the general idea:

- get the timestamp of the last update to that field and compare it to
the current timestamp

if ... : #  interval is less than a week:
    foo = MyModel.objects.get(...)
    foo.counter = foo.counter + 1
else : interval is more than a week
    foo = MyModel()
    foo.counter = 1

foo.save()

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.


Reply via email to