Re: ModelForm validation of foreign keys - extra database queries and performance bottleneck

2017-07-25 Thread johan de taeye
I've already tried the select_related in my queryset. No change at all. >>Also keep in mind that Django (or any other framework) has no idea whether or not fields have "changed" in a form submission without pulling the original set of values to compare against, so expect the object to be

Re: ModelForm validation of foreign keys - extra database queries and performance bottleneck

2017-07-25 Thread James Schneider
On Jul 24, 2017 4:09 AM, "johan de taeye" wrote: I have a model that has a foreign key relation to a number of other objects. When saving an instance of this model from the admin (or a ModelForm), I see plenty of extra and redundant database calls. For a single record

ModelForm validation of foreign keys - extra database queries and performance bottleneck

2017-07-24 Thread johan de taeye
I have a model that has a foreign key relation to a number of other objects. When saving an instance of this model from the admin (or a ModelForm), I see plenty of extra and redundant database calls. For a single record it wouldn't make much of a difference, but when using the same ModeForm to

Again, Model and ModelForm validation

2013-01-25 Thread Fabio Natali
Hi everybody, suppose I have a model and want to add some custom validation to *just one* of its fields. Using Django 1.4 here. I expect that specific validation constraint to be used both in my forms and in my save method. Should I better use Model clean_fields() method? Or the clean()

Model and ModelForm validation

2013-01-25 Thread Fabio Natali
Hi everybody. I am reading this [0] and can't perfectly understand what this line means: "Note that full_clean() will not be called automatically when you call your model's save() method, nor as a result of ModelForm validation. You'll need to call it manually when you want to run one

Re: AttributeError for unique field during ModelForm validation

2012-11-11 Thread Rohit Banga
Thanks Andrejus. Looks like you understand my usecase. I have to use multiple tables with the same schema which is why I am using inheritance. I am using abstract base models as each model should get its own table. If I use multi-table inheritance data from all these tables ends up in one table

Re: AttributeError for unique field during ModelForm validation

2012-11-11 Thread Andrejus
Unfortunately I haven't got experience with abstarct models, one thing I clearly carried out form docs - abstract model has only one clear purpose - to avoid duplicating the same fields and methods when writing code for models. Abstract model is never transformed to database table, so may not

Re: AttributeError for unique field during ModelForm validation

2012-11-10 Thread Rohit Banga
I want to ensure that a username is unique hence the unique constraint. Is having a ModelForm with an abstract model is supported? If not I will consider dynamically creating an instance of derived model form. But it looks a lot cleaner with the abstract class. On Saturday, November 10, 2012

Re: AttributeError for unique field during ModelForm validation

2012-11-10 Thread Andrejus
Hi! I would try to set unique property within "real" model, not within abstract base class. Besides django creates unique pk on each model by default, so to my mind creating additional unique field is redundant. Not quite sure, but there seems to be some restrictions on use of unique property.

AttributeError for unique field during ModelForm validation

2012-11-10 Thread Rohit Banga
I noticed a strange behavior with Django and filed a bug https://code.djangoproject.com/ticket/19271#ticket It is suggested that I first check on the support group if the bug is valid or not. Fair Enough. I have created a standalone project to demonstrate the problem. In order to run it you

Re: ModelForm Validation Error

2012-04-18 Thread Tom Evans
On Tue, Apr 17, 2012 at 8:07 PM, coded kid wrote: > I want to make sure users fill all the fields before they are > redirected to the next page. And if they don’t fill the fields it > should raise an error telling them to fill the fields before they > proceed. So to do

Re: ModelForm Validation Error

2012-04-17 Thread Mario Gudelj
Indent that redirect one more time so that it's wothin the if loop and you're redirected to good only when the form is valid On 18/04/2012 5:07 AM, "coded kid" wrote: > I want to make sure users fill all the fields before they are > redirected to the next page. And if

ModelForm Validation Error

2012-04-17 Thread coded kid
I want to make sure users fill all the fields before they are redirected to the next page. And if they don’t fill the fields it should raise an error telling them to fill the fields before they proceed. So to do that, I wrote the codes below. But the problem I’m facing is that when I didn’t fill

modelForm validation -> model validation -> trigger field validation?

2012-01-25 Thread Sven
hi there, has anyone of you an idea in which cycle the field method of ForeignKey.validate is triggered? I have a custom ForeignKey Field where i override the validate method. So i expect that ModelForm validation triggers -> Model validation (clean methods) and this trigg

Re: ModelForm validation in 1.2.3

2010-12-30 Thread Burhan
The question is how do I get the modelform to only check for form validity, and not model validity (like it did before). I don't see what your link has to do with that. On Dec 30, 7:32 pm, Ferran wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > On 30/12/10 17:25,

Re: ModelForm validation

2010-12-30 Thread Axel Bock
Ah :) . I should have thought of that ... pretty stupid of me :) Thanks for the clarification, I'll try that, makes perfect sense! /Axel. 2010/12/30 derek > Alex > > And I seem to have been equally unclear :} > > I agree that cleaned_data is only available after

Re: ModelForm validation in 1.2.3

2010-12-30 Thread Ferran
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 30/12/10 17:25, Burhan wrote: > In 1.2.3, this logic always fails because "is_clean()" fails if an > existing customer enter's their email address. How can I do the same > using django 1.2.3? http://docs.python.org/tutorial/errors.html

ModelForm validation in 1.2.3

2010-12-30 Thread Burhan
Hello: In 1.2 ModelForm validation was changed so that not only does it check the form validation, but it does validation of the model as well. I have a model that has custom validation for one of its fields, which should be unique in the table. Now I have a front end form, created

Re: ModelForm validation

2010-12-30 Thread derek
Alex And I seem to have been equally unclear :} I agree that cleaned_data is only available after is_valid() - the point being that your form *will* be valid if you have set the value for that field in a hidden input. I do not see that this can be a "security risk" - the default that you are

Re: ModelForm validation

2010-12-29 Thread Ted
Easiest solution I can see is to create two form classes: StudentForm and NonStudentForm. On student form you can then edit form.instance or form.cleaned_data depending on what your needs are to add the additional fields before the object is created/updated. Another approach would be to try

Re: ModelForm validation

2010-12-29 Thread Axel Bock
hi derek, thanks for your hints - was I really that unclear? hm. anyway, could you please give an example about how to "override/check the value for that field after the form POST"? I don't seem to be able to do that, and believe me, I have read the docs. I think cleaned_data is only available

Re: ModelForm validation

2010-12-29 Thread derek
Axel Not sure I have followed all your requirements, but perhaps you can try: * set a default value for the required field * mask the required field on the form being shown to the user (make it hidden) * override/check the value for that field after the form POST and data "clean" (see:

ModelForm validation

2010-12-28 Thread Axel Bock
Hi all, I have this little problem. In my little webapp I have a data model which defines several required fields. Depending on WHO is logged on, some of these fields should not be changed by the user and be pre-filled (or better: post-filled) by the application. Currently I delete the fields

Re: modelform validation

2010-03-31 Thread Vinicius Mendes
Test if self.instance.user is not None, if so, change the queryset to exclude the self.instance.user: http://gist.github.com/350440 __ Vinícius Mendes Solucione Sistemas http://solucione.info/ On Wed, Mar 31, 2010 at 11:24 AM, Emanuel wrote: > Hi

Re: modelform validation

2010-03-31 Thread Brandon Taylor
Hi there, When calling def clean_name(self):, you can see if your instance has an id or not: def clean_name(self): if not self.id: #this would be a new record else: #this would be an existing record HTH, Brandon On Mar 31, 9:24 am, Emanuel

modelform validation

2010-03-31 Thread Emanuel
Hi all! I have a modelform and I want to customize validation. I'm overriding the method clean_(). When I'm saving the form I want to see if a specific user has been already assigned to a project. The only way he can ben assigned again is if he's an inactive user, so: models.py Class

modelform validation

2010-03-31 Thread Emanuel
Hi all! I have a modelform and I want to customize validation. I'm overriding the method clean_(). When I'm saving the form I want to see if a specific user has been already assigned to a project. The only way he can ben assigned again is if he's an inactive user, so: models.py Class

Re: ModelForm validation

2009-08-10 Thread Karen Tracey
On Mon, Aug 10, 2009 at 6:09 AM, nostradamnit wrote: > > I have a form that inherits from ModelForm, and in my view, > form.is_valid returns true, then save() bombs out with validation > errors?!? > is_valid is a method. If you are checking it "if form.is_valid:" that is

ModelForm validation

2009-08-10 Thread nostradamnit
I have a form that inherits from ModelForm, and in my view, form.is_valid returns true, then save() bombs out with validation errors?!? Does anyone know of a good tutorial/doc on this? Thanks, Sam --~--~-~--~~~---~--~~ You received this message because you are

Re: modelform validation errors

2009-08-02 Thread zayatzz
Digging in documentation surely helps :) I had to replace {% if pform.non_field_errors %} {{ pform.non_field_errors.as_ul }} {% endif %} with {{ pform.errors }} to see that about field was causing it. I overrid about field with tinymce

Re: modelform validation errors

2009-08-01 Thread zayatzz
Thanks This might have solved another issue i had not encountered yet, but it did not solve my current issue :) Form is still not valid and i have no idea why. If someone would tell me how modelform error messages are supposed to be used, then they might help me. {% if

Re: modelform validation errors

2009-08-01 Thread prabhu S
The method create_profile returns profile after saving. But this object will not contain primary keys etc generated in the db. To work around this common issue with django profile.save() # Get the data again from db. profile = Profile.objects.get(user=username) return profile Let me know if

Re: modelform validation errors

2009-08-01 Thread zayatzz
I figured ill add the code i have so far: The models: class ProfileManager(models.Manager): def create_profile(self, username): "Creates and saves a User with the given username, e-mail and password." now = datetime.datetime.now() profile =

modelform validation errors

2009-08-01 Thread zayatzz
}} {% endif %} into view, but it is not displaying any validation errors... So how are modelform validation errors supposed to be seen/shown? Alan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" grou