forms - Django Choicefield with required=True and no exception on blank choice -


i guess problem clear title.

basically have form dynamic choice fields. , create blank option select field.

 choices = [('', '----------')] 

problem if submit blank option, form validates. have django 1.5 installed, if in earlier version worked, , validation exception thrown, not.

so big question , how , should validate ?

i tried ovveride choicefield , it's validate method, still same result:

class dynamicchoicefield(forms.choicefield):     # thing need override here validate function.     def validate(self, value):         if self.required , not value:             raise validationerror(self.error_messages['required']) 

andy ideas guys ?

yes , clear me. when change required =false . or try use django force_insert =true in model, never used , try it.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -