2014-04-16 80 views

回答

0

我認爲它晚,但我希望它可以幫助你:

forms.py

class PasswordResetFormExtra(auth.forms.PasswordResetForm): 
    def __init__(self, *args, **kw): 
     super(PasswordResetFormExtra, self).__init__(*args, **kw) 

     self.helper = FormHelper() 
     self.helper.form_class = 'form-horizontal' 
     self.helper.label_class = 'col-lg-2' 
     self.helper.field_class = 'col-lg-8'   
     self.helper.layout = Layout(
      'email', 
      Div(
       Submit('submit', 'Reset password', css_class='btn btn-default'), 
       HTML('<a class="btn btn-default" href="/">Cancel</a>'), 
       css_class='text-left', 
      ) 
     ) 

urls.py

from django.contrib.auth.views import password_reset 
from .forms import(
     PasswordResetFormExtra, 
     ) 

    urlpatterns = patterns('', 
     (r'^/accounts/password/reset/$', password_reset, { 
     'template_name': 'my_templates/password_reset.html', 
     'password_reset_form':PasswordResetFormExtra, 
     }), 

    ) 

password_reset.html

{% load crispy_forms_tags %} 
{% block content %} 
{% crispy form %} 
{% endblock %} 
相關問題