title: IntegrityError at /admin/auth/user/11/delete/ FOREIGN KEY constraint failed
body: <p>when i delete user from my admin panel it shows me given error I dont understand what is the reason of this error or where i am making mistake. I can update and create new users and delete those user who dont have profile but the users which have profiles they are unable to delete because of the following here which i given below.
  <a href="https://i.stack.imgur.com/dV6Br.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dV6Br.png" alt="enter image description here" /></a></p>
  <p>accounts/models.py</p>
  <pre><code>from django.urls import reverse
  from django.db import models
  from django.contrib import auth
  from PIL import Image
  from django.db.models.signals import post_save
  from django.dispatch import receiver
  
  # Create your models here.
  
  class User(auth.models.User,auth.models.PermissionsMixin):
      
      def __str__(self):
          return &quot;@{}&quot;.format(self.username)
  
  class Profile(models.Model):
  
          user = models.OneToOneField(auth.models.User, on_delete=models.CASCADE)
          avatar = models.ImageField(default='1.jpg', upload_to='displays', height_field=None, width_field=None, max_length=None)
      
      
          def __str__(self):
              return f'{self.user.username} Profile'
      
      def save(self,*args, **kwargs):
          super(Profile,self).save(*args, **kwargs) #it will take data and save it
  
          dp = Image.open(self.avatar.path) #storing avatar in variable
          if dp.height &gt;300 or dp.width &gt;300:
              output_size =(300,300) #set any size you want
              dp.thumbnail(output_size) 
              dp.save(self.avatar.path) #after resizing it save it in data base in place of uploaded once by user
   
  
      def get_absolute_url(self):
          return reverse(&quot;Profile_detail&quot;, kwargs={&quot;pk&quot;: self.pk})
  
  @receiver(post_save, sender=User)
  def create_profile(sender, created,instance,**kwargs):
      if created:
          Profile.objects.create(user=instance)
  
  @receiver(post_save, sender=User)
  def save_profile(sender, instance,**kwargs):
      instance.profile.save()
  </code></pre>
  <p>accounts/forms.py</p>
  <pre><code>    from django import forms
      from django.contrib.auth.forms import UserCreationForm
      from django.core.exceptions import ValidationError
      from django.core import validators
      
      User = get_user_model()
      
      class UserCreateForm(UserCreationForm):
      
          class Meta:
              fields = [&quot;username&quot;,&quot;email&quot;,&quot;password1&quot;,&quot;password2&quot;]
              model = get_user_model()
              widgets ={
                  'username' : forms.TextInput(attrs={'class':'textinputclass','placeholder':'username'}),
              }
          
          def clean_email(self):
              email = self.cleaned_data[&quot;email&quot;]
              if User.objects.filter(email__iexact=email).exists():
                  raise forms.ValidationError(&quot;Email is invalid&quot;)
              return email
          
      
          def __init__(self,*args, **kwargs):
              super().__init__(*args, **kwargs)
              self.fields['username'].label = 'Display Name'
              # self.fields['email'].label = 'Email Address'
  </code></pre>
  <p>accounts/views.py</p>
  <pre><code>user = User
  class SignUp(CreateView):
      form_class = forms.UserCreateForm
      
      def form_valid(self, form):
          if form.is_valid:
              email = form.cleaned_data.get('email')
              user = form.save(commit=False)
              user.is_active = False
              send_mail(
              'i gotch you',
              'how are uou',
              'coolahmed21@hgmail.com',
              [email],
              fail_silently=False,
              )
          return super(SignUp, self).form_valid(form)
      success_url = reverse_lazy('login')
      template_name = &quot;accounts/signup.html&quot;
  </code></pre>