SyntaxError: Generator expression must be parenthezised / python manage.py migrate

我怕爱的太早我们不能终老 提交于 2019-11-28 06:44:34

You’re not doing anything wrong; this is a problem between Django and Python 3.7. Django has a fix, but that fix hasn’t made it into a new version yet.

You can install the stable version of Python, Python 3.6, in the meantime.

Also, upgrading Django solved my problem

On your terminal,

$ pip install -U Django

or see here

This is a known incompatibility between Django and Python 3.7. A fix has already been merged into Django 2.x branches and backported into 1.11 branch.

To solve this issue, simply update Django to at least version 1.11.17 (or 2.x) or you can downgrade Python to version 3.6.

The Django Girls tutorial version in English has just switched to Django 2.0 which should make it compatible to Python 3.7. (Django 2.0 includes a backport of the fix mentioned in Ry-'s answer.)

So everyone beginning the tutorial now should be fine with Python 3.7.

If you've already begun the tutorial you'd have to start again at the Django installation chapter. You'll want to do that in a new directory (either delete or rename your current djangogirls directory or choose a different name for the new directory) as the files generated by

django-admin print startproject mysite .

depend on the Django version in use.

Rakesh Paruchuri

Only Django==2.2 will be supported to Python 3.7 so upgrading you Django Version will solve your problem

pip3 install django --upgrade

Per Django's FAQ, Django 1.11.x is not compatible with Python 3.7.

Django 1.11.x reached end of mainstream support on December 2, 2017 and it receives only data loss and security fixes until its end of life.

As all of the above answers already suggesting that there's a miss match between Django and Python version.
While creating a virtual environment, please run the following command

python3.6 -m venv myenv

It will use Python3.6 while creating your virtual environment.
Now you can install all the dependencies in this virtual environment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!