Django Tutorial (Database setup) Question

Cai Gengyang gengyangcai at gmail.com
Sun Sep 27 18:19:46 CEST 2015


I believe I am already in the same directory that contains manage.py , but I still get an error (a syntax error). Checked the lines in settings.py and can't find anything wrong with them either. Posted my entire code below :


CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls

manage.py	mysite

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate

Traceback (most recent call last):

  File "manage.py", line 10, in <module>

    execute_from_command_line(sys.argv)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line

    utility.execute()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute

    settings.INSTALLED_APPS

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__

    self._setup(name)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup

    self._wrapped = Settings(settings_module)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__

    mod = importlib.import_module(self.SETTINGS_MODULE)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module

    __import__(name)

  File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45

    'django.middleware.csrf.CsrfViewMiddleware',

                                              ^

SyntaxError: invalid syntax

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ 





On Monday, September 28, 2015 at 12:09:04 AM UTC+8, Joel Goldstick wrote:
> On Sun, Sep 27, 2015 at 3:32 AM, Cai Gengyang <gengy... at gmail.com> wrote:
> Hello all !
> 
> 
> 
> So I am going through the (Database setup) chapter of this tutorial (https://docs.djangoproject.com/en/1.8/intro/tutorial01/) --- Its the section right after the first chapter on "Creating a project"
> 
> 
> 
> I opened up mysite/settings.py as per the instructions on the Django tutorial.
> 
> 
> 
> However, when I try to run the following command : $ python manage.py migrate to create the tables in the database,
> 
> 
> 
> CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate ---- input
> 
> 
> 
> I get the following error message :
> 
> 
> 
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'manage.py': [Errno 2] No such file or directory ---- output
> 
> 
> 
> Any idea how to solve this issue?
> 
> 
> 
> Thanks a lot !
> 
> 
> 
> You need to be in the directory that contains manage.py 
> Gengyang
> 
> --
> 
> https://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> 
> 
> -- 
> 
> 
> 
> Joel Goldstick
> http://joelgoldstick.com


More information about the Python-list mailing list