Re: Update model field after a certain period

2016-01-06 Thread 'Tom Evans' via Django users
On Wed, Jan 6, 2016 at 9:39 AM,   wrote:
> I have a Django model with a Boolean field called New. During the model
> creation it's set to True, but I want it to be updated automatically to
> False after a certain period (1 month post creation for example). Can I use
> signals here?

Another option is to replace the field with a "created" date time, and
add a computed property called "new" that tests to see whether it is
old or not.

Cheers

Tom

-- 
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+unsubscr...@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/CAFHbX1%2B8AJYJbeq9Z4VgBH%3DQcLTY17dhJg6gCfVRDfVnaf9evg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update model field after a certain period

2016-01-06 Thread Mark Harley
One option would be to create a custom management command 
(https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/) 
that checks for models with a `created_at < now - 1month`. You could then 
run this, say once a day, using crontab 
(https://help.ubuntu.com/community/CronHowto). Here created_at is a 
`datetime` field with `auto_now_add=True`.

On Wednesday, 6 January 2016 13:07:30 UTC, salma.ess...@gmail.com wrote:
>
> I have a Django model with a Boolean field called New. During the model 
> creation it's set to True, but I want it to be updated automatically to 
> False after a certain period (1 month post creation for example). Can I use 
> signals here?
>

-- 
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+unsubscr...@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/b88f2d50-b3ea-4102-aeeb-de5d41979aa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Update model field after a certain period

2016-01-06 Thread salma . essalmani . wbc
I have a Django model with a Boolean field called New. During the model 
creation it's set to True, but I want it to be updated automatically to 
False after a certain period (1 month post creation for example). Can I use 
signals here?

-- 
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+unsubscr...@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/b8a56ab6-cf56-4330-a37d-096681b9ff1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.