Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-08 Thread oggie rob
> Sorry, perhaps I don't quite understand how this is different... > unless you are rendering the field widget manually and somehow adding > extra choices that aren't in the query set passed to the > Model*ChoiceField? There would be one extra choice - the previously selected, and no longer

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-08 Thread Nick Lane
On Aug 9, 5:49 am, oggie rob <[EMAIL PROTECTED]> wrote: > > That could work. The main point of this thread was to see if there are > > use cases for using the default manager for validation instead of the > > query set because I couldn't really think of any - but I'm sure there > > could well be

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-07 Thread Nick Lane
On Aug 7, 6:55 pm, David Danier <[EMAIL PROTECTED]> wrote: > > However, I'm a little confused now. I > > thought the problem was only validation, and not the actual data that > > was added to the choice list. > > The problem is, that validation does not use the actual data of the > choice list. >

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-07 Thread David Danier
> However, I'm a little confused now. I > thought the problem was only validation, and not the actual data that > was added to the choice list. The problem is, that validation does not use the actual data of the choice list. I think doing so may even become a security issue, as people may guess

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-07 Thread oggie rob
> Hmm, I see what you're saying but (using your example) if the employee > is no longer active, wouldn't that mean the field *should* raise a > validation error? If the choices are meant to be limited to only > employees which are active shouldn't the validation prevent the user > from choosing

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-07 Thread Nick Lane
On Aug 7, 4:14 pm, oggie rob <[EMAIL PROTECTED]> wrote: > I'm not sure of the intent, but something to keep in mind is that if > you have previously-valid information and wish to save it again, it > may become invalid. > For example, I have a list of "active" employees for selection in the >

Re: ModelChoiceField's clean() uses default manager instead of query set

2007-08-07 Thread oggie rob
I'm not sure of the intent, but something to keep in mind is that if you have previously-valid information and wish to save it again, it may become invalid. For example, I have a list of "active" employees for selection in the filtered choice field. If I open up some object and hit "Save" after

ModelChoiceField's clean() uses default manager instead of query set

2007-08-06 Thread Nick
The clean() methods in both ModelChoiceField and ModelMultipleChoiceField use a block similar to the following in order to validate the selected choice: try: value = self.queryset.model._default_manager.get(pk=value) except self.queryset.model.DoesNotExist: raise