              encoding = settings.DEFAULT_CHARSET
          self.encoding = encoding
          if six.PY3:
              if isinstance(query_string, bytes):
                  # query_string contains URL-encoded data, a subset of ASCII.
                  query_string = query_string.decode()
              for key, value in parse_qsl(query_string or '',
                                          keep_blank_values=True,
                                          encoding=encoding):
                  self.appendlist(key, value)
          else:
 
</s> remove                                 force_text(value, encoding, errors='replace'))
 </s> add                                 value) </s> remove             self.assertEqual(q['foo'], '\ufffd')
            self.assertEqual(q.getlist('foo'), ['bar', '\ufffd'])
 </s> add             self.assertEqual(q['foo'], '\xff')
            self.assertEqual(q.getlist('foo'), ['bar', '\xff']) </s> remove             case, bad UTF-8 encoding).
 </s> add             case, bad UTF-8 encoding), falling back to ISO-8859-1 decoding.
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
              encoding = settings.DEFAULT_CHARSET
          self.encoding = encoding
          if six.PY3:
              if isinstance(query_string, bytes):
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
              for key, value in parse_qsl(query_string or '',
                                          keep_blank_values=True,
                                          encoding=encoding):
                  self.appendlist(key, value)
          else:
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #22996 -- Prevented crash with unencoded query string

Thanks Jorge Carleitao for the report and Aymeric Augustin, Tim Graham
for the reviews. 
django/http/request.py