错误
response = callback(request,*callback_args,**callback_kwargs)
Exception Type: TypeError at /accounts/profile/
Exception Value: __init__() takes exactly 1 argument (3 given)
这是我的代码
网址.py
from django.conf.urls import patterns, include, url
from django.conf.urls.defaults import *
from django.contrib.auth.views import password_reset, password_reset_done, password_change, password_change_done
from django.views.generic import TemplateView
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)),
(r'^accounts/', include('registration.urls')),
(r'^accounts/profile/$', TemplateView, {'template': 'registration/profile.html'}),
(r'^accounts/password_reset/$', password_reset, {'template_name': 'registration/password_reset.html'}),
(r'^accounts/password_reset_done/$', password_reset_done, {'template_name': 'registration/password_reset_done.html'}),
(r'^accounts/password_change/$', password_change, {'template_name': 'registration/password_change.html'}),
(r'^accounts/password_change_done/$', password_change_done, {'template_name': 'registration/password_change_done.html'}),
)
视图.py
from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from models import RegistrationProfile
from forms import RegistrationForm
from django.core.context_processors import csrf
def activate(request, activation_key):
activation_key = activation_key.lower() # Normalize before trying anything with it.
account = RegistrationProfile.objects.activate_user(activation_key)
return render_to_response('registration/activate.html',{
'account': account,
'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS
}, context_instance=RequestContext(request))
c = {} c.update(csrf(request))
def register(request, success_url='/accounts/register/complete/'):
form = RegistrationForm()
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
new_user=RegistrationProfile.objects.create_inactive_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email']
)
return HttpResponseRedirect(success_url)
return render_to_response('registration/registration_form.html', {
'form': form
}, context_instance=RequestContext(request))