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

前端 未结 8 1737
慢半拍i
慢半拍i 2020-12-02 22:45

I\'m really new in programming and I wanted to follow the Djangogirls tutorial, but I\'m stucked now. In the tutorial, I am here:

To create a database

相关标签:
8条回答
  • 2020-12-02 22:54

    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.

    0 讨论(0)
  • 2020-12-02 22:55

    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.

    0 讨论(0)
  • 2020-12-02 22:56

    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.

    0 讨论(0)
  • 2020-12-02 23:07

    Follow the below-mentioned steps to fix the issue:

    • Move to the directory where you have installed the virtualenv
    • You will find a directory named lib. Inside that directory, you will find a directory named pythonx.y where x.y is the version of python you are using
    • Now, go to site-packages
    • Then go to the directory django
    • Move to contrib directory
    • Now, go to admin directory. This is where you would find a python file widgets.py
    • Find the following code snippet in that file
                if params:
                    related_url += '?' + '&'.join(
                    related_url += '?' + '&'.join('%s=%s' % (k, v) for k, v in params.items())
                        '%s=%s' % (k, v) for k, v in params.items(),
                    )
    

    You need to change that to the following

                if params:
                    related_url += '?' + '&'.join(
                    related_url += '?' + '&'.join('%s=%s' % (k, v) for k, v in params.items())
    
    

    Save the changes and execute the migrate again.

    0 讨论(0)
  • 2020-12-02 23:08

    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.

    0 讨论(0)
  • 2020-12-02 23:14

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

    pip3 install django --upgrade
    
    0 讨论(0)
提交回复
热议问题