Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#17283 closed Bug (invalid)

Adding Human Readable Name to forms.DateField with input_formats option causes input_format to complain about multiple values for input_formats

Reported by: amit.prakash.ambasta@… Owned by: nobody
Component: Forms Version: 1.3-rc
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Karen Tracey)

The following code snippet

from django import forms
from django.utils.translation import ugettext_lazy as _

class SearchForm( forms.Form):
    d_o_b = forms.DateField( _( 'Human Readable Name'), required=False, input_formats=('%d-%m-%Y',))

causes django to complain __init__() got multiple values for keyword argument 'input_formats'


    d_o_b = form.DateField( required=False, input_formats=('%d-%m-%Y',))

works fine.

Change History (3)

comment:1 Changed 7 years ago by Karen Tracey

Description: modified (diff)

Fixed formatting. Please use WikiFormatting and preview before posting.

comment:2 Changed 7 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

Form fields don't take any non-keyword arguments, and I don't see anywhere in the documentation (e.g. that implies differently. If that _('Human Readable Name') is intended to be the field's label, then it needs to be passed as label=_('Human Readable Name').

comment:3 Changed 7 years ago by anonymous

My assumption was that they worked similar to model fields. If that is not so.. why does the following code work:

   variable_number = forms.IntegerField( _( 'Human Readable Name'), required = False, label = 'Label Name')

Also, what does the string argument "Human Readable Name" represent in this case?

The purpose of human readable field as taken from
"You can use an optional first positional argument to a Field to designate a human-readable name...and it doubles as documentation"

Note: See TracTickets for help on using tickets.
Back to Top