mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Refs #23919 -- Removed encoding preambles and future imports
This commit is contained in:
parent
397b3705c5
commit
d7b9aaa366
831 changed files with 6 additions and 2066 deletions
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Django documentation build configuration file, created by
|
||||
# sphinx-quickstart on Thu Mar 27 09:06:53 2008.
|
||||
#
|
||||
|
@ -11,8 +9,6 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
from os.path import abspath, dirname, join
|
||||
|
||||
|
|
|
@ -100,10 +100,7 @@ the respective field according to your needs.
|
|||
.. snippet::
|
||||
:filename: 0006_remove_uuid_null.py
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django A.B on YYYY-MM-DD HH:MM
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
@ -154,10 +151,7 @@ the respective field according to your needs.
|
|||
.. snippet::
|
||||
:filename: 0005_populate_uuid_values.py
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django A.B on YYYY-MM-DD HH:MM
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ The ``ContentFile`` class
|
|||
but unlike :class:`~django.core.files.File` it operates on string content
|
||||
(bytes also supported), rather than an actual file. For example::
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
f1 = ContentFile("esta sentencia está en español")
|
||||
|
|
|
@ -310,9 +310,6 @@ class in the migration file, and just pass it to ``RunPython``. Here's an
|
|||
example of using ``RunPython`` to create some initial objects on a ``Country``
|
||||
model::
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
|
|
|
@ -177,8 +177,6 @@ To customize the English formats, a structure like this would be needed::
|
|||
|
||||
where :file:`formats.py` contains custom format definitions. For example::
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
THOUSAND_SEPARATOR = '\xa0'
|
||||
|
||||
to use a non-breaking space (Unicode ``00A0``) as a thousand separator,
|
||||
|
|
|
@ -454,10 +454,7 @@ the file in the right place, suggest a name, and add dependencies for you)::
|
|||
|
||||
Then, open up the file; it should look something like this::
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django A.B on YYYY-MM-DD HH:MM
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -485,9 +482,6 @@ combined values of ``first_name`` and ``last_name`` (we've come to our senses
|
|||
and realized that not everyone has first and last names). All we
|
||||
need to do is use the historical model and iterate over the rows::
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
def combine_names(apps, schema_editor):
|
||||
|
@ -757,26 +751,6 @@ The decorator adds logic to capture and preserve the arguments on their
|
|||
way into your constructor, and then returns those arguments exactly when
|
||||
deconstruct() is called.
|
||||
|
||||
Supporting Python 2 and 3
|
||||
=========================
|
||||
|
||||
In order to generate migrations that support both Python 2 and 3, all string
|
||||
literals used in your models and fields (e.g. ``verbose_name``,
|
||||
``related_name``, etc.), must be consistently either bytestrings or text
|
||||
(unicode) strings in both Python 2 and 3 (rather than bytes in Python 2 and
|
||||
text in Python 3, the default situation for unmarked string literals.)
|
||||
Otherwise running :djadmin:`makemigrations` under Python 3 will generate
|
||||
spurious new migrations to convert all these string attributes to text.
|
||||
|
||||
The easiest way to achieve this is to follow the advice in Django's
|
||||
:doc:`Python 3 porting guide </topics/python3>` and make sure that all your
|
||||
modules begin with ``from __future__ import unicode_literals``, so that all
|
||||
unmarked string literals are always unicode, regardless of Python version. When
|
||||
you add this to an app with existing migrations generated on Python 2, your
|
||||
next run of :djadmin:`makemigrations` on Python 3 will likely generate many
|
||||
changes as it converts all the bytestring attributes to text strings; this is
|
||||
normal and should only happen once.
|
||||
|
||||
Supporting multiple Django versions
|
||||
===================================
|
||||
|
||||
|
|
|
@ -422,8 +422,6 @@ environment.
|
|||
|
||||
For example, you can create ``myproject/jinja2.py`` with this content::
|
||||
|
||||
from __future__ import absolute_import # Python 2 only
|
||||
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.urls import reverse
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue