gpt4 book ai didi

python - 异常值 : 'NoneType' object has no attribute 'endswith'

转载 作者:行者123 更新时间:2023-11-28 22:53:57 27 4
gpt4 key购买 nike

是的,我正在尝试根据当前的实时站点设置一个 Django 开发站点。我已经设置了新的 virtualenv 并安装了所有依赖项。我还制作了数据库的副本并进行了新的数据库转储。我现在收到上面的错误,我不知道为什么。

我的 django.wsgi 文件似乎指向 virtalenv。以下是有关该错误的更多信息。

Request Method:     GET
Request URL: http://website.co.uk/
Django Version: 1.3
Exception Type: AttributeError
Exception Value:

'NoneType' object has no attribute 'endswith'

Exception Location: /usr/lib/python2.6/posixpath.py in join, line 67
Python Executable: /usr/bin/python
Python Version: 2.6.5
Python Path:

['/var/www/website.co.uk/website/',
'/var/www/website.co.uk/website/apps',
'/var/www/website.co.uk/website/apps',
'/var/www/website.co.uk',
'/var/www/website.co.uk/lib/python2.6/site-packages/distribute-0.6.10-py2.6.egg',
'/var/www/website.co.uk/lib/python2.6/site-packages/pip-1.4.1-py2.6.egg',
'/usr/lib/python2.6',
'/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk',
'/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload',
'/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL',
'/usr/lib/pymodules/python2.6',
'/usr/local/lib/python2.6/dist-packages',
'/var/www/website.co.uk/lib/python2.6/site-packages',
'/var/www/website.co.uk/lib/python2.6/site-packages/PIL']


FULL TRACEBACK

Environment:


Request Method: GET
Request URL: http://website.co.uk/

Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.sites',
'satchmo_store.shop',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.comments',
'django.contrib.sessions',
'django.contrib.sitemaps',
'registration',
'sorl.thumbnail',
'keyedcache',
'livesettings',
'l10n',
'tax',
'tax.modules.no',
'tax.modules.area',
'tax.modules.percent',
'shipping',
'product',
'payment',
'satchmo_ext.satchmo_toolbar',
'satchmo_utils',
'app_plugins',
'authority',
'foodies',
'localsite',
'django_extensions',
'south',
'django_wysiwyg',
'mptt',
'tinymce',
'tagging',
'pages',
'filebrowser',
'html5lib']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.locale.LocaleMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
250. for pattern in self.url_patterns:
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in _get_url_patterns
279. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in _get_urlconf_module
274. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/var/www/website.co.uk/website_app/urls.py" in <module>
4. from satchmo_store.urls import urlpatterns
File "/var/www/website.co.uk/lib/python2.6/site-packages/satchmo_store/urls/__init__.py" in <module>
28. from default import urlpatterns as defaultpatterns
File "/var/www/website.co.uk/lib/python2.6/site-packages/satchmo_store/urls/default.py" in <module>
9. admin.autodiscover()
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/__init__.py" in autodiscover
26. import_module('%s.admin' % app)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/var/www/website.co.uk/website_app/foodies/admin.py" in <module>
2. from foodies.models import *
File "/var/www/website.co.uk/website_app/foodies/models.py" in <module>
24. from pages.admin import *
File "/var/www/website.co.uk/lib/python2.6/site-packages/pages/admin/__init__.py" in <module>
3. from pages import settings
File "/var/www/website.co.uk/lib/python2.6/site-packages/pages/settings.py" in <module>
144. join(_media_url, 'pages/'))
File "/usr/lib/python2.6/posixpath.py" in join
67. elif path == '' or path.endswith('/'):

Exception Type: AttributeError at /
Exception Value: 'NoneType' object has no attribute 'endswith'

来自 pages/settings.py 的代码

    # -*- coding: utf-8 -*-
"""Convenience module that provides default settings for the ``pages``
application when the project ``settings`` module does not contain
the appropriate settings."""
from os.path import join
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

# The path to default template
DEFAULT_PAGE_TEMPLATE = getattr(settings, 'DEFAULT_PAGE_TEMPLATE', None)
if DEFAULT_PAGE_TEMPLATE is None:
raise ImproperlyConfigured('Please make sure you specified a '
'DEFAULT_PAGE_TEMPLATE setting.')

# PAGE_TEMPLATES is a list of tuples that specifies the which templates
# are available in the ``pages`` admin. Templates should be assigned in
# the following format:
#
# PAGE_TEMPLATES = (
# ('pages/nice.html', 'nice one'),
# ('pages/cool.html', 'cool one'),
# )
#
# One can also assign a callable (which should return the tuple) to this
# variable to achieve dynamic template list e.g.:
#
# def _get_templates():
# ...
#
# PAGE_TEMPLATES = _get_templates

PAGE_TEMPLATES = getattr(settings, 'PAGE_TEMPLATES', None)
if (PAGE_TEMPLATES is None and
not (isinstance(PAGE_TEMPLATES, str) or
isinstance(PAGE_TEMPLATES, unicode))):
PAGE_TEMPLATES = ()

# The callable that is used by the CMS
def get_page_templates():
if callable(PAGE_TEMPLATES):
return PAGE_TEMPLATES()
else:
return PAGE_TEMPLATES

# Set ``PAGE_TAGGING`` to ``False`` if you do not wish to use the
# ``django-tagging`` application.
PAGE_TAGGING = getattr(settings, 'PAGE_TAGGING', False)
if PAGE_TAGGING and "tagging" not in getattr(settings, 'INSTALLED_APPS', []):
raise ImproperlyConfigured('django-tagging could not be found.\n'
'Please make sure you\'ve installed it '
'correctly or disable the tagging feature by '
'setting PAGE_TAGGING to False.')

# Set this to ``True`` if you wish to use the ``django-tinymce`` application.
PAGE_TINYMCE = getattr(settings, 'PAGE_TINYMCE', False)
if PAGE_TINYMCE and "tinymce" not in getattr(settings, 'INSTALLED_APPS', []):
raise ImproperlyConfigured('django-tinymce could not be found.\n'
'Please make sure you\'ve installed it '
'correctly or disable the tinymce feature by '
'setting PAGE_TINYMCE to False.')

# Set ``PAGE_UNIQUE_SLUG_REQUIRED`` to ``True`` to enforce unique slug names
# for all pages.
PAGE_UNIQUE_SLUG_REQUIRED = getattr(settings, 'PAGE_UNIQUE_SLUG_REQUIRED',
False)

# Set ``PAGE_CONTENT_REVISION`` to ``False`` to disable the recording of
# pages revision information in the database
PAGE_CONTENT_REVISION = getattr(settings, 'PAGE_CONTENT_REVISION', True)

# A list tuples that defines the languages that pages can be translated into.
#
# gettext_noop = lambda s: s
#
# PAGE_LANGUAGES = (
# ('zh-cn', gettext_noop('Chinese Simplified')),
# ('fr-ch', gettext_noop('Swiss french')),
# ('en-us', gettext_noop('US English')),
#)
PAGE_LANGUAGES = getattr(settings, 'PAGE_LANGUAGES', settings.LANGUAGES)

# Defines which language should be used by default. If
# ``PAGE_DEFAULT_LANGUAGE`` not specified, then project's
# ``settings.LANGUAGE_CODE`` is used
PAGE_DEFAULT_LANGUAGE = getattr(settings, 'PAGE_DEFAULT_LANGUAGE',
settings.LANGUAGE_CODE)

extra = [('can_freeze', 'Can freeze page',)]
for lang in PAGE_LANGUAGES:
extra.append(
('can_manage_' + lang[0].replace('-', '_'),
'Manage' + ' ' + lang[1])
)

PAGE_EXTRA_PERMISSIONS = getattr(settings, 'PAGE_EXTRA_PERMISSIONS', extra)

# PAGE_LANGUAGE_MAPPING should be assigned a function that takes a single
# argument, the language code of the incoming browser request. This function
# maps the incoming client language code to another language code, presumably
# one for which you have translation strings. This is most useful if your
# project only has one set of translation strings for a language like Chinese,
# which has several variants like ``zh-cn``, ``zh-tw``, ``zh-hk`, etc., but
# you want to provide your Chinese translations to all Chinese browsers, not
# just those with the exact ``zh-cn``
# locale.
#
# Enable that behavior here by assigning the following function to the
# PAGE_LANGUAGE_MAPPING variable.
#
# def language_mapping(lang):
# if lang.startswith('zh'):
# return 'zh-cn'
# return lang
# PAGE_LANGUAGE_MAPPING = language_mapping
PAGE_LANGUAGE_MAPPING = getattr(settings, 'PAGE_LANGUAGE_MAPPING', lambda l: l)

# Set SITE_ID to the id of the default ``Site`` instance to be used on
# installations where content from a single installation is served on
# multiple domains via the ``django.contrib.sites`` framework.
SITE_ID = getattr(settings, 'SITE_ID', 1)

# Set PAGE_USE_SITE_ID to ``True`` to make use of the ``django.contrib.sites``
# framework
PAGE_USE_SITE_ID = getattr(settings, 'PAGE_USE_SITE_ID', False)

# Set PAGE_USE_LANGUAGE_PREFIX to ``True`` to make the ``get_absolute_url``
# method to prefix the URLs with the language code
PAGE_USE_LANGUAGE_PREFIX = getattr(settings, 'PAGE_USE_LANGUAGE_PREFIX',
False)

# Assign a list of placeholders to PAGE_CONTENT_REVISION_EXCLUDE_LIST
# to exclude them from the revision process.
PAGE_CONTENT_REVISION_EXCLUDE_LIST = getattr(settings,
'PAGE_CONTENT_REVISION_EXCLUDE_LIST', ()
)

# Set ``PAGE_SANITIZE_USER_INPUT`` to ``True`` to sanitize the user input with
# ``html5lib``
PAGE_SANITIZE_USER_INPUT = getattr(settings, 'PAGE_SANITIZE_USER_INPUT', False)

# URL that handles pages media and uses <MEDIA_ROOT>/pages by default.
_media_url = getattr(settings, "STATIC_URL", settings.MEDIA_URL)
PAGES_MEDIA_URL = getattr(settings, 'PAGES_MEDIA_URL',
join(_media_url, 'pages/'))

# Hide the slug's of the first root page ie: ``/home/`` becomes ``/``
PAGE_HIDE_ROOT_SLUG = getattr(settings, 'PAGE_HIDE_ROOT_SLUG', False)

# Show the publication start date field in the admin. Allows for future dating
# Changing the ``PAGE_SHOW_START_DATE`` from ``True`` to ``False``
# after adding data could cause some weirdness. If you must do this, you
# should update your database to correct any future dated pages.
PAGE_SHOW_START_DATE = getattr(settings, 'PAGE_SHOW_START_DATE', False)

# Show the publication end date field in the admin, allows for page expiration
# Changing ``PAGE_SHOW_END_DATE`` from ``True`` to ``False`` after adding
# data could cause some weirdness. If you must do this, you should update
# your database and null any pages with ``publication_end_date`` set.
PAGE_SHOW_END_DATE = getattr(settings, 'PAGE_SHOW_END_DATE', False)

# ``PAGE_CONNECTED_MODELS`` allows you to specify a model and form for this
# model into your settings to get an automatic form to create
# and directly link a new instance of this model with your page in the admin.
#
# Here is an example:
#
# PAGE_CONNECTED_MODELS = [
# {'model':'documents.models.Document',
# 'form':'documents.models.DocumentForm'},
# ]
#
PAGE_CONNECTED_MODELS = getattr(settings, 'PAGE_CONNECTED_MODELS', False)

# The page link filter enable a output filter on you content links. The goal
# is to transform special page class into real links at the last moment.
# This ensure that even if you have moved a page, the URL will remain correct.
PAGE_LINK_FILTER = getattr(settings, 'PAGE_LINK_FILTER', False)

# This setting is a function that can be defined if you need to pass extra
# context data to the pages templates.
PAGE_EXTRA_CONTEXT = getattr(settings, 'PAGE_EXTRA_CONTEXT', None)

# This setting is the name of a sub-folder where uploaded content, like
# placeholder images, is placed.
PAGE_UPLOAD_ROOT = getattr(settings, 'PAGE_UPLOAD_ROOT', 'upload')

我希望这足以继续下去,但我真的不知道为什么会出现这种情况!

谢谢

最佳答案

在这节中:

# URL that handles pages media and uses <MEDIA_ROOT>/pages by default.
_media_url = getattr(settings, "STATIC_URL", settings.MEDIA_URL)
PAGES_MEDIA_URL = getattr(settings, 'PAGES_MEDIA_URL',
join(_media_url, 'pages/'))

STATIC_URL 不在设置中,settings.MEDIA_URLNone。看来您需要修复设置。

关于python - 异常值 : 'NoneType' object has no attribute 'endswith' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18744584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com