Re: Admin - formset validation with counting checked elements

2011-09-22 Thread BILLION Sébastien
Le jeudi 22 septembre 2011 12:13:20, galgal a écrit : I have my model done, the only thing is - how to validate if 1 or more checkboxes are checked. It should be done in admin - choices are displayed via Inline. -- You received this message because you are subscribed to the Google Groups "Dja

Re: Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
I have my model done, the only thing is - how to validate if 1 or more checkboxes are checked. It should be done in admin - choices are displayed via Inline. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web vi

Re: Admin - formset validation with counting checked elements

2011-09-22 Thread BILLION Sébastien
Le jeudi 22 septembre 2011 11:56:09, galgal a écrit : But I need to do checks in Admin, not my view. I can't find a method to validate in Admin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://

Re: Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
But I need to do checks in Admin, not my view. I can't find a method to validate in Admin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/rRHhnv1GGfEJ. To

Re: Admin - formset validation with counting checked elements

2011-09-22 Thread BILLION Sébastien
Le jeudi 22 septembre 2011 11:42:56, galgal a écrit : I make a mini poll system. To each question choices are related via FK. In admin I use Inline choices. Each choice has "correct" field (Boolean). When saving a poll I need to check if there is minimum 1 choice with "correct" selected. Which

Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
I make a mini poll system. To each question choices are related via FK. In admin I use Inline choices. Each choice has "correct" field (Boolean). When saving a poll I need to check if there is minimum 1 choice with "correct" selected. Which function in admin I must use, to do that validation? -

Re: Accessing request.user in formset validation

2011-05-31 Thread Carsten Fuchs
Hi Tom, wow, perfect!! A thousand thanks for your help and example code! :-D Best regards, Carsten -- Cafu - the open-source Game and Graphics Engine for multiplayer, cross-platform, real-time 3D Action Learn more at http://www.cafu.de -- You received this message because you a

Re: Accessing request.user in formset validation

2011-05-31 Thread Tom Evans
On Tue, May 31, 2011 at 2:21 PM, Carsten Fuchs wrote: > Hi all, > > in some of my forms and formsets I need access to request.user in form > validation. > > With an individual form, I pass request.user as a parameter to the > constructor, using code like this: > > class ErfasseZeitraumForm(forms.F

Accessing request.user in formset validation

2011-05-31 Thread Carsten Fuchs
Hi all, in some of my forms and formsets I need access to request.user in form validation. With an individual form, I pass request.user as a parameter to the constructor, using code like this: class ErfasseZeitraumForm(forms.Form): von= forms.DateField(widget=AdminDateWidget())

Re: inline formset validation error

2011-02-13 Thread Shawn Milochik
You can iterate through the forms in your formset and call is_valid() (and optionally save()) on them based on your needs. Since your definition of "left blank" and "invalid" could vary based on what you're doing, it's better that you make those decisions explicit. If Django tried to decide for yo

inline formset validation error

2011-02-13 Thread Sarang
I have an inline formset that has max_num=3 and extra=3. The form is displayed correctly, however, is_valid() on the formset returns a False with error: [{}, {'tag': [u'This field is required.']}, {'tag': [u'This field is required.']}] The first form has no error as the user has set some value

Re: FormSet validation - not sure how to implement

2010-12-22 Thread Michael Thamm
Never mind - I changed it to ModelForm class instead. >From what I have read, FormSet is not designed to be used in the generic form way. Rather for bulk adds or something like that. ModelForm works nice and easy. On Dec 21, 7:04 am, Michael Thamm wrote: > I am using 2 formsets on a template for

FormSet validation - not sure how to implement

2010-12-21 Thread Michael Thamm
I am using 2 formsets on a template form and it shows fine but I don't know how to implement the form validation. Not allow a field to be empty. I have tried the basic method as documented but it doesn't trigger any messages. However, I also haven't put any defined errors anywhere so I don't know h

Re: Custom formset validation: having a "save?" checkbox for each form

2010-11-09 Thread Carsten Fuchs
e clean method, which allows you to do validation that depends on multiple forms, for example making sure the same day is not reported twice, etc. See http://docs.djangoproject.com/en/dev/topics/forms/formsets/#custom-formset-validation Rewriting your view to take advantage of this, as

Re: Custom formset validation: having a "save?" checkbox for each form

2010-11-08 Thread Knut Ivar Nesheim
ich allows you to do validation that depends on multiple forms, for example making sure the same day is not reported twice, etc. See http://docs.djangoproject.com/en/dev/topics/forms/formsets/#custom-formset-validation Rewriting your view to take advantage of this, as well as a nice idioms: d

Custom formset validation: having a "save?" checkbox for each form

2010-11-08 Thread Carsten Fuchs
Hi all, my name is Carsten Fuchs, and this is my first post here. I'm normally a C++ developer for Windows and Linux desktop and server applications, and have begun my first (big) database-web project in mid summer. Let me start with saying that Django is utterly awesome: I've been able to co

Re: Testing formset validation

2010-10-08 Thread ses1984
I should also add that neither the formset nor the form report .errors or .non_form_errors() at all. On Oct 8, 6:15 pm, ses1984 wrote: > I have a pretty simple form, defined below, that I am setting > according to some initial data, and no matter what I try, I can't seem > to get it to validate i

Testing formset validation

2010-10-08 Thread ses1984
I have a pretty simple form, defined below, that I am setting according to some initial data, and no matter what I try, I can't seem to get it to validate in a test. I have created some test data, which is an array with one dictionary element, where the dictionary corresponds to the form. If I cre

Re: Custom Inline Formset Validation

2010-08-12 Thread kkerbel
To clarify, by "checked" I mean there is a booleanfield and I only want to let the user select 5 of those at a time across the inline formset. On Aug 12, 1:14 pm, kkerbel wrote: > I'm trying to do some custom validation for an inlineformset.  I would > like to only allow 5 items checked across

Custom Inline Formset Validation

2010-08-12 Thread kkerbel
I'm trying to do some custom validation for an inlineformset. I would like to only allow 5 items checked across the forms in the inline formset. What's the best way to do this? I have tried defining a method (like a clean method for forms and formsets) but it doesn't appear to work. Maybe I'm d

Inline Formset Validation

2009-07-02 Thread KRH
A question on forms; I had asked something similar on StackOverflow but found the solution didn't really work for me. Let's say I have an Article class and a Photo class, and I want to be able to attach Photos to Articles. I create an ArticlePhotoSet class, and make it an InlineForm in the Article

formset validation

2008-08-21 Thread mg
I am trying to validate a formset that I have and am having problems with the forms within the set. If i call is_valid on a formset after a POST, it seems that the individual forms aren't validating within the set. For example, if the code below is executed, the resulting log looks like this: DEBU