When I had to do this kind of tasks, I've added a new management command and
run it from the cron (or manually any time you need it, with params, etc).
You can run it calling

python manager.py miCommand parameters

The official documentation is not very complete, which is rare, but there
are some information on the web.
http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
http://oebfare.com/blog/2008/nov/03/writing-custom-management-command/

On Tue, Oct 20, 2009 at 4:48 PM, Chris Withers <ch...@simplistix.co.uk>wrote:

>
> Shawn Milochik wrote:
> > I know this doesn't answer the hard part of your question, but here's
> > a simple way I delete old stuff from a database via an external script
> > that's run by cron:
> >
> > Item.objects.filter(date_updated__lte = datetime.now() - timedelta
> > (days = 30)).delete()
>
> Yep, that's prettymuch what I ended up writing. Wow, Django's ORM
> expressions are ugly compared to SQLAlchemy ;-)
>
> > old. As for your complicated references, assuming you don't have
> > cascading deletes happening automatically, you may have to do an
> > objects.filter(),
>
> Well, cascading deletes do happen automatically with Django, so no
> problem there...
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
>            - http://www.simplistix.co.uk
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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