Re: newforms validation problem

2008-01-28 Thread [EMAIL PROTECTED]
That would just be short_name = "something", what you are doing is creating an object, however you aren't saving it to the database, you are just using it to pre-populate info to a model form. On Jan 28, 4:19 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello that's what I wanted but it

Re: newforms validation problem

2008-01-28 Thread [EMAIL PROTECTED]
Hello that's what I wanted but it doesn't work ('prepopulate_short_name' is an invalid keyword argument for this function) I have player_create_name = request.GET.get('name') tplayer = Player(prepopulate_short_name=player_create_name) playerForm = CreatePlayerForm(instance=tplayer) models: class

Re: newforms validation problem

2008-01-28 Thread Vance Dubberly
If I get what you are asking correctly, you are trying to pre-populate some fields in a form without printing out the validation errors that occur from not having all the fields populated? If so this should help: # create object instance with pre-populated data obj_instance = Object(prepoulate_f

newforms validation problem

2008-01-28 Thread [EMAIL PROTECTED]
Hello, I have a view with searches for a given record (using a text field). If the object does not exist show a error and a link: Create On the create view if GET.get('val') then I put that data in the form. I want this just to make it simple for a user to enter a new object if it does not exist

Re: dynamic newforms validation etc

2007-11-30 Thread RajeshD
> This data needs to be saved in Options. A record for each product > selected with the name and price in it. This is because the product > name can change in the future and the price can change. So this should > be stored in Options. > > My problem is that I don't know yet how to do this. > > Ca

dynamic newforms validation etc

2007-11-30 Thread super
Ok I worked myself a bit in trouble. Don't know yet how to do this with newforms: Let me explain and dumb down my problem to make things easy: two models: model 1: Products I got "products" that have each a name and a price Model 2: Options Option has a foreingkey pointing to products but also a

Re: Newforms validation error not displayed:

2007-11-04 Thread Karen Tracey
On 11/4/07, crybaby <[EMAIL PROTECTED]> wrote: > > > That seems to be a silly question now. I have another related > question regarding type of "self.cleaned_data['guess_the_number']", > string or integer or float? In general it depends on the type of field. In this case it's a RegExField, so

Re: Newforms validation error not displayed:

2007-11-04 Thread crybaby
That seems to be a silly question now. I have another related question regarding type of "self.cleaned_data['guess_the_number']", string or integer or float? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Djang

Re: Newforms validation error not displayed:

2007-11-03 Thread RajeshD
> > def clean_guess_the_number(self): > if self.max_number > self.cleaned_data['guess_the_number']: Change that to: if self.max_number < self.cleaned_data['guess_the_number']: > raise forms.ValidationError('Your Number have to be lower > or equal to Max Number.') >

Re: Newforms validation error not displayed:

2007-11-03 Thread Karen Tracey
On 11/3/07, crybaby <[EMAIL PROTECTED]> wrote: > > > Validation checks the number entered by the user is between the range > and this check is done in "def clean_guess_the_number". This is not > working. > > Seems like "def clean_guess_the_number(self)" never executed when you > post the data and

Newforms validation error not displayed:

2007-11-03 Thread crybaby
Validation checks the number entered by the user is between the range and this check is done in "def clean_guess_the_number". This is not working. Seems like "def clean_guess_the_number(self)" never executed when you post the data and when form.is_valid() called. class GuessForm(forms.Form):

Newforms validation question

2007-09-24 Thread r_f_d
I have an app that uses a roll-my-own role-based access system to restrict access to various model instances. Essentially what happens is that there is a role or roles assigned to users that allow them to either view or edit various asset types based on the owning organization. Many of the asset

Re: Newforms / Validation / Uniqueness

2007-06-01 Thread Nebojša Đorđević
On 31.05.2007., at 04:30, Malcolm Tredinnick wrote: > On Wed, 2007-05-30 at 08:31 -0700, ringemup wrote: > [...] >>> So a "uniqueness" constraint on your model is not something that the >>> form framework is really in a position to check. Instead, what >>> should >>> happen is you construct the

Re: Newforms / Validation / Uniqueness

2007-05-31 Thread ringemup
> Since full model-aware validation doesn't exist yet, example code would > be premature. :-) Ah, sorry, I thought you were saying that models have an existing validate() method that could be called on an object constructed by a form. On May 30, 3:18 pm, "Alfonso Ali" <[EMAIL PROTECTED]> wrote:

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Malcolm Tredinnick
On Wed, 2007-05-30 at 08:31 -0700, ringemup wrote: [...] > > So a "uniqueness" constraint on your model is not something that the > > form framework is really in a position to check. Instead, what should > > happen is you construct the model object and then call > > object.validate(), which return

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Alfonso Ali
My solution is to use the base class parameter of form_for_[model|instance] function, for example: class SomeTest(models.Model): name = models.CharField(maxlength=50) user = models.ForeignKey(User) class Meta: unique_together = (('user', 'name'),) class SomeTestBaseForm(forms.Base

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Horst Gutmann
ringemup wrote: > > Do you then have to figure out which errors apply to which Form > fields, and sort them out and assign them? I haven't seen any sample > code doing anything of this sort, so I'd be very interested to see how > it works. > I was recently in the same situation and did somethi

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread ringemup
> The short answer to your problem is probably to not use form_for_model() > if you want this sort of support. Instead write your own Form sub-class > and write a clean() method for it. The form_for_model() function is just > an aid after all; it shouldn't be the only thing you ever consider > us

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Thomas Guettler
Am Dienstag, 29. Mai 2007 21:19 schrieb ringemup: > Hello -- > > I'm using a basic form_for_model() form object for a model that has a > unique=True constraint on a field other than the primary key. > > When validating submitted data, is there a reason the form check that > that constraint hasn't

Re: Newforms / Validation / Uniqueness

2007-05-29 Thread Malcolm Tredinnick
On Tue, 2007-05-29 at 12:19 -0700, ringemup wrote: > Hello -- > > I'm using a basic form_for_model() form object for a model that has a > unique=True constraint on a field other than the primary key. > > When validating submitted data, is there a reason the form check that > that constraint hasn

Newforms / Validation / Uniqueness

2007-05-29 Thread ringemup
Hello -- I'm using a basic form_for_model() form object for a model that has a unique=True constraint on a field other than the primary key. When validating submitted data, is there a reason the form check that that constraint hasn't been violated and throw a validation error? I'd like to be abl

newforms Validation Static vs Dynamic

2007-02-10 Thread johnny
What is the different between newforms, forms.CharField(max_length = 30, min_length = 5, error_message ='Must be at least 5 char length') and using clean method raise forms.ValidationError ('Display some error message') Is former for static error message and later for Dynamic Error Message? --~

Re: newforms validation

2007-01-22 Thread serbaut
The clean_XXX methods documented in the regression tests mentioned above did it for me. I think the new api is much cleaner(!) than the old. The only thing is that I think the clean_XXX should be passed the cleaned value so far since you most likely will be doing: def clean_XXX(self): value =

Re: newforms validation

2007-01-19 Thread enigmadude
I had this same dilemma also. I was trying to create my own custom login view, but the current built-in login view still uses the oldforms, while I'm in the process of converting to newforms. The AuthenticationForm in Django has a hasCookiesEnabled() method that requires to have access to the req

Re: newforms validation

2007-01-19 Thread Nuno Mariz
Yes, you should implement your own field classes with custom validation. A Field *is* a validator. Yes, I understand the idea. I love the new django.newforms lib, but I think that an extra 'validator_list' parameter at least in CharField is more convenient and easy to implement(less code). G

Re: newforms validation

2007-01-17 Thread serbaut
Thank you both. Django rocks by the way! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send

Re: newforms validation

2007-01-17 Thread Bram - Smartelectronix
serbaut wrote: Respect! Dont have time to wait though... :D Can you please consider passing the cleaned value to the (undocumented?) clean_%s method in Form.full_clean()? -value = getattr(self, 'clean_%s' % name)() +value = getattr(self, 'clean_%s' % nam

Re: newforms validation

2007-01-17 Thread serbaut
Respect! Dont have time to wait though... :D Can you please consider passing the cleaned value to the (undocumented?) clean_%s method in Form.full_clean()? -value = getattr(self, 'clean_%s' % name)() +value = getattr(self, 'clean_%s' % name)(value) Joaki

Re: newforms validation

2007-01-17 Thread Adrian Holovaty
On 1/17/07, serbaut <[EMAIL PROTECTED]> wrote: > def my_view(request): > f = MyForm({'foo': request.POST['foo'], 'bar': request.user.username}) > > The form library itself knows nothing about request objects. But my Field doesnt know about its' form so how does this help my Field.cl

Re: newforms validation

2007-01-17 Thread serbaut
def my_view(request): f = MyForm({'foo': request.POST['foo'], 'bar': request.user.username}) The form library itself knows nothing about request objects. But my Field doesnt know about its' form so how does this help my Field.clean(self, value) validator? Joakim --~--~-

Re: newforms validation

2007-01-17 Thread Adrian Holovaty
On 1/17/07, serbaut <[EMAIL PROTECTED]> wrote: Say for example that I need to check permissions for request.user in clean? def clean(self, value): if request.user.has_some_property() and value > 100: raise forms.ValidationError, 'You are not allowed to go that high, please enter a value

Re: newforms validation

2007-01-17 Thread serbaut
Creating field classes for validation makes sense but what if I need to validate in a request context? Say for example that I need to check permissions for request.user in clean? def clean(self, value): if request.user.has_some_property() and value > 100: raise forms.ValidationError, 'You

Re: newforms validation

2006-12-29 Thread Adrian Holovaty
On 12/29/06, mojo <[EMAIL PROTECTED]> wrote: Is it possible to set list of validators for field? (looking through the code my guess is no). Should I implement my own field classes with custom validation (overloading clean()) or what? Yes, you should implement your own field classes with custom

Re: newforms validation

2006-12-29 Thread mojo
my bad, of course, the patch should be: Index: fields.py === --- fields.py (revision 4256) +++ fields.py (working copy) @@ -33,7 +33,7 @@ # Tracks each time a Field instance is created. Used to retain order. creation_cou

Re: newforms validation

2006-12-29 Thread mojo
I tried to implement what I want, please review (this example works for me): patch: Index: fields.py === --- fields.py (revision 4253) +++ fields.py (working copy) @@ -33,7 +33,7 @@ # Tracks each time a Field instance is cre

newforms validation

2006-12-29 Thread mojo
Hi, Is it possible to set list of validators for field? (looking through the code my guess is no). Should I implement my own field classes with custom validation (overloading clean()) or what? I think that validator_list argument in oldforms was quite convenient. Thanks. --~--~-~--~-