Re: Odd problem: some database updates do not appear on other pages until server restart

2017-01-16 Thread Fred Stluka
Bob, On 8/19/16 8:02 AM, bobhaugen wrote: > On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote: > > Moving the call to with_user to form.__init__ solved the problem in the form ModelChoiceField. > > These questions remain

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread bobhaugen
Michal, thanks for following up. I'll try your suggested code from your other response upthread and see if it solves the problem as well as the form.__init__. And do more digging about how Python does things. I am a self-taught programmer who focuses on community economic development and I

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread Michal Petrucha
On Fri, Aug 19, 2016 at 02:38:02PM +0200, Michal Petrucha wrote: > On Fri, Aug 19, 2016 at 05:02:39AM -0700, bobhaugen wrote: > > On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote: > > These questions remain unanswered, although I intend to do a bunch more > > testing: > > >

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread bobhaugen
On Friday, August 19, 2016 at 7:38:45 AM UTC-5, Michal Petrucha wrote: > > Honestly, I'm not sure what exactly you're asking here. Your > implementation of ``with_user`` was hard-wiring a queryset filter > based on the state of the database at the time ``with_user`` was > called. The rest is

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread Michal Petrucha
On Fri, Aug 19, 2016 at 05:02:39AM -0700, bobhaugen wrote: > On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote: > > > > Could you show us the code of with_user? Maybe it does not return an > > unevaluated queryset? > > > > > def with_user(self): > all_agents =

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread ludovic coues
You were calling the method in the class definition. The class is "defined" when the module is imported. That's why things where "cached". Module is imported only once. The init method on the other hand is called every time an instance of the class is created. I believe that method will be called

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread bobhaugen
On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote: > > Could you show us the code of with_user? Maybe it does not return an > unevaluated queryset? > > def with_user(self): all_agents = EconomicAgent.objects.all() ua_ids = [] for agent in

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-19 Thread Michal Petrucha
On Thu, Aug 18, 2016 at 11:57:40AM -0700, bobhaugen wrote: > On Thursday, August 18, 2016 at 1:34:29 PM UTC-5, Tim Graham wrote: > > > > I'd guess you're doing a query for the form field's choices at the module > > level which will be executed once and cached for as long as the server > > runs.

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Yes, that's what I did. It worked for the form field. But, still, how pervasive is this behavior? (That was the question in the message you answered). On Thursday, August 18, 2016 at 2:18:00 PM UTC-5, Sergiy Khohlov wrote: > > Hello, > This is trivial mistake. Use form.__init__ if you would

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread Sergiy Khohlov
Hello, This is trivial mistake. Use form.__init__ if you would like to change it dynamically 18 серп. 2016 22:14 "bobhaugen" пише: > Also, how pervasive is this behavior? Does it affect all querysets > generated by model methods? I do that all over the place. This could be

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Also, how pervasive is this behavior? Does it affect all querysets generated by model methods? I do that all over the place. This could be bug heaven! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Looks like it works if I "specify queryset=None when declaring the form field and then populate the queryset in the form’s__init__() method:" Does that make sense to you? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
On Thursday, August 18, 2016 at 1:34:29 PM UTC-5, Tim Graham wrote: > > I'd guess you're doing a query for the form field's choices at the module > level which will be executed once and cached for as long as the server > runs. See if >

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread Tim Graham
I'd guess you're doing a query for the form field's choices at the module level which will be executed once and cached for as long as the server runs. See if https://docs.djangoproject.com/en/stable/ref/forms/fields/#fields-which-handle-relationships helps, otherwise please post the code for

Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
I'm running django 1.8.14, I have an odd problem, that I have reproduced both locally using runserver and sqlite, and also using Apache with Postgres. I create a new model instance on one page, and go to another page where that same object should appear in a form selection list. It does not.