python makemigrations

July 1, 2016 421 views
PostgreSQL Python Ubuntu 16.04

when migrate detabase

Traceback (most recent call last):
  File "", line 10, in <module>
  File "/home/alam/myproject/myprojectenv/local/lib/python3.5/site-packages/django/core/management/", line 353, in execute_from_command_line
  File "/home/alam/myproject/myprojectenv/local/lib/python3.5/site-packages/django/core/management/", line 302, in execute
  File "/home/alam/myproject/myprojectenv/local/lib/python3.5/site-packages/django/conf/", line 55, in __getattr__
  File "/home/alam/myproject/myprojectenv/local/lib/python3.5/site-packages/django/conf/", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/alam/myproject/myprojectenv/local/lib/python3.5/site-packages/django/conf/", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/alam/myproject/myprojectenv/lib/python3.5/importlib/", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 658, in exec_module
  File "<frozen importlib._bootstrap_external>", line 764, in get_code
  File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/alam/myproject/myproject/", line 2
    Generated by 'django-admin startproject' using Django 1.9.7.
SyntaxError: invalid syntax
2 Answers

This error indicates that there is a problem in your settings file found at /home/alam/myproject/myproject/ The key part of the message is:

  File "/home/alam/myproject/myproject/", line 2
    Generated by 'django-admin startproject' using Django 1.9.7.
SyntaxError: invalid syntax

When you create a new Django project, the boilerplate at the top of the settings file includes a comment like:

Django settings for foo project.

Generated by 'django-admin startproject' using Django 1.9.7.

For more information on this file, see

For the full list of settings and their values, see

In Python, putting three quotation marks (""") both above and below a block of text makes it a comment that is not evaluated as code. I suspect that you may have accidentally uncommented this text. Make sure it sure it is all commented out.

Have another answer? Share your knowledge.