title: IntegrityError at /signup UNIQUE constraint failed: auth_user.username
body: <p>I'm trying to make an authentication system using Django using only 3 fields for SignUp (username &amp; email &amp; password ) and 2 fields for sign in ( username &amp; password )
  I think that the error that I get has relation to database, which I haven't used my models file yet, I don't know where the problem is coming from, is it from the signup function or the signing function</p>
  <pre><code>    IntegrityError at /signup
  UNIQUE constraint failed: auth_user.username
  Request Method: POST
  Request URL:    http://127.0.0.1:8000/signup
  Django Version: 3.2.6
  Exception Type: IntegrityError
  Exception Value:    
  UNIQUE constraint failed: auth_user.username
  Exception Location: C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\sqlite3\base.py, line 423, in execute
  Python Executable:  C:\Users\dell\AppData\Local\Programs\Python\Python39\python.exe
  Python Version: 3.9.0
  Python Path:    
  ['C:\\Users\\dell\\Desktop\\greenaftech',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\lib',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32\\lib',
   'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\Pythonwin']
  Server time:    Sat, 30 Apr 2022 00:24:12 +0000
  </code></pre>
  <p><strong>this is my views.py</strong>:</p>
  <pre><code>from django.shortcuts import render,redirect
  from django.http import HttpResponse
  from django.contrib.auth.models import User
  from django.contrib import messages
  
  
  # Create your views here.
  def home(request):
      return render(request,&quot;website/index.html&quot;)
  
  
  
  
  def signup(request):
  
      if request.method==&quot;POST&quot;:
          username=request.POST.get('username')
          password=request.POST.get('password')
          email=request.POST.get('email')
          myuser= User.objects.create_user(username,email,password)
          myuser.save()
          messages.success(request,&quot;Your Account has been created.&quot;)
          return redirect('signin')
  
  
      return render(request,&quot;website/signup.html&quot;)
  
  
  
  def signin(request):
      if request.method=='POST':
  
          usern=request.POST.get('username')
          passs=request.POST.get('password')
          
  
          user=authenticate(username=usern,password=passs)
          if user is not None:
              login(request,user)
              userr=user.username
              return render(request,&quot;website/index.html&quot;,{'username':userr})
          else:
              messages.error(request,&quot;Wrong Infos&quot;)
              return redirect('home') 
  
      return render(request,&quot;website/signin.html&quot;)
  
  
  
  def signout(request):
      pass    
  </code></pre>
  <p><strong>and these are my URLs.py</strong> :</p>
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  from . import views
  
  urlpatterns = [
     path('',views.home,name='home'),
     path('signup',views.signup,name='signup'),
     path('signin',views.signin,name='signin'),
     path('signout',views.signout,name='signout'),
  ]
  </code></pre>