gpt4 book ai didi

python - 安装 askbot 后 Django 应用程序未运行

转载 作者:太空宇宙 更新时间:2023-11-04 10:49:06 24 4
gpt4 key购买 nike

在安装 askbot 之前,该应用程序运行良好。我检查了他们的文档并将 askbot 安装为可插入应用程序。而且我还合并了设置和网址。现在论坛部分(askbot 应用程序)工作正常,但包括索引在内的其他部分已经崩溃。

错误如下:

    AttributeError at /
'Template' object has no attribute 'nodelist'
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.3.7
Exception Type: AttributeError
Exception Value:
'Template' object has no attribute 'nodelist'
Exception Location: /home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/loader_tags.py in render, line 116
Python Executable: /home/djangouser/Documents/djprojs/qnet/dj1.3/bin/python
Python Version: 2.7.3
Python Path:
['/home/djangouser/Documents/Workspace/Qnet/Qnet',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/home/djangouser/Documents/Workspace/Qnet',
'/home/djangouser/Documents/Workspace/Qnet/Qnet/peer',
'/home/djangouser/Documents/Workspace/Qnet/Qnet',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/site-packages/stdimage',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
'/usr/share/eclipse/plugins/org.python.pydev_2.7.0.2012080220/pysrc/pydev_sitecustomize',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/plat-linux2',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/lib-tk',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/lib-old',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages',
'/home/djangouser/Documents/Workspace/sampleproj/sampleproj',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/PIL',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/plat-linux2',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/lib-tk',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/lib/python2.7/lib-old',
'/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/askbot/deps']
Server time: Fri, 1 Mar 2013 05:44:14 -0600

回溯如下

    Environment:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.3.7
Python Version: 2.7.3
Installed Applications:
['longerusername',
'django.contrib.auth',
'django.contrib.admin',
'pagination',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'django.contrib.messages',
'django.contrib.humanize',
'django.contrib.sitemaps',
'askbot',
'south',
'askbot.deps.livesettings',
'keyedcache',
'robots',
'django_countries',
'djcelery',
'djkombu',
'followit',
'tinymce',
'group_messaging',
'postman',
'peer']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware',
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'askbot.middleware.forum_mode.ForumModeMiddleware',
'askbot.middleware.cancel.CancelActionMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'askbot.middleware.view_log.ViewLogMiddleware',
'askbot.middleware.spaceless.SpacelessMiddleware')


Traceback:
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/djangouser/Documents/Workspace/Qnet/Qnet/peer/views.py" in index
71. return render_to_response('index.html', context_instance=RequestContext(request))
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
188. return t.render(context_instance)
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/base.py" in render
123. return self._render(context)
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/base.py" in render_node
757. return node.render(context)
File "/home/djangouser/Documents/djprojs/qnet/dj1.3/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
116. for node in compiled_parent.nodelist:

Exception Type: AttributeError at /
Exception Value: 'Template' object has no attribute 'nodelist'

settings.py的内容是 # QNET 项目的 Django 设置。

    ###FOR ASKBOT
import os.path
import logging
import sys
import askbot
import site


#this line is added so that we can import pre-packaged askbot dependencies
ASKBOT_ROOT = os.path.abspath(os.path.dirname(askbot.__file__))
site.addsitedir(os.path.join(ASKBOT_ROOT, 'deps'))
INTERNAL_IPS = ('127.0.0.1',)
###END ASKBOT


DEBUG = True
TEMPLATE_DEBUG = False;#keep false when debugging jinja2 templates

ADMINS = (
# ('', ''),
)

MANAGERS = ADMINS

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

###FOR ASKBOT
#outgoing mail server settings
SERVER_EMAIL = ''
DEFAULT_FROM_EMAIL = ''
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_SUBJECT_PREFIX = ''
EMAIL_HOST=''
EMAIL_PORT=''
EMAIL_USE_TLS=False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

#incoming mail settings
#after filling out these settings - please
#go to the site's live settings and enable the feature
#"Email settings" -> "allow asking by email"
#
# WARNING: command post_emailed_questions DELETES all
# emails from the mailbox each time
# do not use your personal mail box here!!!
#
IMAP_HOST = ''
IMAP_HOST_USER = ''
IMAP_HOST_PASSWORD = ''
IMAP_PORT = ''
IMAP_USE_TLS = False
###END ASKBOT

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.3/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = '/home/djangouser/Desktop/QNET/media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = '/home/djangouser/Desktop/QNET/static/'

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

###FOR ASKBOT
PROJECT_ROOT = os.path.dirname(__file__)
###END ASKBOT

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
'/home/djangouser/Desktop/QNET/static/site/',
###FOR ASKBOT
('default/media', os.path.join(ASKBOT_ROOT, 'media')),
os.path.join(PROJECT_ROOT, "static"),
###END ASKBOT
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '+zme3dsnpuq^j$(mjlm3p$2&^p0np$(z8$_kr)n841z@32ny6+'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
###FOR ASKBOT
'askbot.skins.loaders.Loader',
###END ASKBOT
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware',
###FOR ASKBOT
#below is askbot stuff for this tuple
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'askbot.middleware.forum_mode.ForumModeMiddleware',
'askbot.middleware.cancel.CancelActionMiddleware',
'django.middleware.transaction.TransactionMiddleware',
#'debug_toolbar.middleware.DebugToolbarMiddleware',
'askbot.middleware.view_log.ViewLogMiddleware',
'askbot.middleware.spaceless.SpacelessMiddleware',
###END ASKBOT

)

ROOT_URLCONF = 'QNET.urls'

###FOR ASKBOT
#UPLOAD SETTINGS
FILE_UPLOAD_TEMP_DIR = os.path.join(
os.path.dirname(__file__),
'tmp'
).replace('\\','/')

FILE_UPLOAD_HANDLERS = (
'django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler',
)
ASKBOT_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
ASKBOT_MAX_UPLOAD_FILE_SIZE = 1024 * 1024 #result in bytes
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

#ASKBOT_EXTRA_SKINS_DIR = #path to your private skin collection
#take a look here http://askbot.org/en/question/207/

TEMPLATE_CONTEXT_PROCESSORS= (
# 'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
# 'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'postman.context_processors.inbox',
'askbot.context.application_settings',
#'django.core.context_processors.i18n',
'askbot.user_messages.context_processors.user_messages',#must be before auth
'django.core.context_processors.auth', #this is required for the admin app
'django.core.context_processors.csrf', #necessary for csrf protection

)

TEMPLATE_DIRS = (
'/home/djangouser/Desktop/QNET/templates'
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# to provide our get_profile()
AUTH_PROFILE_MODULE='Humans.Human'

###Login decorator
LOGIN_URL='/login/'

#LOGIN_REDIRECT_URL='/profile/'

### Postman moderation
POSTMAN_AUTO_MODERATE_AS = True

INSTALLED_APPS = (
###FOR ASKBOT
'longerusername',
###END ASKBOT
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
'pagination',
###FOR ASKBOT
#all of these are needed for the askbot
# Uncomment the next line to enable the admin:
'django.contrib.humanize',
'django.contrib.sitemaps',
#'debug_toolbar',
#Optional, to enable haystack search
#'haystack',
'askbot',
# 'askbot.deps.django_authopenid',
#'askbot.importers.stackexchange', #se loader
'south',
'askbot.deps.livesettings',
'keyedcache',
'robots',
'django_countries',
'djcelery',
'djkombu',
'followit',
'tinymce',
'group_messaging',
#'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$
###END ASKBOT
# 'south',
'postman',
'Humans',
'mptt',
'easy_thumbnails',
'filer',
# 'ajax_select',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

####FOR ASKBOT
#setup memcached for production use!
#see http://docs.djangoproject.com/en/1.1/topics/cache/ for details
CACHE_BACKEND = 'locmem://'
#needed for django-keyedcache
CACHE_TIMEOUT = 6000
#sets a special timeout for livesettings if you want to make them different
LIVESETTINGS_CACHE_TIMEOUT = CACHE_TIMEOUT
CACHE_PREFIX = 'askbot' #make this unique
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
#If you use memcache you may want to uncomment the following line to enable memcached based sessions
#SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
# 'askbot.deps.django_authopenid.backends.AuthBackend',
)

##logging settings
#LOG_FILENAME = 'askbot.log'
#logging.basicConfig(
# filename=os.path.join(os.path.dirname(__file__), 'log', LOG_FILENAME),
# level=logging.CRITICAL,
# format='%(pathname)s TIME: %(asctime)s MSG: %(filename)s:%(funcName)s:%(lineno)d %(message)s',
#)
#
############################
##
## this will allow running your forum with url like http://site.com/forum
##
## ASKBOT_URL = 'forums/'
##
ASKBOT_URL = 'forums/' #no leading slash, default = '' empty string
ASKBOT_TRANSLATE_URL = True #translate specific URLs
_ = lambda v:v #fake translation function for the login url
#LOGIN_URL = '/%s%s%s' % (ASKBOT_URL,_('account/'),_('signin/'))
LOGIN_REDIRECT_URL = ASKBOT_URL #adjust, if needed
#note - it is important that upload dir url is NOT translated!!!
#also, this url must not have the leading slash
ALLOW_UNICODE_SLUGS = False
ASKBOT_USE_STACKEXCHANGE_URLS = False #mimic url scheme of stackexchange

#Celery Settings
BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"
CELERY_ALWAYS_EAGER = True

import djcelery
djcelery.setup_loader()
DOMAIN_NAME = ''

CSRF_COOKIE_NAME = '_csrf'
#https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/
#CSRF_COOKIE_DOMAIN = DOMAIN_NAME

#STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
#STATICFILES_DIRS = (
# ('default/media', os.path.join(ASKBOT_ROOT, 'media')),
#)

RECAPTCHA_USE_SSL = True

#HAYSTACK_SETTINGS
ENABLE_HAYSTACK_SEARCH = False
HAYSTACK_SITECONF = 'askbot.search.haystack'
#more information
#http://django-haystack.readthedocs.org/en/v1.2.7/settings.html
HAYSTACK_SEARCH_ENGINE = 'simple'

TINYMCE_COMPRESSOR = True
TINYMCE_SPELLCHECKER = False
TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, 'default/media/js/tinymce/')
TINYMCE_URL = STATIC_URL + 'default/media/js/tinymce/'
TINYMCE_DEFAULT_CONFIG = {
'plugins': 'askbot_imageuploader,askbot_attachment',
'convert_urls': False,
'theme': 'advanced',
'content_css': STATIC_URL + 'default/media/style/tinymce/content.css',
'force_br_newlines': True,
'force_p_newlines': False,
'forced_root_block': '',
'mode' : 'textareas',
'oninit': "function(){ tinyMCE.activeEditor.setContent(askbot['data']['editorContent'] || ''); }",
'plugins': 'askbot_imageuploader,askbot_attachment',
'theme_advanced_toolbar_location' : 'top',
'theme_advanced_toolbar_align': 'left',
'theme_advanced_buttons1': 'bold,italic,underline,|,bullist,numlist,|,undo,redo,|,link,unlink,askbot_imageuploader,askbot_attachment',
'theme_advanced_buttons2': '',
'theme_advanced_buttons3' : '',
'theme_advanced_path': False,
'theme_advanced_resizing': True,
'theme_advanced_resize_horizontal': False,
'theme_advanced_statusbar_location': 'bottom',
'width': '723',
'height': '250'
}

#delayed notifications, time in seconds, 15 mins by default
NOTIFICATION_DELAY_TIME = 60 * 15

GROUP_MESSAGING = {
'BASE_URL_GETTER_FUNCTION': 'askbot.models.user_get_profile_url',
'BASE_URL_PARAMS': {'section': 'messages', 'sort': 'inbox'}
}

###END ASKBOT

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

urls.py的内容是

    from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
from django.conf.urls.defaults import handler404
from django.conf.urls.defaults import handler500
from django.conf.urls.defaults import include
from django.conf.urls.defaults import patterns
from django.conf.urls.defaults import url
from django.conf import settings
from django.contrib import admin

import admin_auth

admin.autodiscover()

if getattr(settings, 'ASKBOT_MULTILINGUAL', False) == True:
from django.conf.urls.i18n import i18n_patterns
urlpatterns = i18n_patterns('',
(r'%s' % settings.ASKBOT_URL, include('askbot.urls'))
)
else:
urlpatterns = patterns('',
(r'%s' % settings.ASKBOT_URL, include('askbot.urls'))
)

urlpatterns += patterns('',
(r'^admin/', include(admin.site.urls)),
#(r'^cache/', include('keyedcache.urls')), - broken views disable for now
(r'^settings/', include('askbot.deps.livesettings.urls')),
(r'^followit/', include('followit.urls')),
(r'^tinymce/', include('tinymce.urls')),
(r'^robots.txt$', include('robots.urls')),
url( # TODO: replace with django.conf.urls.static ?
r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:],
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT.replace('\\','/')},
),
url(r'^register/', 'Humans.views.HumansRegistration'),
url(r'^$', 'Humans.views.index'),
url(r'^messages/', include('postman.urls')),
url(r'^logout/', 'Humans.views.LogoutRequest'),
url(r'^login/', 'Humans.views.LoginRequest'),
)

if 'rosetta' in settings.INSTALLED_APPS:
urlpatterns += patterns('',
url(r'^rosetta/', include('rosetta.urls')),
)

请帮我解决这个问题。我尝试了很多谷歌搜索,但没有用。而且我也不能在 askbot 论坛上发布这个,因为我的业力很低。

最佳答案

Askbot 使用 Jinja2 模板,您的“index.html”模板(我猜是 Django 模板)可能扩展了 askbot 的“基本”模板 - Jinja2 模板。

看来错误不是模板解析错误,而是API错误。当顶级模板和基本模板都被找到并正确解析时,可能会发生这种情况,但由于模板引擎的内部 api 不兼容,它们无法放在一起。

也许解决方案是创建基本模板的 Django 版本并将其放在不同的目录中。

当部分项目使用 Django 模板时,Askbot 确实可以工作 - 例如 - 我们的/settings/url 映射到 livesettings 应用程序,它使用 Django 模板并且两者都可以正常工作,但它们使用不同的基础模板。

为了快速测试 - 创建一个简单的基本模板并将其用于 index.html

关于python - 安装 askbot 后 Django 应用程序未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15157997/

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