I want to run a script outside of the django server for maintenance purposes, but it still accesses some of the models. The problem is that I can't seem to get the model object to reload it's data from the DB - it always seems cached.
# Setup django. import project.settings from django.core.management import setup_environ setup_environ(project.settings) from project import models import time while True: obj = models.Object.objects.get(id=1) print 'obj.status: %s' % obj.status time.sleep(1) Theoretically the line "obj = models.Object.objects.get(id=1)" should reload a new copy of the object with id=1 each time. But when I run this script, the values never change - they are whatever they were when the object was first loaded, and do not change (regardless of what's in the DB) until the next time I run the program. My understanding is that this is how you reload an object after changing it (after .save(), etc). But it's clearly not working in my case. Am I doing something wrong? How do I force the object to be reloaded from the database? Thanks! -- 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.