title: how to exclude admin user from my user list
body: <p>how to exclude admin users from my user list? the below image shows the problem. I don't want to show the admin user in the friend list of a user.</p>
  <p><a href="https://i.stack.imgur.com/jcz5G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jcz5G.png" alt="enter image description here" /></a></p>
  <p>I don't want to show the main_admin user on this user list as it is my admin user of the site</p>
  <p>views.py</p>
  <pre><code>from django.shortcuts import render, redirect, get_object_or_404
  from .models import Profile
  from feed.models import Post
  from django.contrib import messages
  from django.contrib.auth.decorators import login_required
  from django.contrib.auth import get_user_model
  from django.conf import settings
  from django.http import HttpResponseRedirect
  from .models import Profile, FriendRequest
  from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
  import random
  
  User = get_user_model()
  
  
  @login_required
  def users_list(request):
      users = Profile.objects.exclude(user=request.user)
      sent_friend_requests = FriendRequest.objects.filter(from_user=request.user)
      sent_to = []
      friends = []
      for user in users :
          friend = user.friends.all()
          for f in friend:
              if f in friends:
                  friend = friend.exclude(user=f.user)
          friends += friend
      my_friends = request.user.profile.friends.all()
      for i in my_friends:
          if i in friends:
              friends.remove(i)
      if request.user.profile in friends:
          friends.remove(request.user.profile)
      random_list = random.sample(list(users), min(len(list(users)), 10))
      for r in random_list:
          if r in friends:
              random_list.remove(r)
      friends += random_list
      for i in my_friends:
          if i in friends:
              friends.remove(i)
      for se in sent_friend_requests:
          sent_to.append(se.to_user)
      context = {
          'users': friends,
          'sent': sent_to
      }
      return render(request, &quot;users/users_list.html&quot;, context)
  
  
  # def queryset(self, request):
  #     if  request.user.is_superuser:
  #         return User.objects.filter(is_superuser=False)
  #     return User.objects.all()
  
  
  
  def friend_list(request):
      p = request.user.profile
      friends = p.friends.all()
      context = {
          'friends': friends
      }
      return render(request, &quot;users/friend_list.html&quot;, context)
  
  
  @login_required
  def send_friend_request(request, id):
      user = get_object_or_404(User, id=id)
      frequest, created = FriendRequest.objects.get_or_create(
          from_user=request.user,
          to_user=user)
      return HttpResponseRedirect('/users/{}'.format(user.profile.slug))
  
  
  @login_required
  def cancel_friend_request(request, id):
      user = get_object_or_404(User, id=id)
      frequest = FriendRequest.objects.filter(
          from_user=request.user,
          to_user=user).first()
      frequest.delete()
      return HttpResponseRedirect('/users/{}'.format(user.profile.slug))
  
  
  @login_required
  def accept_friend_request(request, id):
      from_user = get_object_or_404(User, id=id)
      frequest = FriendRequest.objects.filter(from_user=from_user, to_user=request.user).first()
      user1 = frequest.to_user
      user2 = from_user
      user1.profile.friends.add(user2.profile)
      user2.profile.friends.add(user1.profile)
      if FriendRequest.objects.filter(from_user=request.user, to_user=from_user).first():
          request_rev = FriendRequest.objects.filter(from_user=request.user, to_user=from_user).first()
          request_rev.delete()
      frequest.delete()
      return HttpResponseRedirect('/users/{}'.format(request.user.profile.slug))
  
  
  @login_required
  def delete_friend_request(request, id):
      from_user = get_object_or_404(User, id=id)
      frequest = FriendRequest.objects.filter(from_user=from_user, to_user=request.user).first()
      frequest.delete()
      return HttpResponseRedirect('/users/{}'.format(request.user.profile.slug))
  
  
  def delete_friend(request, id):
      user_profile = request.user.profile
      friend_profile = get_object_or_404(Profile, id=id)
      user_profile.friends.remove(friend_profile)
      friend_profile.friends.remove(user_profile)
      return HttpResponseRedirect('/users/{}'.format(friend_profile.slug))
  
  
  @login_required
  def profile_view(request, slug):
      p = Profile.objects.filter(slug=slug).first()
      u = p.user
      sent_friend_requests = FriendRequest.objects.filter(from_user=p.user)
      rec_friend_requests = FriendRequest.objects.filter(to_user=p.user)
      user_posts = Post.objects.filter(user_name=u)
  
      friends = p.friends.all()
  
      # is this user our friend
      button_status = 'none'
      if p not in request.user.profile.friends.all():
          button_status = 'not_friend'
  
          # if we have sent him a friend request
          if len(FriendRequest.objects.filter(
                  from_user=request.user).filter(to_user=p.user)) == 1:
              button_status = 'friend_request_sent'
  
          # if we have recieved a friend request
          if len(FriendRequest.objects.filter(
                  from_user=p.user).filter(to_user=request.user)) == 1:
              button_status = 'friend_request_received'
  
      context = {
          'u': u,
          'button_status': button_status,
          'friends_list': friends,
          'sent_friend_requests': sent_friend_requests,
          'rec_friend_requests': rec_friend_requests,
          'post_count': user_posts.count
      }
  
      return render(request, &quot;users/profile.html&quot;, context)
  
  
  def register(request):
      if request.method == 'POST':
          form = UserRegisterForm(request.POST)
          if form.is_valid():
              form.save()
              username = form.cleaned_data.get('username')
              messages.success(request, f'Your account has been created! You can now login!')
              return redirect('login')
      else:
          form = UserRegisterForm()
      return render(request, 'users/register.html', {'form': form})
  
  
  @login_required
  def edit_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('my_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/edit_profile.html', context)
  
  
  @login_required
  def my_profile(request):
      p = request.user.profile
      you = p.user
      sent_friend_requests = FriendRequest.objects.filter(from_user=you)
      rec_friend_requests = FriendRequest.objects.filter(to_user=you)
      user_posts = Post.objects.filter(user_name=you)
      friends = p.friends.all()
  
      # is this user our friend
      button_status = 'none'
      if p not in request.user.profile.friends.all():
          button_status = 'not_friend'
  
          # if we have sent him a friend request
          if len(FriendRequest.objects.filter(
                  from_user=request.user).filter(to_user=you)) == 1:
              button_status = 'friend_request_sent'
  
          if len(FriendRequest.objects.filter(
                  from_user=p.user).filter(to_user=request.user)) == 1:
              button_status = 'friend_request_received'
  
      context = {
          'u': you,
          'button_status': button_status,
          'friends_list': friends,
          'sent_friend_requests': sent_friend_requests,
          'rec_friend_requests': rec_friend_requests,
          'post_count': user_posts.count
      }
  
      return render(request, &quot;users/profile.html&quot;, context)
  
  
  @login_required
  def search_users(request):
      query = request.GET.get('q')
      object_list = User.objects.filter(username__icontains=query)
      context = {
          'users': object_list
      }
      return render(request, &quot;users/search_users.html&quot;, context)
  </code></pre>
  <blockquote>
  <p>Models.py</p>
  </blockquote>
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from django.urls import reverse
  from django.utils import timezone
  from django.db.models.signals import post_save
  from django.conf import settings
  from autoslug import AutoSlugField
  
  
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE,)
      image = models.ImageField(default='default.jpg', upload_to='profile_pics')
      slug = AutoSlugField(populate_from='user')
      bio = models.CharField(max_length=255, blank=True)
      friends = models.ManyToManyField(&quot;Profile&quot;, blank=True)
  
      def __str__(self):
          return str(self.user.username)
  
      def get_absolute_url(self):
          return &quot;/users/{}&quot;.format(self.slug)
  
  
  def post_save_user_model_receiver(sender, instance, created, *args, **kwargs):
      if created:
          try:
              Profile.objects.create(user=instance)
          except:
              pass
  
  
  post_save.connect(post_save_user_model_receiver, sender=settings.AUTH_USER_MODEL)
  
  
  class FriendRequest(models.Model):
      to_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='to_user', on_delete=models.CASCADE)
      from_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='from_user', on_delete=models.CASCADE)
      timestamp = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          return &quot;From {}, to {}&quot;.format(self.from_user.username, self.to_user.username)
  </code></pre>
  <p>Here as you can see main_admin is my superuser and I don't want it to appear in the add new friend list, so please help me out to solve this problem as I'm new to django, Thank you</p>