title: RelatedObjectDoesNotExist at /admin/login/ User has no profile
body: <p>learning django and created a new project.
  login to admin page through <a href="http://127.0.0.1:8000/admin" rel="nofollow noreferrer">http://127.0.0.1:8000/admin</a>
  But after adding profile code for every user I am getting the below error </p>
  
  <p><strong>Error</strong></p>
  
  <p><a href="https://i.stack.imgur.com/iRuNX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iRuNX.jpg" alt="Error screenshot"></a></p>
  
  <p>user/models.py</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from PIL import Image
  
  class Profile(models.Model):
      user=models.OneToOneField(User,on_delete=models.CASCADE)
      image=models.ImageField(default='default.jpg',upload_to='profile_pics')
  
      def __str__(self):
          return f'{self.user.username} Profile'
  
      def save(self):
          super().save()
          img=Image.open(self.image.path)
          if img.height&gt;300 or img.width &gt;300:
              output_size=(300,300)
              img.thumbnail(output_size)
              img.save(self.image.path)
  </code></pre>
  
  <p>user/views.py</p>
  
  <pre><code>from django.shortcuts import render,redirect
  from django.contrib.auth.forms import UserCreationForm
  from django.contrib import messages
  from django.contrib.auth.decorators import login_required
  from .forms import UserRegisterForm,UserUpdateForm,ProfileUpdateForm
  
  def register(request):
      if request.method=="POST":
          form=UserRegisterForm(request.POST)
          if form.is_valid():
              form.save() # it will save user in database
              #form.cleaned_data is dictionary it will contain the data from form
              username=form.cleaned_data.get('username')
              messages.success(request,f'Your account has been created!')
              return redirect('login')
      else:
          form=UserRegisterForm()
  
      # instance of UserCreationForm() class will create form in template as we are passing there
      return render(request,'users/register.html',{'form':form})
  
  @login_required()
  def profile(request):
      if request.method == "POST":
          u_form=UserUpdateForm(request.POST,instance=request.user)
          p_form=ProfileUpdateForm(request.POST,request.FILES,instance=request.user.profile)
          if u_form.is_valid() and p_form.is_valid():
              u_form.save()
              p_form.save()
              messages.success(request, f'Your account has been updated!')
              return redirect('profile')
      else:
          u_form = UserUpdateForm(instance=request.user)
          p_form = ProfileUpdateForm(instance=request.user.profile)
      context={
          'u_form':u_form,
          'p_form':p_form
      }
      return render(request,'users/profile.html',context)
  </code></pre>
  
  <p>users/forms.py</p>
  
  <pre><code>from django import forms
  from django.contrib.auth.models import User
  from django.contrib.auth.forms import UserCreationForm
  from .models import Profile
  class UserRegisterForm(UserCreationForm):
      email=forms.EmailField()
  
      class Meta:
          model=User #model will affected will be User as after submitting form user table gonna affect. and below will fields in forms
          fields=['username','email','password1','password2']
  
  class UserUpdateForm(forms.ModelForm):
      email = forms.EmailField()
  
      class Meta:
          model = User  # model will affected will be User as after submitting form user table gonna affect. and below will fields in forms
          fields = ['username', 'email']
  
  class ProfileUpdateForm(forms.ModelForm):
      class Meta:
          model=Profile
          fields=['image']
  </code></pre>
  
  <p>users/signals.py</p>
  
  <pre><code>from django.db.models.signals import post_save
  from django.contrib.auth.models import User
  from django.dispatch import receiver
  from .models import Profile
  
  @receiver(post_save,sender=User)
  def create_profile(sender,instance,created,**kwargs):
      if created:
          Profile.objects.create(user=instance)
  
  
  @receiver(post_save, sender=User)
  def save_profile(sender, instance, created, **kwargs):
      instance.profile.save()
  </code></pre>
  
  <p>it might be that the Admin profile is not available and it is not creating.any suggestions ?</p>