response = callback(request,*callback_args,**callback_kwargs)
Exception Type: TypeError at /accounts/profile/
Exception Value: __init__() takes exactly 1 argument (3 given)
這是我的代碼
urls.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'}),
)
views.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))
任何人都可以幫助我解決這個錯誤。在此先感謝 – Mathi 2013-03-12 05:40:11
如果您沒有發佈您的代碼,我們如何幫助您? – catherine 2013-03-12 05:41:00
您的視圖代碼爲哪個檔案? – catherine 2013-03-12 11:00:27