On Wed, Apr 15, 2009 at 5:30 PM, Karen Tracey <kmtra...@gmail.com> wrote:
> On Wed, Apr 15, 2009 at 5:18 PM, Darrell Silver > <darrellsil...@gmail.com>wrote: > >> >> I've been searching high and low for an answer to this question, but >> haven't had any luck. If the database data changes somehow, my django >> process, happily running, doesn't see the data if it's already got a >> cache someplace. I believe this cache is stored in QuerySet. >> >> The closest conversation I've found (http://groups.google.com/group/ >> django-users/browse_thread/thread/214719757b8831c2/c05a51eb074151af? >> hl=en&#c05a51eb074151af<http://groups.google.com/group/%0Adjango-users/browse_thread/thread/214719757b8831c2/c05a51eb074151af?%0Ahl=en&#c05a51eb074151af>) >> suggested using _clone(). But that seems to >> have no effect. >> >> Here's an example from the command line: >> >> >>> >> >>> from project.mylib import MyModel >> >>> qs=MyModel.objects.all() >> >>> qs.count() >> 5L >> >>> # So far so good. >> >>> # Wait here while I manually add a 6th row to the mysql table >> directly, outside of django. >> >>> qs.count() # database now out of sync w/ qs which should be 5L b/c the >> results of qs are cached. >> 5L >> >>> qs2=qs._clone() >> >>> qs2.count() # after the _clone, this should now check the DB again and >> be 6L >> 5L >> >>> raise "Darn! I wish I could ask the qs object to go back to the db for >> all further queries." # D'oh. >> >>> >> >> Thanks in advance! >> > > What database are you using? You may be seeing transaction isolation > effects similar to what is described in this thread: > > > http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d > > Karen > > > > That is most likely the case, as the results of count() are *not* cached in the way queryset results are. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---