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

Python Django manage.py migrate SyntaxError: Generator expression must be parenthezised is an error which occurs because of compatibility problems between Django and Python.

In today’s blog post I am going to present an annoying and confusing python error and explain why this error is taking place and how to fix it, with a set of possible fixes.

Exploring the python Django manage.py migrate SyntaxError: Generator expression must be parenthezised

This is an error which occurs because of compatibility problems between Django and Python.

Beware of mixing between errors. Double check if the error message looks like the error message bellow, then continue.

                                                                       #
SyntaxError: Generator expression must be parenthesized
                                                                       #

Bellow are a couple of methods that can solve the issue

Solution 1 : Upgrade Python or Downgrade it

The error is a popular error caused by Django and Python 3.7. Your code is not the cause of this problem.

This problem was fixed in the most recent versions of Python.

The solution here is to upgrade Python to the latest version like Python 3.9 where the problem has been fixed.

Another option is to downgrade Python to Python 3.6, which is a stable version of Python where the issue between Python and Django does not exist.

If this method did not work, please try the method bellow.

Solution 2 : Upgrade Django

If you do not want to upgrade or downgrade python, you can choose to upgrade Django.

You can upgrade Django like this

                                                                       #
pip install -U Django
                                                                       #

You can upgrade to the latest version of Django like this

                                                                       #
pip install -U Django==2.1
                                                                       #

I hope the fixes above fixed your problem. Thank you for reading this blog post to the end.

Summing-up : 

This is the end of our post, I hope this has been helpful and helped you solve the error or at least pointed you in the right direction.

Thank you for reading my blog post to the end, If you want to learn more about the Python programming language, check out the official Python Documentation : https://docs.python.org/3/