#7609 closed Bug (fixed)
Document that PositiveIntegerField and co have a misleading name
Reported by: | Owned by: | Paul Collins | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | name convention, rename |
Cc: | Paul Collins | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I find the PositiveIntegerField (and similar firends) name misleading. It allows zero.
Using UnsignedIntegerField or something like that cat solve that confusion.
Attachments (3)
Change History (22)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Design decision needed |
Calling it something else would be the "right" way to fix this. I'm +1 for calling it UnsignedInteger, because that is really what it is. This will preserve the current behaviour, and to make PositiveInteger act properly, we could simply add code to it to reject 0 when validating.
Writing a patch like this should be fairly trivial.
comment:3 by , 16 years ago
milestone: | → post-1.0 |
---|
by , 16 years ago
Attachment: | UnsignedIntegerField.diff added |
---|
Very simple patch to add UnsignedIntegerField and UnsignedSmallIntegerField as subclasses of PositiveIntegerField and PositiveSmallIntegerField.
comment:5 by , 16 years ago
#10719 marked as a dup. I favor its recommendation to explicitly note in the docs these fields include zero as valid input. I don't think we need yet more names for the same thing and it would be backwards-incompatible at this point to start disallowing zero for these fields.
comment:6 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:7 by , 14 years ago
I was surprised to get a ZeroDivisionError error when using this field with a ModelForm, because as people have already pointed out, 0 is not a positive integer. So how could that be valid input for the PositiveIntegerField?
Now I'm just specifying a different form field in my ModelForm: forms.IntegerField(min_value=1).
IMO changing the min_value form field default for this field from 0 to 1 is better than making a new UnsignedIntegerField class. At the very least, a caution note in the docs for PositiveIntegerField.
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
follow-up: 10 comment:9 by , 13 years ago
Component: | Forms → Documentation |
---|---|
Easy pickings: | unset |
Summary: | PositiveIntegerField and co have a misleading name → Document that PositiveIntegerField and co have a misleading name |
Triage Stage: | Design decision needed → Accepted |
UI/UX: | unset |
Speaking with Jacob: we can't change this due to backwards compatibility, however the docs should clearly note this.
comment:10 by , 13 years ago
Has patch: | set |
---|
Replying to Alex:
Speaking with Jacob: we can't change this due to backwards compatibility, however the docs should clearly note this.
So it's a trivial patch to the docs, but I guess it makes the required point.
comment:11 by , 13 years ago
Might it be a good thing to actually mention we know positive should mean "higher than 0", but the field accepts 0 due to backwards compatibility? It saves people a search on the trac for tickets relating to it.
comment:12 by , 13 years ago
Patch needs improvement: | set |
---|
Yes, I agree with bpeschier. Could you please update the patch?
follow-up: 15 comment:13 by , 13 years ago
Should I include that kind of information as a ..note:: or just put something to the effect of
Like an :class:IntegerField
, but must be positive. Also accepts 0 for backward compatibility reasons (link to this ticket)?
comment:14 by , 13 years ago
Cc: | added |
---|
follow-up: 16 comment:15 by , 13 years ago
Replying to paulcollins:
Should I include that kind of information as a ..note:: or just put something to the effect of
Like an :class:IntegerField
, but must be positive. Also accepts 0 for backward compatibility reasons (link to this ticket)?
No need to use a "..note" directive. Just need to say that, despite its name, it accepts 0 for B-C reasons.
by , 13 years ago
Attachment: | doc_patch_wo_link.diff added |
---|
Same idea without the link to this ticket
comment:16 by , 13 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | unset |
Replying to julien:
Replying to paulcollins:
No need to use a "..note" directive. Just need to say that, despite its name, it accepts 0 for B-C reasons.
Two versions one with the link to this ticket and one without. Let me know if you need some other change to it, otherwise feel free to use either one :)
Remembering my distant math major past, I suppose "NonNegativeInteger" would be more technically correct, but I'm rather OK with PositiveInteger including zero, it's what I expected.