You could set this up as a custom manage.py command and run a cron on that. Gives the advantage of both initiating from outside the app and using Django's DB abstraction layer.
A very simple way to do this would be to put all month text names in order in a tuple. i.e. monthnames = ('jan', 'feb', 'mar', .... ) or however your month names are reflected. (You can actually generate this list by doing a 'for m in' line and pull out the month names but you get what I mean. Then just iterate over the month names more than 6 back from the current position and delete the records. On Oct 8, 10:54 am, Chris Withers <ch...@simplistix.co.uk> wrote: > Tim Chase wrote: > > I wouldn't try to do it from within the web app itself -- > > I'd schedule some wee-hours cron job to do the deletion. > > I plan to, don't worry ;-) > But, I would like to do it from within the Django environment to make it > immune to changes of database... > > > 6mo boundary. Your Month is defined as a string, and I > > don't see any actual date information in it. > > Yeah, an unfortunate artifact of the legacy system I'm replacing. > Months are of the form "September 2009", "August 2009", etc. > How would you represent those in a Django ORM sensible way? > > > In all, I'd just skip Django completely and do something > > like create a quick shell-script to execute the raw SQL and > > schedule it to run monthly > > You guessed right about the database, but that's a luxury I don't have. > The database used may change, so I'd like to do this through the Django > ORM. Does the Django ORM have a sql abstraction layer like sqlalchemy > where I can do the kind of thing you're proposing, or do I need to work > with models? > > 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 -~----------~----~----~----~------~----~------~--~---