在安装askbot之前,应用程序运行得很好。我查看了他们的文档,并将askbot安装为可插拔的应用程序。我还合并了设置和urls。现在论坛部分(Askbot app)运行良好,但包括索引在内的其他部分已经崩溃。
错误如下:
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论坛上发表这篇文章,因为我的报应太少了。
发布于 2013-03-01 23:02:14
Askbot使用Jinja2模板,你的'index.html‘模板--我猜--是一个Django模板,有可能扩展了askbot的“基础”模板--一个Jinja2模板。
该错误似乎不是模板解析错误,而是API错误。当顶层模板和基本模板都被找到并正确解析,但由于模板引擎的内部api不兼容而无法将它们放在一起时,可能会发生这种情况。
也许一个解决方案是创建基本模板的Django版本,并将其放在不同的目录中。
当部分项目使用Django模板时,Askbot确实可以工作-例如-我们的/settings/ url映射到livesettings应用程序,该应用程序使用Django模板,两者都工作得很好,但它们使用不同的基本模板。
要快速测试,请创建一个简单的基本模板,并将其用于index.html。
https://stackoverflow.com/questions/15157997
复制相似问题