old_contents: from django.contrib import admin
  from django.contrib.auth.admin import UserAdmin
  from django.contrib.auth.forms import UserChangeForm
  
  from .utils import get_profile_fields
  from .models import User
  
  
  class CustomUserChangeForm(UserChangeForm):
      class Meta(UserChangeForm.Meta):
          model = User
  
  
  class CustomUserAdmin(UserAdmin):
      form = CustomUserChangeForm
  
      readonly_fields = ('token_version',)
  
      fieldsets = UserAdmin.fieldsets + (
          ('Profile', {'fields': get_profile_fields(User, UserAdmin)}),
      )
  
  
  admin.site.register(User, CustomUserAdmin)
  
new_contents: from django import forms
  from django.contrib import admin
  from django.contrib.auth.admin import UserAdmin
  from django.contrib.auth.forms import UserChangeForm, UserCreationForm
  
  from .utils import get_profile_fields
  from .models import User
  
  
  class CustomUserChangeForm(UserChangeForm):
      class Meta(UserChangeForm.Meta):
          model = User
  
  
  class CustomUserCreationForm(UserCreationForm):
      class Meta(UserCreationForm.Meta):
          model = User
  
      def clean_username(self):
          username = self.cleaned_data["username"]
  
          try:
              User.objects.get(username=username)
          except User.DoesNotExist:
              return username
          raise forms.ValidationError(
              self.error_messages['duplicate_username'],
              code='duplicate_username',
          )
  
  
  class CustomUserAdmin(UserAdmin):
      form = CustomUserChangeForm
      add_form = CustomUserCreationForm
  
      readonly_fields = ('token_version',)
  
      fieldsets = UserAdmin.fieldsets + (
          ('Profile', {'fields': get_profile_fields(User, UserAdmin)}),
      )
  
  
  admin.site.register(User, CustomUserAdmin)
  
subject: Implement custom admin creation for for User model