@@ -638,6 +638,26 @@ The decorator adds logic to capture and preserve the arguments on their
638
638
way into your constructor, and then returns those arguments exactly when
639
639
deconstruct() is called.
640
640
641
+ Supporting Python 2 and 3
642
+ -------------------------
643
+
644
+ In order to generate migrations that support both Python 2 and 3, all string
645
+ literals used in your models and fields (e.g. ``verbose_name``,
646
+ ``related_name``, etc.), must be consistently either bytestrings or text
647
+ (unicode) strings in both Python 2 and 3 (rather than bytes in Python 2 and
648
+ text in Python 3, the default situation for unmarked string literals.)
649
+ Otherwise running :djadmin:`makemigrations` under Python 3 will generate
650
+ spurious new migrations to convert all these string attributes to text.
651
+
652
+ The easiest way to achieve this is to follow the advice in Django's
653
+ :doc:`Python 3 porting guide </topics/python3>` and make sure that all your
654
+ modules begin with ``from __future__ import unicode_literals``, so that all
655
+ unmarked string literals are always unicode, regardless of Python version. When
656
+ you add this to an app with existing migrations generated on Python 2, your
657
+ next run of :djadmin:`makemigrations` on Python 3 will likely generate many
658
+ changes as it converts all the bytestring attributes to text strings; this is
659
+ normal and should only happen once.
660
+
641
661
.. _upgrading-from-south:
642
662
643
663
Upgrading from South
0 commit comments