title: django User matching query does not exist
body: <p>i'm trying to signup with an otp for verification by sending email to the user mail, but getting this error, it's might be problem with signup.html, from where trying to get specific user otp to validate the data, if is there any better solution do this with django would be appreciate, <a href="https://i.stack.imgur.com/5ixjw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ixjw.png" alt="this is where it coming from" /></a></p>
  <p>models.py</p>
  <pre><code>class User(AbstractUser):
      username = None
      email = models.EmailField(_('email address'), unique=True)
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = []
  
      is_buyer = models.BooleanField(default=False)
      is_vendor = models.BooleanField(default=False)
  
      objects = CustomUserManager()
  
      def __str__(self):
          return self.email
  
  
  class UserOTP(models.Model):
      user = models.ForeignKey(User, on_delete = models.CASCADE)
      time_st = models.DateTimeField(auto_now = True)
      otp = models.SmallIntegerField()
  
  
  class Vendor(models.Model):
      user = models.OneToOneField(User, related_name='vendor', on_delete=models.CASCADE)
      business_name = models.CharField(max_length=50)
     
      def __str__(self):
          return self.user.email
  </code></pre>
  <p>forms.py</p>
  <pre><code>class VendorSignUpForm(UserCreationForm):   
      business_name = forms.CharField(required=True)
      email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
  
  
      class Meta:
          model = User
          fields = ('business_name', 'email', 'password1', 'password2', ) 
      
      @transaction.atomic
      def save(self):
          user = super().save(commit=False)
          user.is_vendor = True
          user.save()
          customer = Vendor.objects.create(user=user)
          customer.business_name=self.cleaned_data.get('business_name')
          customer.save()
          return user
  </code></pre>
  <p>views.py</p>
  <pre><code>def signup(request):
      if request.method == 'POST':
          get_otp = request.POST.get('otp')
          print(get_otp)
  
          if get_otp:
              get_user = request.POST.get('user')
              user = User.objects.get(email=get_user)
              if int(get_otp) == UserOTP.objects.filter(user = user).last().otp:
                  user.is_active = True
                  user.save()
                  messages.success(request, f'Account is Created For {user.email}')
                  return redirect('login')
              else:
                  messages.warning(request, f'You Entered a Wrong OTP')
                  return render(request, 'registration/signup.html', {'otp': True, 'user': user})
  
          form = VendorSignUpForm(request.POST)
          if form.is_valid():
              form.save()
              email = form.cleaned_data.get('email')
              user = User.objects.get(email=email)
              print(user)
              user.email = email
              user.is_active = False
              user.save()
              usr_otp = random.randint(100000, 999999)
              UserOTP.objects.create(user=user, otp = usr_otp)
              mess = f&quot;Hello {user.email},\nYour OTP is {usr_otp}\nThanks!&quot;
              send_mail( 'Welcome to Costume Base - Verify Your Email', 
              mess , settings.DEFAULT_FROM_EMAIL, [user.email], 
              fail_silently = False)
  
              return render(request, 'registration/signup.html', {'otp': True, user: user})  
      else:
          form = VendorSignUpForm()
      return render(request, 'registration/signup.html', {'form': form})  
  </code></pre>
  <p>signup.html</p>
  <pre><code>   {% block content %}
  
      &lt;div&gt;
          &lt;h2&gt;Signup&lt;/h2&gt;
  
      &lt;/div&gt;
  
      &lt;div&gt;
          {% if otp %}
  
          &lt;form method=&quot;POST&quot;&gt;
              {% csrf_token %}
              &lt;fieldset class=&quot;form-group&quot;&gt;
                  &lt;legend class=&quot;border-bottom display&quot;&gt;
                      &lt;h3 class=&quot;float-left&quot;&gt;Verify Your Email&lt;/h3&gt;
  
              
                  &lt;/legend&gt;
                     ** is this input value showing the error? **
                  &lt;input type=&quot;hidden&quot; value=&quot;{{user.email}}&quot; name = 'user' &gt;
  
                  &lt;div class=&quot;input-group mb-3&quot;&gt;
                    &lt;div class=&quot;input-group-prepend&quot;&gt;
                      &lt;span class=&quot;input-group-text&quot; id=&quot;basic-addon1&quot;&gt;OTP&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Enter Your OTP&quot; aria-label=&quot;OTP&quot;
                     aria-describedby=&quot;basic-addon1&quot; name = 'otp'&gt;
                  &lt;/div&gt;
                  
              &lt;/fieldset&gt;
              &lt;div class=&quot;form-grounp&quot;&gt;
                  &lt;button class=&quot;btn mainbtn&quot; type=&quot;submit&quot;&gt;Verify&lt;/button&gt;
                  &lt;small class=&quot;float-right text-muted&quot;&gt;&lt;i&gt;&lt;a href=&quot;#&quot; class=&quot;text-dark&quot; 
                    onclick=&quot;ReSendOTP('{{user.email}}', 'resendOTPmess')&quot;&gt;&lt;i id=&quot;resendOTPmess&quot;&gt;Resend&lt;/i&gt; OTP&lt;/a&gt;&lt;/small&gt;
              &lt;/div&gt;
          &lt;/form&gt;
          
            
  {% else %}
          
          &lt;form method=&quot;POST&quot;&gt;
              {% csrf_token %}
              {{form.as_p}}
  
              &lt;button type=&quot;submit&quot;&gt;Register&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      {% endif %}
      {% endblock content %}
  </code></pre>