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
t;> dev = models.EmailField()
>>>> qa = models.EmailField()
>>>> cc = models.MultipleEmailField()
>>>>
>>>> forms.py:
>>>>
>>>> class RecipientsForm(forms.**ModelForm):
>>>>
>>>
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
> 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
>
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
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
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
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
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
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
> 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
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
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
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
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
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
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
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
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-
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
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
? 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
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
... 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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
&
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
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
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
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
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
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
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
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
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
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)
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 ?
--~--~
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
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
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
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:
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)
>
>> >> 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
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,
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
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
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]
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
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:
>
>
>
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
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
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
>
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['
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
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
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
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
--~--~-~--~~~---~--~-
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
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
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
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
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/
76 matches
Mail list logo