text: from django import forms
  from django.contrib.auth.forms import (
      UserCreationForm,
      AuthenticationForm,
      UserChangeForm,
  )
  from .models import ShopUser
  
  
  class ShopUserLoginForm(AuthenticationForm):
      class Meta:
          model = ShopUser
          fields = ("username", "password")
  
      def __init__(self, *args, **kwargs):
          super(ShopUserLoginForm, self).__init__(*args, **kwargs)
          for field_name, field in self.fields.items():
              field.widget.attrs["class"] = "form-control"
  
  
  class ShopUserRegisterForm(UserCreationForm):
      class Meta:
          model = ShopUser
          fields = (
              "username",
              "first_name",
              "last_name",
              "password1",
              "password2",
              "email",
              "age",
              "user_photo",
          )
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          for field_name, field in self.fields.items():
              field.help_text = ""
              field.widget.attrs["class"] = "form-control"
  
      def clean_age(self):
          data = self.cleaned_data["age"]
          if data < 18:
              raise forms.ValidationError(
                  "Регистрироваться на нашем сайте пользователям младше 18 лет не разрешается"
              )
          return data
  
      def clean_email(self):
          data = self.cleaned_data["email"]
          if data and ShopUser.objects.filter(email=data).exists():
              raise forms.ValidationError("Пользователь с такой почтой уже существует")
          return ""
  
      def clean_password2(self):
          password1 = self.cleaned_data["password1"]
          password2 = self.cleaned_data["password2"]
          if password1 != password2:
              raise forms.ValidationError("Введенные пароли не совпадают")
          return password2
  
  
  class ShopUserEditForm(UserChangeForm):
      class Meta:
          model = ShopUser
          fields = (
              "username",
              "first_name",
              "last_name",
              "age",
              "user_photo",
              "password",
          )
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          for field_name, field in self.fields.items():
              field.widget.attrs["class"] = "form-control"
              field.help_text = ""
              if field_name == "password":
                  field.widget = forms.HiddenInput()
  
      def clean_age(self):
          data = self.cleaned_data["age"]
          if data < 18:
              raise forms.ValidationError(
                  "Регистрироваться на нашем сайте пользователям младше 18 лет не разрешается"
              )
          return data
  
      def clean_password2(self):
          password1 = self.cleaned_data["password1"]
          password2 = self.cleaned_data["password2"]
          if password1 != password2:
              raise forms.ValidationError("Введенные пароли не совпадают")
          return password2
  