Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Model forms error messages
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Karol Sikora  
View profile  
 More options May 2 2012, 10:13 am
From: Karol Sikora <elektrr...@gmail.com>
Date: Wed, 2 May 2012 07:13:41 -0700 (PDT)
Local: Wed, May 2 2012 10:13 am
Subject: Model forms error messages

Hi,

According to my ticket: https://code.djangoproject.com/ticket/18237 and
previous one eg.: https://code.djangoproject.com/ticket/13693 I would to
discuss wider this case.
IMHO redefining field in model form subclass to set custom error messages
is a hardly DRY violation. Currently we have error_messages parameter in
model fields definition, why not use them as default(it custom messages are
given in fields definition) in model form? As I know these messages are use
in admin, so there is the most intuitive way. There are *model* forms, so
by default getting error messages form error_messages in model definition
is IMHO the best way. Another option is something like in this
blog: http://blog.brendel.com/2012/01/django-modelforms-setting-any-field.html
I don't believe that redefining fields in subclass of model form is the
best way and that all developers has the same opinion.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carl Meyer  
View profile  
 More options May 2 2012, 10:23 am
From: Carl Meyer <c...@oddbird.net>
Date: Wed, 02 May 2012 08:23:54 -0600
Local: Wed, May 2 2012 10:23 am
Subject: Re: Model forms error messages
Hi Karol,

On 05/02/2012 08:13 AM, Karol Sikora wrote:

> According to my ticket: https://code.djangoproject.com/ticket/18237 and
> previous one eg.: https://code.djangoproject.com/ticket/13693 I would to
> discuss wider this case.
> IMHO redefining field in model form subclass to set custom error
> messages is a hardly DRY violation. Currently we have error_messages
> parameter in model fields definition, why not use them as default(it
> custom messages are given in fields definition) in model form? As I know
> these messages are use in admin, so there is the most intuitive way.
> There are *model* forms, so by default getting error messages form
> error_messages in model definition is IMHO the best way. Another option
> is something like in this blog:
> http://blog.brendel.com/2012/01/django-modelforms-setting-any-field.html
> I don't believe that redefining fields in subclass of model form is the
> best way and that all developers has the same opinion.

I agree with jezdez that a Meta option as outlined in that blog post is
not good, but personally I do agree that #13693 should be reopened and
accepted. Honza outlined some valid specific concerns on that ticket,
but IMO (and as he says himself) they are addressable concerns that
should be taken into account by someone working on a patch, they are not
a reason to close the ticket.

Carl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karol Sikora  
View profile  
 More options May 2 2012, 5:50 pm
From: Karol Sikora <elektrr...@gmail.com>
Date: Wed, 2 May 2012 14:50:41 -0700 (PDT)
Local: Wed, May 2 2012 5:50 pm
Subject: Re: Model forms error messages

Here is my use case.

Model field definition:
    blog_url = models.URLField(verbose_name=u'Blog', blank=True,
error_messages={'invalid': u'Adres bloga nie jest prawidłowy'})

To define error messages in form I have to write:
 blog_url = forms.CharField(error_messages={'invalid': u'Adres bloga nie
jest prawidłowy'}, label=u'Blog', required=False)

So there are 3 DRY violation in one field(label - verbose_name, required -
blank, error_messages - error messages)!
I can't understand why all remaining model option are translated to
corresponding fields, but error_messages not.
In my opinion this is a serious bug*,* not only feature request.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Slotboom  
View profile  
 More options Nov 5 2012, 5:58 pm
From: Robert Slotboom <slotboomrob...@gmail.com>
Date: Mon, 5 Nov 2012 14:58:46 -0800 (PST)
Local: Mon, Nov 5 2012 5:58 pm
Subject: Re: Model forms error messages

I really don’t get it why this isn’t implemented right.

The values of model.field.label and model.field.help_text are handled to
the modelform so why not also handle model.field.error_messages????


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »