Opened 12 years ago

Closed 12 years ago

Last modified 12 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'

while

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

works fine.

Change History (3)

comment:1 by Karen Tracey, 12 years ago

Description: modified (diff)

Fixed formatting. Please use WikiFormatting and preview before posting.

comment:2 by Karen Tracey, 12 years ago

Resolution: invalid
Status: newclosed

Form fields don't take any non-keyword arguments, and I don't see anywhere in the documentation (e.g. https://docs.djangoproject.com/en/1.3/ref/forms/fields/#core-field-arguments) 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 by anonymous, 12 years ago

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 https://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-models
"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