Python 在Django settings.py文件中指定STATIC\u ROOT STATIC\u URL时出错

Python 在Django settings.py文件中指定STATIC\u ROOT STATIC\u URL时出错,python,django,Python,Django,我是django和web应用程序开发新手。 我正在尝试将css添加到我的演示站点(在windows7上使用django v1.4),并得到以下错误。我尝试了所有的方法,浪费了将近3-4个小时。仍然无法解决它 我想我犯了一些愚蠢的错误,谁能告诉我我在哪里犯了错误 或者当我这样做的时候 http://localhost:8000/static/css.css 或 我得到: TypeError:强制使用Unicode:需要字符串或缓冲区,找到元组 setting.py文件是: import os P

我是django和web应用程序开发新手。 我正在尝试将css添加到我的演示站点(在windows7上使用django v1.4),并得到以下错误。我尝试了所有的方法,浪费了将近3-4个小时。仍然无法解决它

我想我犯了一些愚蠢的错误,谁能告诉我我在哪里犯了错误

或者当我这样做的时候

http://localhost:8000/static/css.css

我得到:

TypeError:强制使用Unicode:需要字符串或缓冲区,找到元组

setting.py文件是:

import os
PROJECT_PATH = os.path.abspath(os.curdir).replace('\\', '/')

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE'   : 'django.db.backends.mysql',        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME'     : 'ecomstore',                       # Or path to database file if using sqlite3.
        'USER'     : 'vivek',                           # Not used with sqlite3.
        'PASSWORD' : 'linux',                           # Not used with sqlite3.
        'HOST'     : '',                                # Set to empty string for localhost. Not used with sqlite3.
        'PORT'     : '',                                # Set to empty string for default. Not used with sqlite3.
    }
}

TIME_ZONE     = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID       = 1
USE_I18N      = True
USE_L10N      = True
USE_TZ        = True
MEDIA_ROOT    = ''
MEDIA_URL     = ''
STATIC_ROOT   = os.path.join(PROJECT_PATH,'static').replace('\\', '/'),
STATIC_URL    = '/static/'

STATICFILES_DIRS = (
    os.path.join(PROJECT_PATH, 'static').replace('\\', '/'),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = 'dyi(9i9e*oy#7o#-z$vcnk%d$2)n!)t=3(cqo5=prtp$7e2(*h'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'ecomstore.urls'

WSGI_APPLICATION = 'ecomstore.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(PROJECT_PATH, 'templates').replace('\\', '/'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
删除行末尾的


删除行末尾的

严重吗?你发布截图了吗?真的?真的?你发布截图了吗?真的吗?非常感谢。::::)我没怎么注意到汉克斯我没有注意到
import os
PROJECT_PATH = os.path.abspath(os.curdir).replace('\\', '/')

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE'   : 'django.db.backends.mysql',        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME'     : 'ecomstore',                       # Or path to database file if using sqlite3.
        'USER'     : 'vivek',                           # Not used with sqlite3.
        'PASSWORD' : 'linux',                           # Not used with sqlite3.
        'HOST'     : '',                                # Set to empty string for localhost. Not used with sqlite3.
        'PORT'     : '',                                # Set to empty string for default. Not used with sqlite3.
    }
}

TIME_ZONE     = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID       = 1
USE_I18N      = True
USE_L10N      = True
USE_TZ        = True
MEDIA_ROOT    = ''
MEDIA_URL     = ''
STATIC_ROOT   = os.path.join(PROJECT_PATH,'static').replace('\\', '/'),
STATIC_URL    = '/static/'

STATICFILES_DIRS = (
    os.path.join(PROJECT_PATH, 'static').replace('\\', '/'),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = 'dyi(9i9e*oy#7o#-z$vcnk%d$2)n!)t=3(cqo5=prtp$7e2(*h'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'ecomstore.urls'

WSGI_APPLICATION = 'ecomstore.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(PROJECT_PATH, 'templates').replace('\\', '/'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
STATIC_ROOT   = os.path.join(PROJECT_PATH,'static').replace('\\', '/'),