title: UpdateView with my own made Custom_user_model in Django
body: <p>I want to use email as authentication so i made change in default user and made a new custom one by AbstractUser but when i am making view to update the profile that is not giving me any query showing Page not found No User matches the given query.
  Here is sample codes</p>
  
  <pre><code>**models.py**
  from django.db import models
  from django.contrib.auth.models import AbstractUser,BaseUserManager
  from django.utils.translation import ugettext_lazy as _
  from django.core.validators import MinValueValidator, MaxValueValidator
  from django.db.models.signals import pre_save
  from django.utils.text import slugify
  from django.urls import reverse
  from django.utils import timezone
  from .choices import branch_choices
  
  #from app_name.models import skills
  # Create your models here.
  
  class UserManager(BaseUserManager):
      """Define a model manager for User model with no username field."""
  
      use_in_migrations = True
  
      def _create_user(self, email, password, **extra_fields):
          """Create and save a User with the given email and password."""
          if not email:
              raise ValueError('The given email must be set')
          email = self.normalize_email(email)
          user = self.model(email=email, **extra_fields)
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_user(self, email, password=None, **extra_fields):
          """Create and save a regular User with the given email and password."""
          extra_fields.setdefault('is_staff', False)
          extra_fields.setdefault('is_superuser', False)
          return self._create_user(email, password, **extra_fields)
  
      def create_superuser(self, email, password, **extra_fields):
          """Create and save a SuperUser with the given email and password."""
          extra_fields.setdefault('is_staff', True)
          extra_fields.setdefault('is_superuser', True)
  
          if extra_fields.get('is_staff') is not True:
              raise ValueError('Superuser must have is_staff=True.')
          if extra_fields.get('is_superuser') is not True:
              raise ValueError('Superuser must have is_superuser=True.')
  
          return self._create_user(email, password, **extra_fields)
  
  
  
  
  
  
  
  class User(AbstractUser):
      #age=models.CharField(max_length=2,blank=True)
      bio = models.TextField(max_length=500, blank=True)
      slug=models.SlugField(unique=True)
      #locatition = models.CharField(max_length=30, blank=True)
      designation=models.CharField(max_length=50,blank=True)
      company=models.CharField(max_length=255,blank=True)
      #skills=models.ManyToManyField(skills)
      passing=models.PositiveIntegerField(validators=[MinValueValidator(2002),MaxValueValidator(timezone.now().year)],default=timezone.now().year,blank=True)
      branch=models.CharField(max_length=10,choices=branch_choices,blank=True)
      #mobile=models.IntegerField(blank=True)
      website=models.URLField(max_length=255,blank=True)
      mtj=models.TextField(max_length=500,blank=True)
      username=None
      email=models.EmailField(_('email address'),unique=True)
      USERNAME_FIELD='email'
      REQUIRED_FIELDS=[]
      objects = UserManager()
  
      def __str__(self):
          return self.email
      def get_absolute_url(self):
          return reverse("my_profile",kwargs={"slug":self.slug})  
  
  def create_slug(instance,new_slug=None):
      s = instance.email
      result = s[:s.find("@")]
      slug=slugify(result)
      if new_slug is not None:
          slug=new_slug
      qs=User.objects.filter(slug=slug).order_by("-id")
      exists=qs.exists()
      if exists:
          new_slug="%s-%s"%(slug,qs.first().id)
          return create_slug(instance,new_slug=new_slug)
      return slug
  
  
  def pre_save_post_reciever(sender,instance,*args,**kwargs):
      if not instance.slug:
          instance.slug=create_slug(instance)
  pre_save.connect(pre_save_post_reciever,sender=User)
  </code></pre>
  
  <p>Here is my view to UpdateProfile</p>
  
  <pre><code>    from django.shortcuts import render,redirect,get_object_or_404
  from .forms import SignUpForm
  from django.contrib.auth import login 
  from django.utils.decorators import method_decorator
  from django.conf import settings
  from django.contrib.auth.forms import UserChangeForm
  # Create your views here.
  from django.urls import reverse_lazy
  from django.contrib.auth.decorators import login_required
  from django.views.generic import UpdateView,ListView
  from django.contrib.auth import get_user_model
  #from django.contrib.auth.models import User
  User = get_user_model()
  
  
  @method_decorator(login_required, name='dispatch')
  class UserUpdateView(UpdateView):
      model = User
      fields = ('first_name', 'last_name','bio','designation','company','passing','branch','website','mtj')
      template_name = 'account/my_account.html'
  
      def get_object(self):
          return self.request.user
  </code></pre>
  
  <p>Urls.py</p>
  
  <pre><code>from .views import UserUpdateView
  path('profile/edit/',UserUpdateView,name='my_account')
  </code></pre>
  
  <p>,</p>
  
  <p>Thank you </p>