Suggestions for using a custom pre-login signal to perform custom validation?

2018-03-16 Thread Stodge
I want to add a custom pre-login signal (user_logging_in) that fires just before Django's login function is called. This is a snippet from our custom account app that may explain what I want: from django.contrib.auth import login as real_login def custom_login() # Allow other apps to per

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-06 Thread Dilip M
t;> dev = models.EmailField() >>>> qa = models.EmailField() >>>> cc = models.MultipleEmailField() >>>> >>>> forms.py: >>>> >>>> class RecipientsForm(forms.**ModelForm): >>>> >>>

RE: Help with Custom model field and custom validation for EmailField()

2012-11-03 Thread bb6xt
Hi, If all u nid is a field whose value is a comma separated list of emails den u dont nid a custom field at all. All u nid is a gud ol CharField. Just set it like so: emails=models.CharField(max_length=500, validators=[multi_email_validator,]). here is what multi_email_validator looks like: from

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-03 Thread Chris Pagnutti
> 2. Create new model custom field MultipleEmailField(), which would split >>> emails separated by comma and uses modified validation of >>> models.EmailField() done in step 1. >>> >>> I am going through docs, but not able to figure out how to put things >

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-03 Thread Dilip M
leEmailField(), which would split >> emails separated by comma and uses modified validation of >> models.EmailField() done in step 1. >> >> I am going through docs, but not able to figure out how to put things >> together! Here is what I understood. >> >> M

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-02 Thread Chris Pagnutti
a and uses modified validation of > models.EmailField() done in step 1. > > I am going through docs, but not able to figure out how to put things > together! Here is what I understood. > > MultipleEmailField() should go in /fields.py. But how to > make it to run

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-02 Thread Chris Pagnutti
ilField(), which would split > emails separated by comma and uses modified validation of > models.EmailField() done in step 1. > > I am going through docs, but not able to figure out how to put things > together! Here is what I understood. > > MultipleEmailField() should g

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-02 Thread Dilip M
fied validation of >> models.EmailField() done in step 1. >> >> I am going through docs, but not able to figure out how to put things >> together! Here is what I understood. >> >> MultipleEmailField() should go in /fields.py. But how to >> make it to run defa

Re: Help with Custom model field and Custom validation for EmailField().

2012-11-02 Thread Chris Pagnutti
s modified validation of > models.EmailField() done in step 1. > > I am going through docs, but not able to figure out how to put things > together! Here is what I understood. > > MultipleEmailField() should go in /fields.py. But how to > make it to run default validation

Help with Custom model field and Custom validation for EmailField().

2012-11-02 Thread Dilip M
validation of models.EmailField() done in step 1. I am going through docs, but not able to figure out how to put things together! Here is what I understood. MultipleEmailField() should go in /fields.py. But how to make it to run default validation of models.EmailField() and than do custom

Re: Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread Tomas Neme
> Ah. I think the method is overriding the edit page. In other words, you have > click on the editpage to see the effect of my fail code. So it doesn't > trigger if you are on the list view page. Does anyone know what to do with > the editable submission? > It should use the same clean_ method, sho

Re: Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread dd
Ah. I think the method is overriding the edit page. In other words, you have click on the editpage to see the effect of my fail code. So it doesn't trigger if you are on the list view page. Does anyone know what to do with the editable submission? It should use the same clean_ method, shouldn't

Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread dd
Django has list_editable. I need to edit is_active flag. class MyUserAdminForm(ModelForm): class Meta: model = User def clean_is_active(self): # do something that validates your data print ' I am here... ' print self.cleaned_data print self cla

Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread John Yeukhon Wong
Django has list_editable. I need to edit is_active flag. class MyUserAdminForm(ModelForm): class Meta: model = User def clean_is_active(self): # do something that validates your data print ' I am here... ' print self.cleaned_data print self cla

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

Custom Validation on Inline Generic Foreign Key

2011-08-23 Thread John
Hi there, I am writing an app with Django where I have a model with a generic foreign key. I am looking to do some validation on this model based on the content_type of the generic foreign key. When I am modifying this model on its admin page, I am able to easily determine the content_type because

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

Custom validation in model

2011-01-26 Thread Mario8k
o use custom validation to the admin, like suggest in http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin. But i think that is better to have a method to validate, inside model logic, as suggested in an old thread http://groups.google.com/group/django-

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(Base

Custom validation in model formset

2010-10-11 Thread 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): super(BaseCandFormSet, self).clean() f

Re: inlineformset_factory - minimum number of completed forms and custom validation

2010-06-19 Thread ALJ
... sorry ... I forgot to use formset.non_form_errors() -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@g

inlineformset_factory - minimum number of completed forms and custom validation

2010-06-19 Thread ALJ
Can anyone point me in the right direction regarding customer validation of forms via an inlineformset_factory? I want to make sure at least one form is completed and that no two forms have the same date. (I have to admit, I'm getting confused by how all the different classes relate to each other)

Custom Validation on Models

2010-05-18 Thread hovo
Hi, I am new to django, and got some problems on models validation. I have the following two models: class A(models.Model): ... class B(models.Model): key_field = models.ForeignKey(A) ... bool_field = models.BooleanField(default=False) I want to add a validation rule in model B o

change inlines fields and custom validation in the admin

2010-03-27 Thread pablo
I'll add a ModelMultipleChoiceField to the parent instance form and validate it dynamically. How can I iterate over all the the m2m instances and move the m2m children to the parent field? What function do I need to override to achieve this? What function do I need to override for custom validation of an inlin

custom validation for an inline formset, howto?

2010-02-24 Thread dan levine
I am trying to perform custom validation on an inline formset. The docs indicate that custom formset validation should go through a custom clean method: http://docs.djangoproject.com/en/1.1/topics/forms/formsets/#custom-formset-validation but the clean method doesn't get called for my ins

Re: Can I have custom validation in the admin change_list form when using ModelAdmin.list_editable?

2009-07-29 Thread Vasil Vangelovski
That works, thanx. On Thu, Jul 30, 2009 at 12:07 AM, Alex Gaynor wrote: > > On Wed, Jul 29, 2009 at 5:05 PM, Vasil > Vangelovski wrote: >> >> Is it possible to define custom validation for the form in the admin >> change list when using ModelAdmin.list_e

Re: Can I have custom validation in the admin change_list form when using ModelAdmin.list_editable?

2009-07-29 Thread Alex Gaynor
On Wed, Jul 29, 2009 at 5:05 PM, Vasil Vangelovski wrote: > > Is it possible to define custom validation for the form in the admin > change list when using ModelAdmin.list_editable? > > > > Yes, get_changelist_form, and get_changelist_formset: http://code.djangoproject.com

Can I have custom validation in the admin change_list form when using ModelAdmin.list_editable?

2009-07-29 Thread Vasil Vangelovski
Is it possible to define custom validation for the form in the admin change list when using ModelAdmin.list_editable? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

How to do custom validation of models ?

2009-06-09 Thread Frédéric Hébert
Hi all, I have two models related with a foreign key like these : CODE --- class Reservation(models.Model): some fields here ... class Periodicite(models.Model): some fields here # rep_opt is a fake suite of bits, where each bit re

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

Custom Validation in Django 1.0.2 Final

2009-04-06 Thread Harish
Hi Folks, I am wrote a simple application in djang0 1.0.2 to check the custom validation. I will past the model.py and admin.py code here. model.py --- from django.db import models from django.contrib import admin from django import forms class Personal(models.Model): firstName

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

Custom validation in view?

2009-04-04 Thread Paddy Joy
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 thee data in the view and manually set the form field errors? Pa

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

2009-03-19 Thread Michael A. Repucci
mage of type ImageField, and >> I'd like to do custom validation via the model form's clean_image >> method based on the height and width (in pixels) of the image. >> >> If I just grab the image object from the cleaned_data dictionary it >> doesn't have a

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 &

custom validation (clean_) based on image height and width

2009-03-19 Thread Michael Repucci
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 and width (in pixels) of the image. If I just

Re: Help with adding custom validation to the admin

2009-03-12 Thread Vincent
On Mar 12, 10:16 am, Vincent wrote: > Thanks Alex. > > I spent the better part of my day yesterday pouring over both of those > pages prior to posting a request for help here. I think part of the > problem is that I only loosely understand the whole model, form, view > paradigm and am therefore

Re: Help with adding custom validation to the admin

2009-03-12 Thread Vincent
On Mar 11, 6:56 pm, Alex Gaynor wrote: > For additional validation you should provide a custom > form:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form > > and to set the fields automatically you should use the save_model > hook:http://docs.djangoproject.com/en/dev/ref/contrib/admin

Re: Help with adding custom validation to the admin

2009-03-11 Thread Alex Gaynor
On Wed, Mar 11, 2009 at 5:42 PM, Vincent wrote: > > Hi all: > > I am just getting started with Django and could really use some > initial help. My first hurdle is this: I would like to have the act of > choosing a file automatically propagate several of fields of my model. > Bellow is an example

Help with adding custom validation to the admin

2009-03-11 Thread Vincent
Hi all: I am just getting started with Django and could really use some initial help. My first hurdle is this: I would like to have the act of choosing a file automatically propagate several of fields of my model. Bellow is an example of the model of interest here: ##models.py from django.db imp

Custom validation for inline formset in Admin

2009-03-11 Thread ljholish
I have a UserProfile related to auth's User model with a couple of extra date fields, start_date and end_date. I would like one and only one UserProfile that is editable inline with the parent User model in my Admin app. This part is working, but I would also like to do custom validation o

Re: newform-admin: custom validation (multiple fields)

2008-11-24 Thread Alessandro Ronchi
2008/5/1 [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > Thanks Felix. I did use the Form.clean() for my validation accross > multiple fields. There is an open ticket for the non_field_errors() > not being called withing the change_form.html template. > http://code.djangoproject.com/ticket/6809 I need

Re: How to add custom validation to inline admin forms, overriding clean(self) or clean_FIELD(self) doesn't work.

2008-10-23 Thread Karen Tracey
a warning). > But when I try to add custom validation methods to the inline form (in > the same way I would for a typical ModelForm, via clean(self) method) > the validator never gets called... > > Can anyone point me in the right direction here, maybe there is > another class or m

How to add custom validation to inline admin forms, overriding clean(self) or clean_FIELD(self) doesn't work.

2008-10-23 Thread Jacob Rigby
I have a custom ModelForm with a TabularInline child form. I can edit and save without problems, and simple field validation is working (if a required field is missing from the inline form it shows a warning). But when I try to add custom validation methods to the inline form (in the same way I

Re: Admin field custom validation

2008-09-29 Thread David Reynolds
On 21 Sep 2008, at 8:11 pm, [EMAIL PROTECTED] wrote: > > Hello Daniel, > > Thank you for your reply. > > I guess then that I cannot test image heights and widths on a form > pre- > save, because that is the only reason I can think of for this error > after forum submissal (if I use clean_logo)

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Hello Daniel, Thank you for your reply. I guess then that I cannot test image heights and widths on a form pre- save, because that is the only reason I can think of for this error after forum submissal (if I use clean_logo) 'NoneType' object is unsubscriptable. Does that make sense ? --~--~

Re: Admin field custom validation

2008-09-21 Thread Daniel Roseman
On Sep 21, 6:01 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Having done a bit more research I see this often used as: > > clean_fieldname(self) rather than clean(self) > > which I guess would eleviate my problem, as my clean(self) function > doesn't appear to remember or pass on the rest

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Having done a bit more research I see this often used as: clean_fieldname(self) rather than clean(self) which I guess would eleviate my problem, as my clean(self) function doesn't appear to remember or pass on the rest of the submitted field information. However when I try the above I get: 'None

Re: Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Sorry I was wrong, if I try to submit a NEW logo that is too large it fails correctly. But when I try to add a new logo that is the right size it enters a fully blank row into the database. Thanks --~--~-~--~~~---~--~~ You received this message because you are subs

Admin field custom validation

2008-09-21 Thread [EMAIL PROTECTED]
Hi, This is my code: class LogoAdminForm(forms.ModelForm): class Meta: model = Logo def clean(self): from django.core.files.images import get_image_dimensions logo = self.cleaned_data['logo'] w, h = get_image_dimensions(logo) if w > 150 or h > 150:

Key error at password2 while doing custom validation with user registration form

2008-07-25 Thread tom17
This is how I solved it! my model is like this: class userForm(forms.Form): username = forms.CharField() display_name = forms.CharField() email_address = forms.EmailField() timezone = TimeZoneField() password1 = forms.CharField(widget=forms.PasswordInput)

Re: Custom validation

2008-07-22 Thread Alex Rades
> >> >> class User(model.Model): >> >> group = models.ForeignKey(Group) >> >> >> Class Group(model.Model): >> >> interest = models.ForeignKey(Interests) >> >> >> Basically i want to be possible to change in the admin the interes

Re: Custom validation

2008-07-21 Thread Alex Rades
roup(model.Model): >> interest = models.ForeignKey(Interests) >> >> Basically i want to be possible to change in the admin the interest of >> a Group *only if*: >> >> self.user_set.count() == 0 >> >> The documentation is not very about custom validation,

Re: Custom validation

2008-07-21 Thread Jeff FW
els.ForeignKey(Interests) > > Basically i want to be possible to change in the admin the interest of > a Group *only if*: > > self.user_set.count() == 0 > > The documentation is not very about custom validation, it says to pass > validator_list to the field definition, so i&#

Custom validation

2008-07-21 Thread Alex Rades
ly if*: self.user_set.count() == 0 The documentation is not very about custom validation, it says to pass validator_list to the field definition, so i've tried with: interest = models.ForeignKey(interests, validator_list = [ myvalidator ]) But it seems the custom validators are not called at al

Re: newform-admin: custom validation (multiple fields)

2008-05-01 Thread [EMAIL PROTECTED]
Thanks Felix. I did use the Form.clean() for my validation accross multiple fields. There is an open ticket for the non_field_errors() not being called withing the change_form.html template. http://code.djangoproject.com/ticket/6809 -Alen On May 1, 4:14 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]

Re: newform-admin: custom validation (multiple fields)

2008-05-01 Thread [EMAIL PROTECTED]
On Apr 30, 6:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > After reading over the newforms documentation, I came across the > Form.clean() method that suites my case nicely regarding my newforms- > admin form: > > """ > The Form subclass’s clean() method. This method can perform any > v

Re: newform-admin: custom validation (multiple fields)

2008-04-30 Thread [EMAIL PROTECTED]
ve doc snippet with regards to the special 'field' called __all__? regards, -al On Apr 30, 5:50 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi Al, > > On Apr 30, 2:18 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > >

Re: newform-admin: custom validation (multiple fields)

2008-04-30 Thread [EMAIL PROTECTED]
Hi Al, On Apr 30, 2:18 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I would like to add some custom validation to the newform-admin form. > I have look at the > -http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIaddcustomval... > - and am still not fin

newform-admin: custom validation (multiple fields)

2008-04-30 Thread [EMAIL PROTECTED]
I would like to add some custom validation to the newform-admin form. I have look at the - http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIaddcustomvalidation - and am still not finding a solution. Here is what I'm trying to do: I have several form fields on an admin form

Re: newforms 0.96.1 custom validation

2008-03-07 Thread Panos Laganakos
Thanks Malcolm, that was it! Newforms are starting to feel fun :) On Mar 6, 7:03 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-03-06 at 08:45 -0800, Panos Laganakos wrote: > > Trying to add custom validation for a customer creation form, but when >

Re: newforms 0.96.1 custom validation

2008-03-06 Thread Malcolm Tredinnick
On Thu, 2008-03-06 at 08:45 -0800, Panos Laganakos wrote: > Trying to add custom validation for a customer creation form, but when > I add: > > def clean_username(self): > try: > user = > User.objects.get(username__exact=self.cleaned_data['

newforms 0.96.1 custom validation

2008-03-06 Thread Panos Laganakos
Trying to add custom validation for a customer creation form, but when I add: def clean_username(self): try: user = User.objects.get(username__exact=self.cleaned_data['username']) except User.DoesNotExist: return self.cleaned_data

newforms 0.96.1 custom validation

2008-03-06 Thread Panos Laganakos
Trying to add custom validation for a customer creation form, but when I add: def clean_username(self): try: user = User.objects.get(username__exact=self.cleaned_data['username']) except User.DoesNotExist: return self.cleaned_data

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

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
admin area will display as an error and let the user correct the data? Cheers, Mike Collin Grady wrote: > 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/mod

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

Custom validation for models in admin

2007-09-11 Thread Mike H
there yet, and the online documentation points to a .validate() on the model which is marked as experimental. If it's possible, where can I put custom validation like that, that the admin area will pick up on? I'm currently using 0.96 but could easily upgrade to the svn trunk if neede

custom validation with newForms

2007-03-22 Thread tyman26
I want to create some custom validation methods for some fields in a model that I have. I use a form to display this model through a view. Anyways, does this mean I can't use "forms.models.form_for_model(Employee)"? Would I have to create this form seperately from the m

Custom validation in Django admin

2007-02-01 Thread genelisp
Hi, I want to do some custom validation in the django admin. I have a model which looks like: class Message(models.Model): name = models.CharField(maxlength=30) date = models.DateField() speaker = models.CharField(maxlength=30) path = models.FileField(upload_to='messages/