[Django] #27389: Cannot use QueryDict without configuring settings first

12 views
Skip to first unread message

Django

unread,
Oct 26, 2016, 3:49:36 AM10/26/16
to django-...@googlegroups.com
#27389: Cannot use QueryDict without configuring settings first
--------------------------------------+--------------------
Reporter: Jaap Roes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
This is not really a bug, but I was surprised by this behaviour:

{{{
>>> from django.http import QueryDict
>>> q = QueryDict('a=1&a=2&b=3&c=4&c=5&d')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/lib/python3.4/site-packages/django/http/request.py", line
377, in __init__
encoding = settings.DEFAULT_CHARSET
File "/path/to/lib/python3.4/site-packages/django/conf/__init__.py",
line 53, in __getattr__
self._setup(name)
File "/path/to/lib/python3.4/site-packages/django/conf/__init__.py",
line 39, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting
DEFAULT_CHARSET, but settings are not configured. You must either define
the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.
}}}

The `QueryDict` implementation relies on two Django settings
`DEFAULT_CHARSET` and `DATA_UPLOAD_MAX_NUMBER_FIELDS`, both have sane
defaults (`'utf-8'` and `1000`) and are probably rarely overruled in user
settings. Would it be acceptable to just use these values if settings
aren't configured?

--
Ticket URL: <https://code.djangoproject.com/ticket/27389>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 26, 2016, 8:59:42 AM10/26/16
to django-...@googlegroups.com
#27389: Cannot use QueryDict without configuring settings first
-------------------------------------+-------------------------------------

Reporter: Jaap Roes | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
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):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I guess it's a question of how much effort it will take and if it's
possible to write tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/27389#comment:1>

Django

unread,
Oct 26, 2016, 9:35:59 AM10/26/16
to django-...@googlegroups.com
#27389: Cannot use QueryDict without configuring settings first
-------------------------------------+-------------------------------------

Reporter: Jaap Roes | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
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 Claude Paroz):

We probably need a use case also.

--
Ticket URL: <https://code.djangoproject.com/ticket/27389#comment:2>

Django

unread,
Oct 26, 2016, 10:12:58 AM10/26/16
to django-...@googlegroups.com
#27389: Cannot use QueryDict without configuring settings first
-------------------------------------+-------------------------------------

Reporter: Jaap Roes | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: HTTP handling | Version: master
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 Jaap Roes):

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


Comment:

No real use case. I was just trying to use the QueryDict in simple quick
(throwaway) python script and was surprised it didn't work standalone.

I'll resolve it as wontfix because I cannot be bothered to write a patch
;-)

--
Ticket URL: <https://code.djangoproject.com/ticket/27389#comment:3>

Reply all
Reply to author
Forward
0 new messages