9👍
✅
yes of course you can overwrite django forms.
# forms.py
from django.contrib.auth.forms import PasswordResetForm
class UserPasswordResetForm(PasswordResetForm):
def __init__(self, *args, **kwargs):
super(UserPasswordResetForm, self).__init__(*args, **kwargs)
email = forms.EmailField(label='', widget=forms.EmailInput(attrs={
'class': 'your class',
'placeholder': 'your placeholder',
'type': 'email',
'name': 'email'
}))
# urls.py
from .forms import UserPasswordResetForm
path('password_reset/', auth_views.PasswordResetView.as_view(
template_name='main/password_reset.html',
form_class=UserPasswordResetForm),name='password_reset'),
2👍
Try Using django-crispy-forms.
Installation
pip install django-crispy-forms
Add it to your INSTALLED_APPS and select the style:
INSTALLED_APPS = [
'crispy_forms',
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Load the tag
{% load crispy_forms_tags %}
Now you can style the form
{{ form|crispy }}
- [Django]-Django can not delete csrftoken after logout
- [Django]-Can we pass array/list to template content blocks in django? python
Source:stackexchange.com