Re: Modifying a ModelAdmin instance at runtime

2014-11-17 Thread Collin Anderson
Ohh. Yup. My bad :) On Wednesday, November 12, 2014 5:01:03 PM UTC-5, Peter Sagerson wrote: > > I agree that setting self.exclude will set the instance attribute, thus > hiding the class attribute of the same name. However, it appears that a > given AdminSite instantiates each registered ModelAd

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
> Your analysis is entirely correct, as far as I can tell. Setting > attributes on `self` in a per-request method of a `ModelAdmin` is not > concurrency-safe, and it should not be recommended or demonstrated in > the docs. If you'd be willing to file a bug (or, better, a PR) to fix > this documenta

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Carl Meyer
Hi Peter, On 11/12/2014 10:59 PM, Peter Sagerson wrote: > I agree that setting self.exclude will set the instance attribute, > thus hiding the class attribute of the same name. However, it appears > that a given AdminSite instantiates each registered ModelAdmin once > at registration time.[1] The

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
I agree that setting self.exclude will set the instance attribute, thus hiding the class attribute of the same name. However, it appears that a given AdminSite instantiates each registered ModelAdmin once at registration time.[1] The default AdminSite itself is a module global. Thus, any long-ru

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Collin Anderson
On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote: > > The documentation of ModelAdmin.get_form()[1] demonstrates modifying > self.exclude in order to modify the add/change form on a per-request basis. > However, looking at django.contrib.admin, it seems clear that ModelAdmin i

Modifying a ModelAdmin instance at runtime

2014-11-11 Thread Peter Sagerson
The documentation of ModelAdmin.get_form()[1] demonstrates modifying self.exclude in order to modify the add/change form on a per-request basis. However, looking at django.contrib.admin, it seems clear that ModelAdmin is instantiated when it's installed, not for every request. It also doesn't a