Я работаю над проектом django, и когда я пытаюсь запустить эту функцию, возвращается, что может быть задан только один аргумент, но дан только один аргумент.
from django.http import HttpResponse, Http404
from django.template import Context
from django.template.loader import get_template
from django.contrib.auth.models import User
def main_page(request):
template = get_template('main_page.html')
variables = Context({
'head_title':u'Bookmarks!',
'page_title':u'Welcome to bookmarks!',
'page_body': u'store and share the bookmarks',
})
output = template.render(variables)
return HttpResponse(output)
Шаблон URL
from django.conf.urls.defaults import patterns, include, url
from socialnetwork.bookmarks.views import *
urlpatterns = patterns('',
(r'^user/(\w+)/$', main_page),
)
Traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/user/Colin/
Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'socialnetwork.bookmarks']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
Exception Type: TypeError at /user/Colin/
Exception Value: main_page() takes exactly 1 argument (2 given)