forms.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. from django import forms
  2. from django.contrib.auth import get_user_model
  3. from webservice_running.models import OrdersLocal
  4. from django.contrib.auth.forms import UserCreationForm
  5. class OrderRegForm(forms.ModelForm):
  6. class Meta:
  7. model = OrdersLocal
  8. fields = '__all__'
  9. def __init__(self, *args, **kwargs):
  10. super().__init__(*args, **kwargs)
  11. for field in self.fields.values():
  12. field.widget.attrs['class'] = 'form-control'
  13. class RegisterUserForm(UserCreationForm):
  14. password1 = forms.CharField(label="Пароль",
  15. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  16. password2 = forms.CharField(label="Подтверждение пароля",
  17. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  18. username = forms.CharField(label="Номер телефона",
  19. widget=forms.TextInput(attrs={'class':'form-control'}))
  20. class Meta:
  21. model = get_user_model()
  22. fields = ['username', 'password1', 'password2']