D:\PythonWorkstation\django\django_station\queryset>python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 15, in <module> 省略部门信息..... File "D:\PythonWorkstation\django\django_station\queryset\blog\models.py", line 2 from __future__ import unicode_literals ^ SyntaxError: from __future__ imports must occur at the beginning of the file
解决办法:
将from __future__ import ...这段语句放在代码块最前面即可。
错误代码:
from django.db import models
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
正确示例:
from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible