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 Peter Sagerson
https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L104 > On Nov 12, 2014, at 1:36 PM, Collin Anderson wrote: > > On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote: > The documentation of ModelAdmin.get_form()[1] demonstrates modifying > self

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

Re: ANN: django-otp and friends: one-time passwords and trusted agents

2013-08-09 Thread Peter Sagerson
I imagine that would work. Generally speaking, if you want to use a multi-page flow to atomically mutate some state (in this case auth status), you're pretty much into form wizard territory. For specific scenarios, there may be workarounds--potentially a bit sneaky and underhanded--that produce

Re: ANN: django-otp and friends: one-time passwords and trusted agents

2013-08-09 Thread Peter Sagerson
st not > dug into the gritty details of the system. > > Any tips on creating a 2 stage approach would be much appreciated. > > On Wednesday, July 3, 2013 1:34:31 PM UTC-7, Peter Sagerson wrote: >> >> I took part of this conversation offline to spare the list from the gory

Re: ANN: django-otp and friends: one-time passwords and trusted agents

2013-07-03 Thread Peter Sagerson
27;s probably out of the scope of what you have right now. I'd > still like like to see something that ties it up nicely. That's basically > what I'm building right now except I don't trust my build to work in anyone > else's setup - although if I have time I'll s

Re: ANN: django-otp and friends: one-time passwords and trusted agents

2013-07-01 Thread Peter Sagerson
tion for Django > but I don't think many people will know where to start when it comes to using > it (myself included). > > On Wednesday, September 12, 2012 1:27:26 PM UTC-7, Peter Sagerson wrote: > I recently released a suite of packages to support two-factor authentication

Re: Filtering queryset using two fields in one model

2009-12-08 Thread Peter Sagerson
Assuming you're using Django 1.1, take a look at: http://docs.djangoproject.com/en/1.1/topics/db/queries/#filters-can-reference-fields-on-the-model On Dec 8, 2009, at 10:18 AM, pbzRPA wrote: > Hi, > > I am not sure if this is a really stupid question but how can you > filter a model by comparin

Re: Admin why deleting related(null=True) objects?

2009-10-07 Thread Peter Sagerson
Yes, Django always cascades deletes. There's talk about providing more options in a future release, but for now it's kind of a problem. I generally find this behavior potentially catastrophic, so I wrote an intermediate model base class that clears all nullable foreign keys before deleting

Re: Menu managements, current URL

2009-09-29 Thread Peter Sagerson
Is request.path[1] what you want? You might also consider basing your menu context on the current view rather than the current URL. I typically define a view decorator that can attach any context information I need to the current request: def page_context(section): def decorator(func):

Re: Permissions independent of models

2009-07-27 Thread Peter Sagerson
The way I solved this was to write a custom auth backend that could evaluate a collection of non-model permissions. By convention, I had one permission per view. Some of these permissions were aliased to corresponding model permissions and some of them were based on other criteria. Essenti