title: How to make a user profile view?
body: <p>Since I am new to django, this is my first time trying to create a user profile. And I don't know how to make a profile view with a link to it. Could you please give me an example</p>
  <p>models.py</p>
  <pre><code>class CustomUser(AbstractBaseUser, PermissionsMixin):
      email = models.EmailField(_('email address'), unique=True)
      username = models.CharField(max_length = 40, unique=True)
      is_staff = models.BooleanField(default=False)
      is_active = models.BooleanField(default=True)
      date_joined = models.DateTimeField(default=timezone.now)
      slug = AutoSlugField(populate_from = 'username', null=True)
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = ['username']
  
      objects = CustomUserManager()
  
      class Meta:
          verbose_name = 'Пользователь'
          verbose_name_plural = 'Пользователи'
  
      def __str__(self):
          return self.email
  
      def get_absolute_url(self):
          return reverse('profile', args=[str(self.slug)])
  
  
  class UserProfile(models.Model):
      user = models.OneToOneField(CustomUser, on_delete = models.CASCADE, null = True, db_constraint=False)
      avatar = ProcessedImageField(
          upload_to = 'avatar',
          format = &quot;JPEG&quot;,
          default = &quot;avatar/empty_avatar.jpg&quot;,
          processors = [ResizeToFit(250, 200)],
          options = {'quality': 90},
          blank = True,
          null = True,
      )
      description = models.TextField(default = '', blank =  True, null = True)
      slug = AutoSlugField(populate_from = 'user', null=True)
  
      class Meta:
          verbose_name = 'Профиль'
          verbose_name_plural = 'Профили'
  
      @receiver(post_save, sender=CustomUser)
      def create_user_profile(sender, instance, created, **kwargs):
          if created:
              UserProfile.objects.create(user=instance)
  
      @receiver(post_save, sender=CustomUser)
      def save_user_profile(sender, instance, **kwargs):
          try:
              instance.userprofile.save()
          except ObjectDoesNotExist:
              UserProfile.objects.create(user=instance)
  </code></pre>
  <p>forms.py</p>
  <pre><code>class CustomUserCreationForm(UserCreationForm):
  
      class Meta:
          model = get_user_model()
          fields = ('email', 'username',)
  
  
  class CustomUserChangeForm(UserChangeForm):
  
      class Meta:
          model = get_user_model()
          fields = ('email', 'username',)
  
  
  class UserProfileForm(forms.ModelForm):
      class Meta:
          model = UserProfile
          fields = ('avatar', 'description',)
  
  </code></pre>
  <p>views.py
  I want to create a link to an object using a slug or username so that it looks like &quot;accounts/profile/username&quot;</p>
  <pre><code>class UserProfileUpdate(generic.UpdateView, generic.FormView):
      model = UserProfile
      template_name = 'users/profile.html'
      form_class = UserProfileForm
  
      def form_valid(self, form):
          response = form.save(commit = False)
          response.save()
          return super(UserProfileUpdate, self).form_valid(form)
  
      def get_context_data(self, **kwargs):
          context = super(UserProfileUpdate, self).get_context_data(**kwargs)
          context['user'] = CustomUser.objects.get(slug = slug)
          context['profile'] = UserProfile.objects.get(user = context['user'])
          return context
  </code></pre>
  <p>I also want users to be able to view other users' profiles, not just thier own</p>