Re: Custom Validation on Inline Generic Foreign Key

2011-08-31 Thread John
I went ahead and hardcoded checks for fields that as of today I know will only be in one of the models. I would still love to hear any cleaner solutions if anyone has them. On Aug 26, 10:12 am, John wrote: > Any ideas? > > In the inline model's validation I could hardcode checks for data that > I

Re: Custom Validation on Inline Generic Foreign Key

2011-08-26 Thread John
Any ideas? In the inline model's validation I could hardcode checks for data that I expect will only be in one of the models, but that does not seem like the best option. I am still hoping for a simpler alternative to this. Thanks. -- You received this message because you are subscribed to the

Re: Custom validation in model

2011-01-26 Thread Shawn Milochik
Overriding the clean method of the modelform is the way to go. If you're getting an error about not having 'cleaned_data,' it could be because your custom clean method doesn't return anything -- you're responsible for returning it if you override it that method. Shawn -- You received this me

Re: Custom validation in model formset

2010-10-11 Thread ringemup
try this... from django.forms import ValidationError ... for form in self.forms: ... raise ValidationError('whatever') On Oct 11, 1:32 pm, Duane Hilton wrote: > Changing forms to form brings a new error: > > *Exception Value: 'CandidateFeedForm' object has no attribute > 'Validation

Re: Custom validation in model formset

2010-10-11 Thread Duane Hilton
Changing forms to form brings a new error: *Exception Value: 'CandidateFeedForm' object has no attribute 'ValidationError'* Below is the view that is using the BaseCandFormSet code that I included in the original message. Maybe something is wrong in it? Thanks in advance for your suggestions. I'v

Re: Custom validation in model formset

2010-10-11 Thread Jonathan Barratt
? 11 ?.?. 2553 23:44 Duane Hilton ?: > Hi all, > > I'm trying to do some custom validation on a model formset, but I'm > not having good luck. Thank you in advance for your suggestions ... > > In my views, I have: > > class BaseCandFormSet(BaseModelFormSet): >def clean(self): >

Re: Custom Validation in Django 1.0.2 Final

2009-04-07 Thread Harish
Hi, Malcolm... Thanks a lot... It is working Now.. On Apr 7, 12:05 pm, Malcolm Tredinnick wrote: > On Mon, 2009-04-06 at 23:58 -0700, Harish wrote: > > [...] > > > If salary is found negative it displays the error message in beginning > > of the form(that is after the message 'Please correct

Re: Custom Validation in Django 1.0.2 Final

2009-04-07 Thread Malcolm Tredinnick
On Mon, 2009-04-06 at 23:58 -0700, Harish wrote: [...] > If salary is found negative it displays the error message in beginning > of the form(that is after the message 'Please correct the error below. > '). Actually it should display the error message in the 'Salary' > section > > I think, I am m

Re: Custom validation in view?

2009-04-04 Thread Paddy Joy
Thanks Alex that's exactly what I was looking for! Paddy On Apr 5, 10:40 am, Alex Gaynor wrote: > On Sat, Apr 4, 2009 at 8:37 PM, Paddy Joy wrote: > > > I need to validate some data from a form however I need access to the > > request object as the data validation will be different depending o

Re: Custom validation in view?

2009-04-04 Thread Alex Gaynor
On Sat, Apr 4, 2009 at 8:37 PM, Paddy Joy wrote: > > I need to validate some data from a form however I need access to the > request object as the data validation will be different depending on > the logged on user. > > What is the preferred method for this type of validation? Can i > validate th

Re: custom validation (clean_) based on image height and width

2009-03-19 Thread Michael A. Repucci
Perfect. Thank you! On Thu, Mar 19, 2009 at 3:36 PM, Alex Gaynor wrote: > > > On Thu, Mar 19, 2009 at 3:31 PM, Michael Repucci wrote: > >> >> I'm struggling with what seems like should be a very straightforward >> task. I have a model with a field named image of type ImageField, and >> I'd like

Re: custom validation (clean_) based on image height and width

2009-03-19 Thread Alex Gaynor
On Thu, Mar 19, 2009 at 3:31 PM, Michael Repucci wrote: > > I'm struggling with what seems like should be a very straightforward > task. I have a model with a field named image of type ImageField, and > I'd like to do custom validation via the model form's clean_image > method based on the height

Re: Custom validation

2008-07-22 Thread Alex Rades
Well, as i said, overriding save() does not provide the ability to raise an error which is field-specific. What i want to do, was possible with validator_list. I actually don't understand why this functionality has been removed. On Mon, Jul 21, 2008 at 7:59 PM, Jeff FW <[EMAIL PROTECTED]> wrote:

Re: Custom validation

2008-07-21 Thread Alex Rades
The point is that i see this validation as tied to the model, not to a specific form. For me this as an integrity check, something which should be done at model level. On Mon, Jul 21, 2008 at 3:20 PM, Jeff FW <[EMAIL PROTECTED]> wrote: > > Sounds like you're looking at the oldforms documentation-

Re: Custom validation

2008-07-21 Thread Jeff FW
Sounds like you're looking at the oldforms documentation--that's all been deprecated. Read this instead: http://www.djangoproject.com/documentation/newforms/ Especially this part: http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation -Jeff On Jul 21, 8:14 am, "A

Re: Custom validation for models in admin

2007-10-04 Thread jr
The following did it for me: from django import newforms as forms class yourForm(forms.BaseForm): ... def clean(self): "do your custom validation here" return self.cleaned_data does it for me. Clean is called automatically e.g. by ...is_valid(). hope it helps. jr On Sep 11, 10

Re: Custom validation for models in admin

2007-10-03 Thread Rob Slotboom
Hi Mike, I have the same problem with my model. (Link below) Reading your "points to a .validate() on the model" raises the following question. Have you tried it? http://groups.google.com/group/django-users/browse_thread/thread/bd2b2c24f3879690 --~--~-~--~~~---~--~-

Re: Custom validation for models in admin

2007-09-11 Thread Mike H
Sorry, I should have said that I'd already tried a custom validator. Unfortunately, validators don't provide the functionality I need. I need to check in the database to see if there are any pages, other than the one I am saving, that have start and end dates that overlap with the one I am sa

Re: Custom validation for models in admin

2007-09-11 Thread Collin Grady
You need to write a validator and use validator_list in the field attributes to do custom validation in admin. http://www.djangoproject.com/documentation/model-api/#validator-list --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G