'manage.py shell' settings.py 中给出语法错误


File "/home/jc/tryout/mydjangoproject/mydjangoproject/settings.py", line 1
"""
   ^
SyntaxError: unexpected character after line continuation character

我 settings.py 是:

"""
Django settings for mydjangoproject project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'nurokm67=6qezctkfa-o-g+k$=u$nete3pw)d*q!6j_$g7i#0l'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

我遇到了同样的问题,我只是写:

def__str__(self): 

而不是

def __str__(self):

要解决问题,只需在def__str之间留出一个空格

最新更新