winston_smith winston_smith - 5 months ago 39
Python Question

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

I started learning a Django tutorial , and when I want to run

python manage.py runserver


there is a lots of error
Traceback (most recent call last):
File "manage.py", line 10, in
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
from django.db.migrations.executor import MigrationExecutor
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in
from .loader import MigrationLoader
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in
from django.db.migrations.recorder import MigrationRecorder
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in
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
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
from django.db.migrations.executor import MigrationExecutor
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in
from .loader import MigrationLoader
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in
from django.db.migrations.recorder import MigrationRecorder
File "/home/sarfraz/.local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in
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/"
)

Hope it was clear.

Answer

Add a comma to the end of the value closed between parenthesis otherwise it is not a tuple:

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

it should solve the issue. Hope that it helps.

Comments