Re: [Django] #35433: NumberInput min_value attr overridden by IntegerField.widget_attrs

2024-05-05 Thread Django
#35433: NumberInput min_value attr overridden by IntegerField.widget_attrs
-+--
 Reporter:  mitch99  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Forms|  Version:  5.0
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by mitch99):

 * resolution:   => wontfix
 * status:  new => closed

Comment:

 OK thanks I'll try these approaches.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f4c174b8b-ca9c861a-79bd-429d-ac39-b14c02c35d33-00%40eu-central-1.amazonses.com.


Re: [Django] #35433: NumberInput min_value attr overridden by IntegerField.widget_attrs

2024-05-05 Thread Django
#35433: NumberInput min_value attr overridden by IntegerField.widget_attrs
-+--
 Reporter:  mitch99  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Forms|  Version:  5.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Comment (by David Sanders):

 Yup what Tim said: There will be people relying on this existing behaviour
 

 Another way to get `min="1"` is to use django-widget-tweaks:
 https://github.com/jazzband/django-widget-tweaks  I just tested it out and
 it works 
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f4bc04105-d2c78c44-3c55-4888-9921-28cd6392867a-00%40eu-central-1.amazonses.com.


Re: [Django] #35433: NumberInput min_value attr overridden by IntegerField.widget_attrs (was: NumberInput off-by-one on min value for type range)

2024-05-05 Thread Django
#35433: NumberInput min_value attr overridden by IntegerField.widget_attrs
-+--
 Reporter:  mitch99  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Forms|  Version:  5.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Tim Graham):

 * easy:  1 => 0
 * summary:  NumberInput off-by-one on min value for type range =>
 NumberInput min_value attr overridden by IntegerField.widget_attrs

Comment:

 The root cause is that `Field.__init__()`
 
[https://github.com/django/django/blob/9a27c76021f934201cccf12215514a3091325ec8/django/forms/fields.py#L158-L160
 overrides a widget's attrs] with `Field.widget_attrs` which includes
 `min_value=0` from
 
[https://github.com/django/django/blob/9a27c76021f934201cccf12215514a3091325ec8/django/db/models/fields/__init__.py#L2401
 PositiveIntegerField.formfield()].

 I'm not sure if we should change the behavior. The most appropriate fix
 for your use case might be to subclass `PositiveIntegerField` and override
 `formfield()` to set `min_value=1`.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f4bb98df8-272cf77b-df73-46cb-972d-962c251b399f-00%40eu-central-1.amazonses.com.