我正在尝试设置一个Django站点(OSQA)并且无法使其正常工作。
有一些问题,其中之一是当我尝试查看用户的个人资料时,我遇到以下异常:
有人可以指出问题所在吗?
TemplateSyntaxError at /users/2/allenq/
Caught NoReverseMatch while rendering: Reverse for 'ask_to_me' with arguments '(2, u'allenq')' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://123.243.100.125/users/2/allenq/
Django Version: 1.3.4
Exception Type: TemplateSyntaxError
Exception Value:
Caught NoReverseMatch while rendering: Reverse for 'ask_to_me' with arguments '(2, u'allenq')' and keyword arguments '{}' not found.
Exception Location: /usr/lib/python2.6/site-packages/django/template/defaulttags.py in render, line 450
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path:
['/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
'/usr/lib/python2.6/site-packages/elementtree-1.2.7_20070827_preview-py2.6.egg',
'/usr/lib/python2.6/site-packages/Markdown-2.2.0-py2.6.egg',
'/usr/lib/python2.6/site-packages/html5lib-0.95-py2.6.egg',
'/usr/lib/python2.6/site-packages/django_rosetta-0.6.8-py2.6.egg',
'/usr/lib64/python26.zip',
'/usr/lib64/python2.6',
'/usr/lib64/python2.6/plat-linux2',
'/usr/lib64/python2.6/lib-tk',
'/usr/lib64/python2.6/lib-old',
'/usr/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6/site-packages',
'/usr/lib64/python2.6/site-packages/PIL',
'/usr/lib64/python2.6/site-packages/gst-0.10',
'/usr/lib64/python2.6/site-packages/gtk-2.0',
'/usr/lib64/python2.6/site-packages/webkit-1.0',
'/usr/lib/python2.6/site-packages',
'/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
'/usr/local/src',
'/usr/local/src/osqa',
'/usr/local/src/osqa/forum/markdownext']
Server time: ???, 24 ?? 2012 22:58:23 +1100
Template error
In template /usr/local/src/osqa/forum/skins/default/templates/users/info.html, error at line 31
Caught NoReverseMatch while rendering: Reverse for 'ask_to_me' with arguments '(2, u'allenq')' and keyword arguments '{}' not found.
21 </tr>
22 <tr>
23 <td align="center">
24 {% if not view_user.is_suspended %}
25 <div class="scoreNumber" id="user-reputation">{{view_user.reputation|intcomma}}</div>
26 <p><b style="color:#777;">{% trans "reputation" %}</b></p>
27 {% else %}
28 <div class="scoreNumber">{% trans "Suspended" %}</div>
29 <p>{{ view_user.suspension.extra.publicmsg }}</p>
30 {% endif %}
31 <div class="scoreNumber" id="user-reputation"><a href="{% url ask_to_me view_user.id view_user.username%}">{% trans "Ask to me" %}</a></div>
32 </td>
33 </tr>
34 </table>
35 </td>
36 <td width="360" style="vertical-align: top;">
37 {% if can_view_private %}{% user_menu request.user view_user %}{% endif %}
38 <table class="user-details">
39 <tr>
40 <th colspan="2" align="left"><h3>{% trans "Registered user" %}</h3></th>
41 </tr>
Traceback Switch to copy-and-paste view
/usr/lib/python2.6/site-packages/django/core/handlers/base.py in get_response
response = callback(request, *callback_args, **callback_kwargs) ...
? Local vars
/usr/local/src/osqa/forum/modules/decorators.py in decorated
return decoratable(*args, **kwargs) ...
? Local vars
/usr/local/src/osqa/forum/modules/decorators.py in __call__
res = dec(res, *args, **kwargs) ...
? Local vars
/usr/local/src/osqa/forum/views/users.py in result
return render_to_response(template, context, context_instance=RequestContext(request)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/shortcuts/__init__.py in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader.py in render_to_string
return t.render(context_instance) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
return self._render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render
return self.render_template(self.template, context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/loader_tags.py in render_template
output = template.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
return self._render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/base.py in render
bits.append(self.render_node(node, context)) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/debug.py in render_node
result = node.render(context) ...
? Local vars
/usr/lib/python2.6/site-packages/django/template/defaulttags.py in render
raise e ...
? Local vars
Request information
GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
Variable Value
sessionid
'1e7a11ca5a8631425ad03fd4973e57dc'
META
Variable Value
mod_wsgi.listener_port
'80'
HTTP_COOKIE
'sessionid=1e7a11ca5a8631425ad03fd4973e57dc'
mod_wsgi.listener_host
''
SERVER_SOFTWARE
'Apache/2.2.15 (CentOS)'
SCRIPT_NAME
u''
mod_wsgi.handler_script
''
SERVER_SIGNATURE
'<address>Apache/2.2.15 (CentOS) Server at 123.243.100.125 Port 80</address>\n'
REQUEST_METHOD
'GET'
PATH_INFO
u'/users/2/allenq/'
SERVER_PROTOCOL
'HTTP/1.1'
QUERY_STRING
''
HTTP_ACCEPT_CHARSET
'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
HTTP_CONNECTION
'keep-alive'
HTTP_REFERER
'http://123.243.100.125/questions/unanswered/'
SERVER_NAME
'123.243.100.125'
REMOTE_ADDR
'123.243.100.125'
mod_wsgi.request_handler
'wsgi-script'
wsgi.url_scheme
'http'
PATH_TRANSLATED
'/usr/local/src/osqa/osqa.wsgi/users/2/allenq/'
SERVER_PORT
'80'
wsgi.multiprocess
False
mod_wsgi.input_chunked
'0'
SERVER_ADDR
'192.168.0.10'
DOCUMENT_ROOT
'/usr/local/src/osqa/forum'
mod_wsgi.process_group
'osqa'
SCRIPT_FILENAME
'/usr/local/src/osqa/osqa.wsgi'
SERVER_ADMIN
'admin@your.server.com'
wsgi.input
<mod_wsgi.Input object at 0x7f1d982f5670>
HTTP_HOST
'123.243.100.125'
wsgi.multithread
True
mod_wsgi.callable_object
'application'
REQUEST_URI
'/users/2/allenq/'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
wsgi.version
(1, 1)
GATEWAY_INTERFACE
'CGI/1.1'
wsgi.run_once
False
wsgi.errors
<mod_wsgi.Log object at 0x7f1d982f5af0>
REMOTE_PORT
'11611'
HTTP_ACCEPT_LANGUAGE
'en-GB,en-US;q=0.8,en;q=0.6'
mod_wsgi.version
(3, 2)
mod_wsgi.application_group
'localhost.localdomain|'
mod_wsgi.script_reloading
'1'
wsgi.file_wrapper
''
HTTP_ACCEPT_ENCODING
'gzip,deflate,sdch'
Settings
Using settings module osqa.settings
Setting Value
USE_L10N
False
USE_THOUSAND_SEPARATOR
False
APP_PROTOCOL
'http'
LANGUAGE_CODE
'zh_CN'
ROOT_URLCONF
'urls'
MANAGERS
()
APP_URL
'http://127.0.0.1'
DEFAULT_CHARSET
'utf-8'
APP_DOMAIN
'127.0.0.1'
STATIC_ROOT
''
TEST_DATABASE_CHARSET
None
LOG_FILENAME
'django.osqa.log'
MESSAGE_STORAGE
'django.contrib.messages.storage.user_messages.LegacyFallbackStorage'
DATABASE_HOST
'127.0.0.1'
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
SEND_BROKEN_LINK_EMAILS
False
URL_VALIDATOR_USER_AGENT
'Django/1.3.4 (http://www.djangoproject.com)'
STATICFILES_FINDERS
('django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder')
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
ADMIN_FOR
()
TIME_INPUT_FORMATS
('%H:%M:%S', '%H:%M')
DATABASES
{'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': '127.0.0.1',
'NAME': 'osqa',
'OPTIONS': {},
'PASSWORD': '********************',
'PORT': '',
'TEST_CHARSET': None,
'TEST_COLLATION': None,
'TEST_MIRROR': None,
'TEST_NAME': None,
'TIME_ZONE': 'Australia/Melbourne',
'USER': 'uosqa'}}
TEST_DATABASE_NAME
None
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
DEFAULT_CONTENT_TYPE
'text/html'
OSQA_DEFAULT_SKIN
'default'
APPEND_SLASH
True
FIRST_DAY_OF_WEEK
0
DATABASE_ROUTERS
[]
YEAR_MONTH_FORMAT
'F Y'
STATICFILES_STORAGE
'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES
{'default': {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/usr/local/src/osqa/cache'}}
MODULES_FOLDER
'/usr/local/src/osqa/forum_modules'
SERVER_EMAIL
USE_I18N
True
THOUSAND_SEPARATOR
','
SECRET_KEY
'********************'
LANGUAGE_COOKIE_NAME
'django_language'
FILE_UPLOAD_TEMP_DIR
'/usr/local/src/osqa/tmp'
TRANSACTIONS_MANAGED
False
LOGGING_CONFIG
'django.utils.log.dictConfig'
TEMPLATE_LOADERS
['django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'forum.modules.template_loader.module_templates_loader',
'forum.skins.load_template_source']
TEMPLATE_DEBUG
True
CSRF_COOKIE_NAME
'csrftoken'
TEST_DATABASE_COLLATION
None
EMAIL_HOST_PASSWORD
'********************'
CACHE_BACKEND
'file:///usr/local/src/osqa/cache'
SESSION_COOKIE_SECURE
False
CSRF_COOKIE_DOMAIN
None
FILE_CHARSET
'utf-8'
DEBUG
True
MODULES_PACKAGE
'forum_modules'
SESSION_FILE_PATH
None
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
INSTALLED_APPS
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.humanize',
'django.contrib.sitemaps',
'django.contrib.markup',
'forum']
LANGUAGES
(('ar', 'Arabic'),
('az', 'Azerbaijani'),
('zh-cn', 'Simplified Chinese'),
('zh-tw', 'Traditional Chinese'))
DATABASE_ENGINE
'postgresql_psycopg2'
DATABASE_NAME
'osqa'
COMMENTS_FIRST_FEW
0
PREPEND_WWW
False
SESSION_COOKIE_HTTPONLY
False
DATABASE_PORT
''
DEBUG_PROPAGATE_EXCEPTIONS
False
MONTH_DAY_FORMAT
'F j'
LOGIN_URL
'/accounts/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
TIME_FORMAT
'P'
DATE_INPUT_FORMATS
('%Y-%m-%d',
'%d %B, %Y')
AUTHENTICATION_BACKENDS
['django.contrib.auth.backends.ModelBackend']
FORCE_SCRIPT_NAME
''
PASSWORD_RESET_TIMEOUT_DAYS
'********************'
CACHE_MIDDLEWARE_ALIAS
'default'
SESSION_SAVE_EVERY_REQUEST
False
ADMIN_MEDIA_PREFIX
'/admin_media/'
NUMBER_GROUPING
0
SESSION_ENGINE
'django.contrib.sessions.backends.db'
CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure'
COMMENTS_SKETCHY_USERS_GROUP
None
LOGIN_REDIRECT_URL
'/accounts/profile/'
SESSION_COOKIE_PATH
'/'
LOGGING
{'disable_existing_loggers': False,
'handlers': {'mail_admins': {'class': 'django.utils.log.AdminEmailHandler',
'level': 'ERROR'}},
'loggers': {'django.request': {'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True}},
'version': 1}
CACHE_MIDDLEWARE_KEY_PREFIX
''
LOCALE_PATHS
()
TEMPLATE_STRING_IF_INVALID
''
COMMENTS_ALLOW_PROFANITIES
False
LOGOUT_URL
'/accounts/logout/'
EMAIL_USE_TLS
False
TEMPLATE_DIRS
('/usr/local/src/osqa/forum/skins',)
FIXTURE_DIRS
()
EMAIL_HOST
'localhost'
DATE_FORMAT
'N j, Y'
MEDIA_ROOT
''
ADMINS
()
FORMAT_MODULE_PATH
None
DEFAULT_FROM_EMAIL
'webmaster@localhost'
STATICFILES_DIRS
()
MEDIA_URL
''
DATETIME_FORMAT
'N j, Y, P'
EMAIL_SUBJECT_PREFIX
'[Django] '
DJANGO_VERSION
1.3
SITE_ID
1
DISALLOWED_USER_AGENTS
()
ALLOWED_INCLUDE_ROOTS
()
DECIMAL_SEPARATOR
'.'
SHORT_DATE_FORMAT
'm/d/Y'
DATABASE_USER
'uosqa'
MODULE_LIST
[<module 'osqa.forum_modules.sximporter' from '/usr/local/src/osqa/forum_modules/sximporter/__init__.pyc'>,
<module 'osqa.forum_modules.pgfulltext' from '/usr/local/src/osqa/forum_modules/pgfulltext/__init__.pyc'>,
<module 'osqa.forum_modules.default_badges' from '/usr/local/src/osqa/forum_modules/default_badges/__init__.pyc'>,
<module 'osqa.forum_modules.akismet' from '/usr/local/src/osqa/forum_modules/akismet/__init__.pyc'>,
<module 'osqa.forum_modules.exporter' from '/usr/local/src/osqa/forum_modules/exporter/__init__.pyc'>,
<module 'osqa.forum_modules.localauth' from '/usr/local/src/osqa/forum_modules/localauth/__init__.pyc'>,
<module 'osqa.forum_modules.robotstxt' from '/usr/local/src/osqa/forum_modules/robotstxt/__init__.pyc'>,
<module 'osqa.forum_modules.facebookauth' from '/usr/local/src/osqa/forum_modules/facebookauth/__init__.pyc'>,
<module 'osqa.forum_modules.oauthauth' from '/usr/local/src/osqa/forum_modules/oauthauth/__init__.pyc'>]
TEST_RUNNER
'django.test.simple.DjangoTestSuiteRunner'
SITE_SRC_ROOT
'/usr/local/src/osqa'
TIME_ZONE
'Australia/Melbourne'
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
APP_BASE_URL
'http://127.0.0.1'
EMAIL_BACKEND
'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_TABLESPACE
''
TEMPLATE_CONTEXT_PROCESSORS
['django.core.context_processors.request',
'forum.context.application_settings',
'forum.user_messages.context_processors.user_messages',
'django.core.context_processors.auth']
SESSION_COOKIE_AGE
1209600
ONLINE_USERS
{}
SETTINGS_MODULE
'osqa.settings'
USE_ETAGS
False
DISABLED_MODULES
['books', 'recaptcha', 'project_badges']
LANGUAGES_BIDI
('he', 'ar', 'fa')
DEFAULT_INDEX_TABLESPACE
''
INTERNAL_IPS
('127.0.0.1',)
STATIC_URL
None
EMAIL_PORT
25
SHORT_DATETIME_FORMAT
'm/d/Y P'
ABSOLUTE_URL_OVERRIDES
{}
DATABASE_OPTIONS
{}
CACHE_MIDDLEWARE_SECONDS
600
BANNED_IPS
()
DEBUG_TOOLBAR_CONFIG
{'INTERCEPT_REDIRECTS': True}
DATETIME_INPUT_FORMATS
('%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M',
'%Y-%m-%d',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M',
'%m/%d/%Y',
'%m/%d/%y %H:%M:%S',
'%m/%d/%y %H:%M',
'%m/%d/%y')
DATABASE_PASSWORD
'********************'
COMMENTS_MODERATORS_GROUP
None
PROFANITIES_LIST
'********************'
EMAIL_HOST_USER
''
COMMENTS_BANNED_USERS_GROUP
None
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page.
修改: urls.py文件:
import startup
import os.path
from forum import settings
from django.conf.urls.defaults import *
from django.conf import settings as djsettings
from django.contrib import admin
from forum import views as app
from forum.sitemap import OsqaSitemap
from django.utils.translation import ugettext as _
import logging
admin.autodiscover()
sitemaps = {
'questions': OsqaSitemap
}
APP_PATH = os.path.dirname(__file__)
core_urls = (
url(r'^$', app.readers.index, name='index'),
url(r'^%s(.*)' % _('nimda/'), include(admin.site.urls)), url(r'^sitemap.xml$', 'forum.sitemap.index', {'sitemaps': sitemaps}),
url(r'^sitemap-(?P<section>.+)\.xml$', 'forum.sitemap.sitemap', {'sitemaps': sitemaps}),
url(r'^favicon\.ico$', app.meta.favicon),
url(r'^cstyle\.css$', app.meta.custom_css, name='custom_css'),
url(r'^m/(?P<skin>\w+)/media/(?P<path>.*)$', app.meta.media , name='osqa_media'),
url(r'^%s(?P<path>.*)$' % _('upfiles/'), 'django.views.static.serve', {'document_root': os.path.join(APP_PATH, 'upfiles').replace('\\', '/')}, name='uploaded_file',),
url(r'^%s$' % _('faq/'), app.meta.static, {'content': settings.FAQ_PAGE_TEXT, 'title': _('FAQ')}, name='faq'),
url(r'^%s$' % _('about/'), app.meta.static, {'content': settings.ABOUT_PAGE_TEXT, 'title': _('About')}, name='about'),
url(r'^%s$' % _('markdown_help/'), app.meta.markdown_help, name='markdown_help'), url(r'^opensearch\.xml$', app.meta.opensearch, name='opensearch'),
url(r'^opensearch\.xml$', app.meta.opensearch, name='opensearch'),
url(r'^%s$' % _('privacy/'), app.meta.privacy, name='privacy'),
url(r'^%s$' % _('logout/'), app.meta.logout, name='logout'),
url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('edit/')), app.writers.edit_answer, name='edit_answer'),
url(r'^%s(?P<id>\d+)/$' % _('revisions/'), app.readers.revisions, name='revisions'),
url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'),
url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
url(r'^%s%s$' % (_('questions/'), _('related_questions/')), app.commands.related_questions, name='related_questions'),
url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'),
url(r'^%s(?P<mode>[\w\-]+)/(?P<user>\d+)/(?P<slug>.*)/$' % _('questions/'), app.readers.user_questions, name='user_questions'),
url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('edit/')), app.writers.edit_question, name='edit_question'),
url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('close/')), app.commands.close, kwargs=dict(close=True), name='close'),
url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('reopen/')), app.commands.close, kwargs=dict(close=False), name='reopen'),
url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('answer/')), app.writers.answer, name='answer'),
url(r'^%s(?P<action>\w+)/$' % _('pending-data/'), app.writers.manage_pending_data, name='manage_pending_data'),
url(r'^%s(?P<id>\d+)/(?P<vote_type>[a-z]+)/' % _('vote/'), app.commands.vote_post, name='vote_post'),
url(r'^%s(?P<id>\d+)/$' % _('like_comment/'), app.commands.like_comment, name='like_comment'),
url(r'^%s(?P<id>\d+)/' % _('comment/'), app.commands.comment, name='comment'),
url(r'^%s(?P<id>\d+)/$' % _('delete_comment/'), app.commands.delete_comment, name='delete_comment'),
url(r'^%s(?P<id>\d+)/$' % _('convert_comment/'), app.commands.convert_comment_to_answer, name='convert_comment'),
url(r'^%s(?P<id>\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name='accept_answer'),
url(r'^%s(?P<id>\d+)/$' % _('answer_link/'), app.commands.answer_permanent_link, name='answer_permanent_link'),
url(r'^%s(?P<id>\d+)/$' % _('mark_favorite/'), app.commands.mark_favorite, name='mark_favorite'),
url(r'^%s%s(?P<user_id>\d+)/%s(?P<answer_id>\d+)/$' % (_('award_points/'), _('user/'), _('answer/')), app.commands.award_points, name='award_points'),
url(r'^%s(?P<id>\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'),
url(r'^%s(?P<id>\d+)/' % _('delete/'), app.commands.delete_post, name='delete_post'),
url(r'^%s(?P<id>\d+)/(?P<user>\d+)?$' % _('subscribe/'), app.commands.subscribe, name='subscribe'),
url(r'^%s(?P<id>\d+)/$' % _('subscribe/'), app.commands.subscribe, name='subscribe_simple'),
url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'),
url(r'^%s' % _('matching_users/'), app.commands.matching_users, name='matching_users'),
url(r'^%s(?P<id>\d+)/' % _('node_markdown/'), app.commands.node_markdown, name='node_markdown'),
url(r'^%s(?P<id>\d+)/' % _('convert/'), app.commands.convert_to_comment, name='convert_to_comment'),
url(r'^%s(?P<id>\d+)/' % _('convert_to_question/'), app.writers.convert_to_question,name='convert_to_question'),
url(r'^%s(?P<id>\d+)/' % _('wikify/'), app.commands.wikify, name='wikify'),
url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]*)$' % _('question/'), 'django.views.generic.simple.redirect_to', {'url': '/questions/%(id)s/%(slug)s'}),
url(r'^%s(?P<id>\d+)/?$' % _('questions/'), app.readers.question, name='question'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/(?P<answer>\d+)$' % _('questions/'), app.readers.question),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)$' % _('questions/'), app.readers.question, name='question'),
url(r'^%s$' % _('tags/'), app.readers.tags, name='tags'),
url(r'^%s(?P<tag>.*)/$' % _('tags/'), app.readers.tag, name='tag_questions'),
url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('interesting/')), app.commands.mark_tag, kwargs={'reason':'good','action':'add'}, name='mark_interesting_tag'),
url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('ignored/')), app.commands.mark_tag, kwargs={'reason':'bad','action':'add'}, name='mark_ignored_tag'),
url(r'^%s(?P<tag>[^/]+)/$' % _('unmark-tag/'), app.commands.mark_tag, kwargs={'action':'remove'}, name='mark_ignored_tag'),
url(r'^%s$' % _('users/'), app.users.users, name='users'),
# url(r'^%s$' % _('online_users/'), app.users.online_users, name='online_users'),
url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'),
url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('award/')), app.users.award_points, name='user_award_points'),
url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('suspend/')), app.users.suspend, name='user_suspend'),
url(r'^%s(?P<id>\d+)/%s(?P<action>[a-z]+)/(?P<status>[a-z]+)/$' % (_('users/'), _('powers/')), app.users.user_powers, name='user_powers'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('subscriptions/')), app.users.user_subscriptions, name='user_subscriptions'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('preferences/')), app.users.user_preferences, name='user_preferences'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('favorites/')), app.users.user_favorites, name='user_favorites'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('reputation/')), app.users.user_reputation, name='user_reputation'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('votes/')), app.users.user_votes, name='user_votes'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('recent/')), app.users.user_recent, name='user_recent'),
url(r'^%s(?P<id>\d+)/(?P<slug>.*)/$' % _('users/'), app.users.user_profile, name='user_profile'),
url(r'^%s$' % _('badges/'), app.meta.badges, name='badges'),
url(r'^%s(?P<id>\d+)/(?P<slug>[\w-]+)/?$' % _('badges/'), app.meta.badge, name='badge'),
# (r'^admin/doc/' % _('admin/doc'), include('django.contrib.admindocs.urls')),
url(r'^%s$' % _('upload/'), app.writers.upload, name='upload'),
url(r'^%s$' % _('search/'), app.readers.search, name='search'),
url(r'^%s$' % _('contact/'), app.meta.feedback, name='feedback'),
(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^%s%s$' % (_('account/'), _('signin/')), app.auth.signin_page, name='auth_signin'),
url(r'^%s%s$' % (_('account/'), _('signout/')), app.auth.signout, name='user_signout'),
url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('signin/')), app.auth.prepare_provider_signin, name='auth_provider_signin'),
url(r'^%s(?P<provider>\w+)/%s$' % (_('account/'), _('done/')), app.auth.process_provider_signin, name='auth_provider_done'),
url(r'^%s%s$' % (_('account/'), _('register/')), app.auth.external_register, name='auth_external_register'),
url(r'^%s%s(?P<user>\d+)/(?P<code>.+)/$' % (_('account/'), _('validate/')), app.auth.validate_email, name='auth_validate_email'),
url(r'^%s%s$' % (_('account/'), _('tempsignin/')), app.auth.request_temp_login, name='auth_request_tempsignin'),
url(r'^%s%s(?P<user>\d+)/(?P<code>.+)/$' % (_('account/'), _('tempsignin/')), app.auth.temp_signin, name='auth_tempsignin'),
url(r'^%s(?P<id>\d+)/%s$' % (_('account/'), _('authsettings/')), app.auth.auth_settings, name='user_authsettings'),
url(r'^%s%s(?P<id>\d+)/%s$' % (_('account/'), _('providers/'), _('remove/')), app.auth.remove_external_provider, name='user_remove_external_provider'),
url(r'^%s%s%s$' % (_('account/'), _('providers/'), _('add/')), app.auth.signin_page, name='user_add_external_provider'),
url(r'^%s%s$' %(_('account/'), _('send-validation/')), app.auth.send_validation_email, name='send_validation_email'),
url(r'^%s$' % _('admin/'), app.admin.dashboard, name='admin_index'),
url(r'^%s%s$' % (_('admin/'), _('switch_interface/')), app.admin.interface_switch, name='admin_switch_interface'),
url(r'^%s%s$' % (_('admin/'), _('statistics/')), app.admin.statistics, name='admin_statistics'),
url(r'^%s%s$' % (_('admin/'), _('denormalize/')), app.admin.recalculate_denormalized, name='admin_denormalize'),
url(r'^%s%s$' % (_('admin/'), _('go_bootstrap/')), app.admin.go_bootstrap, name='admin_go_bootstrap'),
url(r'^%s%s$' % (_('admin/'), _('go_defaults/')), app.admin.go_defaults, name='admin_go_defaults'),
url(r'^%s%s(?P<set_name>\w+)/(?P<var_name>\w+)/$' % (_('admin/'), _('settings/')), app.admin.get_default, name='admin_default'),
url(r'^%s%s$' % (_('admin/'), _('maintenance/')), app.admin.maintenance, name='admin_maintenance'),
url(r'^%s%s$' % (_('admin/'), _('flagged_posts/')), app.admin.flagged_posts, name='admin_flagged_posts'),
url(r'^%s%s$' % (_('admin/'), _('static_pages/')), app.admin.static_pages, name='admin_static_pages'),
url(r'^%s%s%s$' % (_('admin/'), _('static_pages/'), _('new/')), app.admin.edit_page, name='admin_new_page'),
url(r'^%s%s%s(?P<id>\d+)/$' % (_('admin/'), _('static_pages/'), _('edit/')), app.admin.edit_page, name='admin_edit_page'),
url(r'^%s%s(?P<name>\w+)/$' % (_('admin/'), _('tools/')), app.admin.tools_page, name='admin_tools'),
url(r'^%s%s(?P<set_name>\w+)/$' % (_('admin/'), _('settings/')), app.admin.settings_set, name='admin_set'),
url(r'%s%s' % (_('admin/'), _('test_email_settings/')), app.admin.test_email_settings, name='test_email_settings'),
url(r'^feeds/rss[/]?$', app.readers.feed, name='latest_questions_feed'),
)
from forum.modules import get_modules_script
module_patterns = get_modules_script('urls')
urlpatterns = patterns('')
for pattern_file in module_patterns:
pattern = getattr(pattern_file, 'urlpatterns', None)
if pattern:
urlpatterns += pattern
module_defined = {}
for t in urlpatterns:
if hasattr(t, 'name') and t.name:
module_defined[t.name] = True
core_defined = []
for u in core_urls:
if not(hasattr(u, 'name') and u.name and (u.name in module_defined)):
core_defined.append(u)
def urlname(name):
if name in module_defined:
return None
return name
urlpatterns += patterns('', *core_defined)
答案 0 :(得分:1)
Reverse for 'ask_to_me' with arguments '(2, u'allenq')' and keyword arguments '{}' not found.
Django模板渲染器无法找到反向网址。
这意味着您在某处使用了{%url ...%}标记,其参数与urls.py中的网址不匹配。
确保urls.py中存在ask_to_me
网址格式。您可以尝试在Django命令行中使用reverse()。
然后,确保它需要两个未命名的参数,一个整数(此处为2)和一个字符串(此处为“allenq”)。
我无法为您提供开箱即用的解决方案,因为您没有向我们提供足够的信息。我们需要urls.py和模板代码,至少需要使用{%url ...%}标记的部分。此外,您只询问“指出问题所在的位置”的信息,所以......你去了。
所以带错误的模板标签是:
{% url ask_to_me view_user.id view_user.username%}
此错误是由无模式且名称为“ask_to_me”的事实引起的。只有这一个包含“问”这个词:
url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
然而,它不需要参数。你需要找到那个视图消失的地方。尝试查看urls.py的下半部分,其中URL模式是从“模块”动态添加的。