On Fri, 2006-10-27 at 06:22 -0700, doubtintom wrote: > I'm using generic view create_update.update_object to edit items > selected from a generic list_detail.object_list. Edits to items work > very well, they hit the database as soon as I submit the form in my > html template. I know because I inspect the mysql table directly. So > far so good. > > One of my fields is a "Done" checkbox. The queryset used by my > list_detail.object_list is generated by a overriding get_query_set in a > Manager in my model which contains custom sql that filters out records > which are marked "Done". However, after submitting the form and getting > "post_save_direct"ed back to the list, Django does not refresh the list > by dropping the updated "Done" field. That is, I want the queryset to > match the database and the record I just marked "Done" should drop off > the list, but it doesn't. Refreshing the browser doesn't do anything. > > So there seems to be some sort of caching going on. I haven't set up > caching in this project. I have learned by experimenting that > restarting the Django server, or even saving the model file, causes my > custom sql to refresh the queryset, becuase the html form suddenly > "Knows" about the database change, and drops the "done" row upon > browser refresh.
It sounds like your queryset is being computed once and then, as expected, it is caching the results. If you want it to refresh itself, you need to create a new queryset. By design, querysets only talk to the database once. I cannot suggest a specific improvement, because you haven't given any details of how/where you are creating the queryset or how you are passing the information into the form. If you could give some details on where the queryset is being constructed and how you are giving the data to the form (a short example might help), we can probably give some specific recommendations. Note that the reason you are seeing different behaviour with mod_python will be because you aren't always running the same instance of the code: so the queryset will be constructed once in each thread (and then cached in that instance). You will eventually see the same problem there. Again, querysets are meant to behave like this for efficiency; it isn't a flaw in the development server or a bug in Django. It just means you need to refresh them explicitly (by creating a new instance) when you need new results. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---