On Wed, Oct 13, 2010 at 4:38 AM, Mattias Linnap <matt...@linnap.com> wrote:

> Hi Django users,
>
> I'm building an application with Django, and I need some database
> changes to occur at certain times in the future - independently of any
> web request. Things like cleaning up expired sessions, deleting
> expired user actions, etc.


I use cron to do those kinds of things.   The scripts start with this:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
from my_project.models import *

And then they have access to whatever I need.  Actually, instead of
importing *, I usually just import the models I need for that script.

I like keeping all that housekeeping stuff separate from the web app.

Nick

-- 
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=en.

Reply via email to