Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7333 closed (invalid)

newforms DecimalField docs different from class definition

Reported by: jfw Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The docs at http://www.djangoproject.com/documentation/newforms/#decimalfield
list max_decimal_places and max_whole_digits as parameters to DecimalField, whereas the actual class takes decimal_places, and nothing for max_whole_digits. The default_error_messages, however, do use those names, so that might be where the confusion comes from.

Attachments (1)

7333-suggestion.diff (3.2 KB) - added by uzi 6 years ago.
A suggested fix to the issue.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by serialx

  • milestone set to 1.0 alpha
  • Needs documentation set
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Confirmed. Needs documentation patch.

comment:2 Changed 6 years ago by ElliottM

  • milestone changed from 1.0 alpha to 1.0 beta
class DecimalField(Field):
214 	    default_error_messages = {
215 	        'invalid': _(u'Enter a number.'),
216 	        'max_value': _(u'Ensure this value is less than or equal to %s.'),
217 	        'min_value': _(u'Ensure this value is greater than or equal to %s.'),
218 	        'max_digits': _('Ensure that there are no more than %s digits in total.'),
219 	        'max_decimal_places': _('Ensure that there are no more than %s decimal places.'),
220 	        'max_whole_digits': _('Ensure that there are no more than %s digits before the decimal point.')
221 	    }
222 	
223 	    def __init__(self, max_value=None, min_value=None, max_digits=None, decimal_places=None, *args, **kwargs):
224 	        self.max_value, self.min_value = max_value, min_value
225 	        self.max_digits, self.decimal_places = max_digits, decimal_places
    * Error message keys: required, invalid, max_value, min_value, max_digits, max_decimal_places, max_whole_digits

Takes four optional arguments: max_value, min_value, max_digits, and decimal_places.

Am i Missing something? Those appear to match up. Also, this isn't related to a must-have feature, so i'm moving it out of 1.0 alpha

comment:3 Changed 6 years ago by serialx

Documentation is missing.

comment:4 Changed 6 years ago by serialx

Er.. ElliottM, you are right. I've misinterpreted the document. I think the issuer did the same mistake as me. Maybe we could redesign the document to migrate this problem?

Changed 6 years ago by uzi

A suggested fix to the issue.

comment:5 Changed 6 years ago by uzi

Attached a possible fix to the issue. Change "max_decimal_places" to "decimal_places" and "max_whole_digits" to "total_digits". Opinions?

comment:6 Changed 6 years ago by mtredinnick

Make the docs match the code, not the other way around. That way you don't break any code that is already using these parameters.

comment:7 Changed 6 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

I can't see the problem here. As far as I can see, the docs match the implementation exactly, and according to SVN history, they always have.

comment:8 Changed 3 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.