1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #23919 -- Removed Python 2 notes in docs.

This commit is contained in:
Tim Graham
2017-01-18 11:51:29 -05:00
committed by GitHub
parent c716fe8782
commit f6acd1d271
61 changed files with 139 additions and 731 deletions

View File

@@ -26,10 +26,6 @@ directory whose name doesn't begin with an underscore. For example::
tests.py
views.py
On Python 2, be sure to include ``__init__.py`` files in both the
``management`` and ``management/commands`` directories as done above or your
command will not be detected.
In this example, the ``closepoll`` command will be made available to any project
that includes the ``polls`` application in :setting:`INSTALLED_APPS`.

View File

@@ -704,14 +704,12 @@ smoothly:
a field that's similar to what you want and extend it a little bit,
instead of creating an entirely new field from scratch.
2. Put a ``__str__()`` (``__unicode__()`` on Python 2) method on the class you're
wrapping up as a field. There are a lot of places where the default
behavior of the field code is to call
2. Put a ``__str__()`` method on the class you're wrapping up as a field. There
are a lot of places where the default behavior of the field code is to call
:func:`~django.utils.encoding.force_text` on the value. (In our
examples in this document, ``value`` would be a ``Hand`` instance, not a
``HandField``). So if your ``__str__()`` method (``__unicode__()`` on
Python 2) automatically converts to the string form of your Python object,
you can save yourself a lot of work.
``HandField``). So if your ``__str__()`` method automatically converts to
the string form of your Python object, you can save yourself a lot of work.
Writing a ``FileField`` subclass
================================

View File

@@ -250,19 +250,3 @@ details about the default templates:
* :ref:`http_internal_server_error_view`
* :ref:`http_forbidden_view`
* :ref:`http_bad_request_view`
Python Options
==============
It's strongly recommended that you invoke the Python process running your
Django application using the `-R`_ option or with the :envvar:`PYTHONHASHSEED`
environment variable set to ``random``. This option is enabled by default
starting with Python 3.3.
These options help protect your site from denial-of-service (DoS)
attacks triggered by carefully crafted inputs. Such an attack can
drastically increase CPU usage by causing worst-case performance when
creating ``dict`` instances. See `oCERT advisory #2011-003
<http://www.ocert.org/advisories/ocert-2011-003.html>`_ for more information.
.. _-r: https://docs.python.org/2/using/cmdline.html#cmdoption-R

View File

@@ -53,26 +53,6 @@ mention:
about escaping strings with quotes or commas in them. Just pass
``writerow()`` your raw strings, and it'll do the right thing.
.. admonition:: Handling Unicode on Python 2
Python 2's :mod:`csv` module does not support Unicode input. Since Django
uses Unicode internally this means strings read from sources such as
:class:`~django.http.HttpRequest` are potentially problematic. There are a
few options for handling this:
* Manually encode all Unicode objects to a compatible encoding.
* Use the ``UnicodeWriter`` class provided in the `csv module's examples
section`_.
* Use the `python-unicodecsv module`_, which aims to be a drop-in
replacement for :mod:`csv` that gracefully handles Unicode.
For more information, see the Python documentation of the :mod:`csv` module.
.. _`csv module's examples section`: https://docs.python.org/2/library/csv.html#examples
.. _`python-unicodecsv module`: https://github.com/jdunck/python-unicodecsv
.. _streaming-csv-files:
Streaming large CSV files
@@ -89,7 +69,6 @@ the assembly and transmission of a large CSV file::
import csv
from django.utils.six.moves import range
from django.http import StreamingHttpResponse
class Echo(object):