1
我想創建在Django一個登錄表單,我用這個方法:如何創建自己的登錄表單的Django
def Login(request):
if request.method == 'POST':
form = AuthenticationForm(request.POST)
if form.is_valid:
username = request.POST['username']
password = request.POST['password']
access = authenticate(username=username, password=password)
if access is not None:
if access.is_active:
login(request,access)
return HttpResponseRedirect('/')
else:
return render_to_response('noactive.html', context_instance=RequestContext(request))
else:
HttpResponseRedirect('/')
else:
form = AuthenticationForm()
return render_to_response('login.html', {'form':form}, context_instance=RequestContext(request))
有什麼辦法來創建一個表單的表單中forms.py創建而不是Django提供給你的django.contrib.auth.forms.AuthenticationForm?
class MyForm(AuthenticationForm)? –
你爲什麼想這樣做? Django的貢獻形式做了很多 – karthikr
但是,如果我想讓我的用戶獲得更多的信息,如「出生日期」或「血型」? django.contrib.auth.forms沒有給你什麼東西? –