diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index 61d9ff7..6fdb3c1 100644
a
|
b
|
a list of all possible variables.
|
9 | 9 | import os |
10 | 10 | import time # Needed for Windows |
11 | 11 | from django.conf import global_settings |
| 12 | from warnings import warn |
12 | 13 | |
13 | 14 | ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" |
14 | 15 | |
… |
… |
class Settings(object):
|
90 | 91 | # as strings. |
91 | 92 | tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS") |
92 | 93 | |
| 94 | # If DEFAULT_CHARSET is specified, populate OUTPUT_CHARSET from it. |
| 95 | try: |
| 96 | setattr(self, "OUTPUT_CHARSET", getattr(mod, "DEFAULT_CHARSET")) |
| 97 | warn("DEFAULT_CHARSET is deprecated. Use OUTPUT_CHARSET instead.", |
| 98 | DeprecationWarning, stacklevel=3) |
| 99 | except AttributeError, e: |
| 100 | pass |
| 101 | |
93 | 102 | for setting in dir(mod): |
94 | 103 | if setting == setting.upper(): |
95 | 104 | setting_value = getattr(mod, setting) |
… |
… |
class Settings(object):
|
97 | 106 | setting_value = (setting_value,) # In case the user forgot the comma. |
98 | 107 | setattr(self, setting, setting_value) |
99 | 108 | |
| 109 | |
100 | 110 | # Expand entries in INSTALLED_APPS like "django.contrib.*" to a list |
101 | 111 | # of all those apps. |
102 | 112 | new_installed_apps = [] |
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 6be789a..287b8b9 100644
a
|
b
|
MANAGERS = ADMINS
|
102 | 102 | # MIME type isn't manually specified. These are used to construct the |
103 | 103 | # Content-Type header. |
104 | 104 | DEFAULT_CONTENT_TYPE = 'text/html' |
105 | | DEFAULT_CHARSET = 'utf-8' |
| 105 | OUTPUT_CHARSET = 'utf-8' |
106 | 106 | |
107 | 107 | # Encoding of files read from disk (template and initial SQL files). |
108 | 108 | FILE_CHARSET = 'utf-8' |
diff --git a/django/core/mail.py b/django/core/mail.py
index 72343cb..5ba545e 100644
a
|
b
|
def forbid_multi_line_headers(name, val):
|
78 | 78 | result = [] |
79 | 79 | for item in val.split(', '): |
80 | 80 | nm, addr = parseaddr(item) |
81 | | nm = str(Header(nm, settings.DEFAULT_CHARSET)) |
| 81 | nm = str(Header(nm, settings.OUTPUT_CHARSET)) |
82 | 82 | result.append(formataddr((nm, str(addr)))) |
83 | 83 | val = ', '.join(result) |
84 | 84 | else: |
85 | | val = Header(force_unicode(val), settings.DEFAULT_CHARSET) |
| 85 | val = Header(force_unicode(val), settings.OUTPUT_CHARSET) |
86 | 86 | return name, val |
87 | 87 | |
88 | 88 | class SafeMIMEText(MIMEText): |
… |
… |
class EmailMessage(object):
|
220 | 220 | return self.connection |
221 | 221 | |
222 | 222 | def message(self): |
223 | | encoding = self.encoding or settings.DEFAULT_CHARSET |
224 | | msg = SafeMIMEText(smart_str(self.body, settings.DEFAULT_CHARSET), self.content_subtype, encoding) |
| 223 | encoding = self.encoding or settings.OUTPUT_CHARSET |
| 224 | msg = SafeMIMEText(smart_str(self.body, settings.OUTPUT_CHARSET), self.content_subtype, encoding) |
225 | 225 | if self.attachments: |
226 | 226 | body_msg = msg |
227 | 227 | msg = SafeMIMEMultipart(_subtype=self.multipart_subtype) |
… |
… |
class EmailMessage(object):
|
288 | 288 | basetype, subtype = mimetype.split('/', 1) |
289 | 289 | if basetype == 'text': |
290 | 290 | attachment = SafeMIMEText(smart_str(content, |
291 | | settings.DEFAULT_CHARSET), subtype, settings.DEFAULT_CHARSET) |
| 291 | settings.OUTPUT_CHARSET), subtype, settings.OUTPUT_CHARSET) |
292 | 292 | else: |
293 | 293 | # Encode non-text attachments with base64. |
294 | 294 | attachment = MIMEBase(basetype, subtype) |
diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
index cedab06..02e5636 100644
a
|
b
|
def Deserializer(object_list, **options):
|
72 | 72 | # Handle each field |
73 | 73 | for (field_name, field_value) in d["fields"].iteritems(): |
74 | 74 | if isinstance(field_value, str): |
75 | | field_value = smart_unicode(field_value, options.get("encoding", settings.DEFAULT_CHARSET), strings_only=True) |
| 75 | field_value = smart_unicode(field_value, options.get("encoding", settings.OUTPUT_CHARSET), strings_only=True) |
76 | 76 | |
77 | 77 | field = Model._meta.get_field(field_name) |
78 | 78 | |
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py
index 667faf7..fa0c794 100644
a
|
b
|
class Serializer(base.Serializer):
|
22 | 22 | """ |
23 | 23 | Start serialization -- open the XML document and the root element. |
24 | 24 | """ |
25 | | self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET)) |
| 25 | self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.OUTPUT_CHARSET)) |
26 | 26 | self.xml.startDocument() |
27 | 27 | self.xml.startElement("django-objects", {"version" : "1.0"}) |
28 | 28 | |
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 5439aa6..307dc83 100644
a
|
b
|
class QueryDict(MultiValueDict):
|
139 | 139 | This is immutable unless you create a copy of it. |
140 | 140 | |
141 | 141 | Values retrieved from this class are converted from the given encoding |
142 | | (DEFAULT_CHARSET by default) to unicode. |
| 142 | (OUTPUT_CHARSET by default) to unicode. |
143 | 143 | """ |
144 | 144 | def __init__(self, query_string, mutable=False, encoding=None): |
145 | 145 | MultiValueDict.__init__(self) |
… |
… |
class QueryDict(MultiValueDict):
|
147 | 147 | # *Important*: do not import settings any earlier because of note |
148 | 148 | # in core.handlers.modpython. |
149 | 149 | from django.conf import settings |
150 | | encoding = settings.DEFAULT_CHARSET |
| 150 | encoding = settings.OUTPUT_CHARSET |
151 | 151 | self.encoding = encoding |
152 | 152 | self._mutable = True |
153 | 153 | for key, value in parse_qsl((query_string or ''), True): # keep_blank_values=True |
… |
… |
class HttpResponse(object):
|
259 | 259 | def __init__(self, content='', mimetype=None, status=None, |
260 | 260 | content_type=None): |
261 | 261 | from django.conf import settings |
262 | | self._charset = settings.DEFAULT_CHARSET |
| 262 | self._charset = settings.OUTPUT_CHARSET |
263 | 263 | if mimetype: |
264 | 264 | content_type = mimetype # For backwards compatibility |
265 | 265 | if not content_type: |
266 | 266 | content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, |
267 | | settings.DEFAULT_CHARSET) |
| 267 | settings.OUTPUT_CHARSET) |
268 | 268 | if not isinstance(content, basestring) and hasattr(content, '__iter__'): |
269 | 269 | self._container = content |
270 | 270 | self._is_string = False |
diff --git a/django/test/client.py b/django/test/client.py
index 67d3aa9..af2699f 100644
a
|
b
|
def encode_multipart(boundary, data):
|
61 | 61 | as an application/octet-stream; otherwise, str(value) will be sent. |
62 | 62 | """ |
63 | 63 | lines = [] |
64 | | to_str = lambda s: smart_str(s, settings.DEFAULT_CHARSET) |
| 64 | to_str = lambda s: smart_str(s, settings.OUTPUT_CHARSET) |
65 | 65 | for (key, value) in data.items(): |
66 | 66 | if isinstance(value, file): |
67 | 67 | lines.extend([ |
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index bcc5e4b..537a44c 100644
a
|
b
|
def to_language(locale):
|
65 | 65 | class DjangoTranslation(gettext_module.GNUTranslations): |
66 | 66 | """ |
67 | 67 | This class sets up the GNUTranslations context with regard to output |
68 | | charset. Django uses a defined DEFAULT_CHARSET as the output charset on |
| 68 | charset. Django uses a defined OUTPUT_CHARSET as the output charset on |
69 | 69 | Python 2.4. With Python 2.3, use DjangoTranslation23. |
70 | 70 | """ |
71 | 71 | def __init__(self, *args, **kw): |
diff --git a/docs/email.txt b/docs/email.txt
index 7f2eef6..7ea9843 100644
a
|
b
|
settings, if set, are used to authenticate to the SMTP server, and the
|
28 | 28 | .. note:: |
29 | 29 | |
30 | 30 | The character set of e-mail sent with ``django.core.mail`` will be set to |
31 | | the value of your `DEFAULT_CHARSET`_ setting. |
| 31 | the value of your `OUTPUT_CHARSET`_ setting. |
32 | 32 | |
33 | | .. _DEFAULT_CHARSET: ../settings/#default-charset |
| 33 | .. _OUTPUT_CHARSET: ../settings/#output-charset |
34 | 34 | .. _EMAIL_HOST: ../settings/#email-host |
35 | 35 | .. _EMAIL_PORT: ../settings/#email-port |
36 | 36 | .. _EMAIL_HOST_USER: ../settings/#email-host-user |
diff --git a/docs/request_response.txt b/docs/request_response.txt
index 4dcdf10..cca6975 100644
a
|
b
|
All attributes except ``session`` should be considered read-only.
|
42 | 42 | **New in Django development version** |
43 | 43 | |
44 | 44 | A string representing the current encoding used to decode form submission |
45 | | data (or ``None``, which means the ``DEFAULT_CHARSET`` setting is used). |
| 45 | data (or ``None``, which means the ``OUTPUT_CHARSET`` setting is used). |
46 | 46 | You can write to this attribute to change the encoding used when accessing |
47 | 47 | the form data. Any subsequent attribute accesses (such as reading from |
48 | 48 | ``GET`` or ``POST``) will use the new ``encoding`` value. Useful if you |
49 | | know the form data is not in the ``DEFAULT_CHARSET`` encoding. |
| 49 | know the form data is not in the ``OUTPUT_CHARSET`` encoding. |
50 | 50 | |
51 | 51 | ``GET`` |
52 | 52 | A dictionary-like object containing all given HTTP GET parameters. See the |
diff --git a/docs/settings.txt b/docs/settings.txt
index fb2e04f..f509ca7 100644
a
|
b
|
site with ``DEBUG`` turned on.
|
394 | 394 | DEFAULT_CHARSET |
395 | 395 | --------------- |
396 | 396 | |
397 | | Default: ``'utf-8'`` |
398 | | |
399 | | Default charset to use for all ``HttpResponse`` objects, if a MIME type isn't |
400 | | manually specified. Used with ``DEFAULT_CONTENT_TYPE`` to construct the |
401 | | ``Content-Type`` header. |
| 397 | ``DEFAULT_CHARSET`` has been deprecated in favor of ``OUTPUT_CHARSET``. |
402 | 398 | |
403 | 399 | DEFAULT_CONTENT_TYPE |
404 | 400 | -------------------- |
… |
… |
DEFAULT_CONTENT_TYPE
|
406 | 402 | Default: ``'text/html'`` |
407 | 403 | |
408 | 404 | Default content type to use for all ``HttpResponse`` objects, if a MIME type |
409 | | isn't manually specified. Used with ``DEFAULT_CHARSET`` to construct the |
| 405 | isn't manually specified. Used with ``OUTPUT_CHARSET`` to construct the |
410 | 406 | ``Content-Type`` header. |
411 | 407 | |
412 | 408 | DEFAULT_FROM_EMAIL |
… |
… |
locales have different formats. For example, U.S. English would say
|
733 | 729 | See `allowed date format strings`_. See also ``DATE_FORMAT``, |
734 | 730 | ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``YEAR_MONTH_FORMAT``. |
735 | 731 | |
| 732 | OUTPUT_CHARSET |
| 733 | -------------- |
| 734 | |
| 735 | **New in Django development version** |
| 736 | |
| 737 | Default: ``'utf-8'`` |
| 738 | |
| 739 | Default charset to use for all ``HttpResponse`` objects, if a MIME type isn't |
| 740 | manually specified. Used with ``DEFAULT_CONTENT_TYPE`` to construct the |
| 741 | ``Content-Type`` header. This setting deprecates ``DEFAULT_CHARSET``. |
| 742 | |
736 | 743 | PREPEND_WWW |
737 | 744 | ----------- |
738 | 745 | |
diff --git a/docs/templates_python.txt b/docs/templates_python.txt
index 43ef016..e940c81 100644
a
|
b
|
pieces of the templating system and then, *before* you call any of the
|
1453 | 1453 | templating functions, call ``django.conf.settings.configure()`` with any |
1454 | 1454 | settings you wish to specify. You might want to consider setting at least |
1455 | 1455 | ``TEMPLATE_DIRS`` (if you're going to use template loaders), |
1456 | | ``DEFAULT_CHARSET`` (although the default of ``utf-8`` is probably fine) and |
| 1456 | ``OUTPUT_CHARSET`` (although the default of ``utf-8`` is probably fine) and |
1457 | 1457 | ``TEMPLATE_DEBUG``. All available settings are described in the |
1458 | 1458 | `settings documentation`_, and any setting starting with *TEMPLATE_* |
1459 | 1459 | is of obvious interest. |
diff --git a/docs/unicode.txt b/docs/unicode.txt
index a2c4e7f..cbbef2b 100644
a
|
b
|
You can use Unicode strings, or you can use normal strings (sometimes called
|
60 | 60 | If your code only uses ASCII data, it's safe to use your normal strings, |
61 | 61 | passing them around at will, because ASCII is a subset of UTF-8. |
62 | 62 | |
63 | | Don't be fooled into thinking that if your ``DEFAULT_CHARSET`` setting is set |
| 63 | Don't be fooled into thinking that if your ``OUTPUT_CHARSET`` setting is set |
64 | 64 | to something other than ``'utf-8'`` you can use that other encoding in your |
65 | | bytestrings! ``DEFAULT_CHARSET`` only applies to the strings generated as |
| 65 | bytestrings! ``OUTPUT_CHARSET`` only applies to the strings generated as |
66 | 66 | the result of template rendering (and e-mail). Django will always assume UTF-8 |
67 | 67 | encoding for internal bytestrings. The reason for this is that the |
68 | | ``DEFAULT_CHARSET`` setting is not actually under your control (if you are the |
| 68 | ``OUTPUT_CHARSET`` setting is not actually under your control (if you are the |
69 | 69 | application developer). It's under the control of the person installing and |
70 | 70 | using your application -- and if that person chooses a different setting, your |
71 | 71 | code must still continue to work. Ergo, it cannot rely on that setting. |
… |
… |
setting to the encoding of the files on disk. When Django reads in a template
|
293 | 293 | file, it will convert the data from this encoding to Unicode. (``FILE_CHARSET`` |
294 | 294 | is set to ``'utf-8'`` by default.) |
295 | 295 | |
296 | | The ``DEFAULT_CHARSET`` setting controls the encoding of rendered templates. |
| 296 | The ``OUTPUT_CHARSET`` setting controls the encoding of rendered templates. |
297 | 297 | This is set to UTF-8 by default. |
298 | 298 | |
299 | 299 | Template tags and filters |
… |
… |
two fields will return their members as Unicode data. All other attributes and
|
345 | 345 | methods of ``HttpRequest`` return data exactly as it was submitted by the |
346 | 346 | client. |
347 | 347 | |
348 | | By default, the ``DEFAULT_CHARSET`` setting is used as the assumed encoding |
| 348 | By default, the ``OUTPUT_CHARSET`` setting is used as the assumed encoding |
349 | 349 | for form data. If you need to change this for a particular form, you can set |
350 | 350 | the ``encoding`` attribute on an ``HttpRequest`` instance. For example:: |
351 | 351 | |