python manage.py 运行服务器错误 django.core.exceptions.ImproperlyConfigured: T

python manage.py runserver error django.core.exceptions.ImproperlyConfigured: T

我开始学习 Django 教程,当我想 运行

 python manage.py runserver

错误信息如下:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 14, in <module>
    from django.db.migrations.executor import MigrationExecutor
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in <module>
    from .loader import MigrationLoader
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder(object):
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
    class Migration(models.Model):
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 24, in Migration
    app = models.CharField(max_length=255)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1081, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 161, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 108, in __init__
    "Please fix your settings." % setting)
django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a tuple. Please fix your settings.
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 14, in <module>
    from django.db.migrations.executor import MigrationExecutor
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in <module>
    from .loader import MigrationLoader
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder(object):
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
    class Migration(models.Model):
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 24, in Migration
    app = models.CharField(max_length=255)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1081, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 161, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/sarfraz/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 108, in __init__
    "Please fix your settings." % setting)
django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a tuple. Please fix your settings.

And there is the ligne in my project/settings.py 
TEMPLATE_DIRS = (
"/home/sarfraz/django/crepes_bretonnes/templates/"
)

希望清楚。

在括号之间闭合的值的末尾添加一个逗号,否则它不是 tuple:

TEMPLATE_DIRS = ( "/home/sarfraz/django/crepes_bretonnes/templates/", )

应该可以解决问题。希望对你有帮助。