- visit a form containing a ModelMultipleChoiceField (such as the page for
editing an auth.group in django admin) with a recent version of Firefox.
The widget has two <select>s, and the second one contains the chosen
elements.
- refresh the page with f5 or the reload button
- notice that the second <select> is now empty (no <option>s)
This causes inadvertent data loss when the user then submits the form. The
behaviour can be avoided by setting autocomplete="off".
A similar behaviour is noticeable in normal <select> widgets, where the
value chosen before refreshing is still selected after the refresh,
regardless of the <option> selected="" attribute, although this being a
bug is debatable, and certainly not limited to django.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
Thanks for the report, I was able to reproduce this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:1>
Comment (by Dlis):
Unfortunately, Firefox has a "feature" that is associated with restoring
the values of form fields. Sometimes, this behavior does not interact well
with hidden fields like fields with CSRF-tokens. For example, a
corresponding ticket was created more than 20 years ago
(https://bugzilla.mozilla.org/show_bug.cgi?id=46845 ) and opens again from
time to time.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:2>
* owner: nobody => baravkareknath
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:3>
* stage: Accepted => Ready for checkin
Comment:
we can disable autocomplete field in python django as below:
hidden_widget = MultipleHiddenInput(attrs={'autocomplete': 'off'})
widget = SelectMultiple(attrs={'autocomplete': 'off'})
As well as we have one more option to set widget-
autocomplete = False like is_localized = False, is_required = False and so
on..
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:4>
* stage: Ready for checkin => Accepted
Comment:
Eknath, this ticket doesn't have submitted and reviewed PR, please check
[https://docs.djangoproject.com/en/stable/internals/contributing/triaging-
tickets/#triage-stages "Triaging tickets"] docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:5>
Comment (by Eknath Baravkar):
Hi Mariusz Felisiak, Thanks for replay. I am first time contributor; I
will work on the same.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:6>
* has_patch: 0 => 1
Comment:
Add patch Please check PR as below:
https://github.com/django/django/pull/16418
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:7>
Comment (by Mariusz Felisiak):
I can no longer reproduce this issue on Firefox 108.0.1.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:8>
* status: assigned => closed
* has_patch: 1 => 0
* resolution: => needsinfo
* stage: Accepted => Unreviewed
Comment:
Closing as "needsinfo" unless someone can reproduce it with
''"[https://docs.djangoproject.com/en/dev/faq/admin/#what-browsers-are-
supported-for-using-the-admin the recent versions of modern, web standards
compliant browsers]"''.
--
Ticket URL: <https://code.djangoproject.com/ticket/33386#comment:9>