title: How to define extra fields when creating super user in Django?
body: <p>I have this in my <code>models.py</code>:</p>
  <pre><code>class UserManager(BaseUserManager):
  
      def create_user(self, name, password=None):
  
          &quot;&quot;&quot;
  
          Creates and saves a User with the given name and password.
  
          &quot;&quot;&quot;
  
          if not name:
  
              raise ValueError('A user must have a name.')
  
  
  
          user = self.model()
  
          user.set_password(password)
  
          user.save(using=self._db)
  
          return user
  
  
  
      def create_staffuser(self, name, password):
  
          &quot;&quot;&quot;
  
          Creates and saves a staff user with the given name and password.
  
          &quot;&quot;&quot;
  
          user = self.create_user(
  
              name,
  
              password=password,
  
          )
  
          user.staff = True
  
          user.save(using=self._db)
  
          return user
  
  
  
      def create_superuser(self, name, password, id):
  
          &quot;&quot;&quot;
  
          Creates and saves a superuser with the given name and password.
  
          &quot;&quot;&quot;
  
          user = self.create_user(
  
              name,
  
              id,
  
              password=password,
  
          )
  
          user.staff = True
  
          user.admin = True
  
          user.save(using=self._db)
  
          return user
  </code></pre>
  <p>The reason I added the field <code>id</code> in my <code>create_superuser</code> -method is that it is a required field in my model and I thought I need to include it also when running <code>python manage.py createsuperuser</code>. My problem is that I don't know how to customize the super user creation. With this I always get the error <code>TypeError: create_superuser() missing 1 required positional argument: 'id'</code>. I also tried to remove the id from the function. The process goes through without errors then, but I can't log in to the admin site, it says the username or password are not correct.
  I have this in my <code>admin.py</code>:</p>
  <pre><code>from django.contrib import admin
  
  from django.contrib.auth import get_user_model
  
  from django.contrib.auth.models import Group
  
  from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  
  from .forms import UserAdminCreationForm, UserAdminChangeForm
  
  
  User = get_user_model()
  
  
  # Remove Group Model from admin. We're not using it.
  
  admin.site.unregister(Group)
  
  
  class UserAdmin(BaseUserAdmin):
  
      # The forms to add and change user instances
  
      form = UserAdminChangeForm
  
      add_form = UserAdminCreationForm
  
  
  
      # The fields to be used in displaying the User model.
  
      # These override the definitions on the base UserAdmin
  
      # that reference specific fields on auth.User.
  
      list_display = ['name', 'admin']
  
      list_filter = ['admin']
  
      fieldsets = (
  
          (None, {'fields': ('name', 'password')}),
  
          ('Personal info', {'fields': ()}),
  
          ('Permissions', {'fields': ('admin',)}),
  
      )
  
      # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
  
      # overrides get_fieldsets to use this attribute when creating a user.
  
      add_fieldsets = (
  
          (None, {
  
              'classes': ('wide',),
  
              'fields': ('name', 'password1', 'password2')}
  
          ),
  
      )
  
      search_fields = ['name']
  
      ordering = ['name']
  
      filter_horizontal = ()
  
  
  admin.site.register(User, UserAdmin)
  </code></pre>
  <p>Do I need to modify the <code>admin.py</code> -file to make this work or is there some other obvious reason why it doesn't work?</p>