The issue currently is filtering for all users that
- Are not the user
- Where model field == True
If I remove the ".filter(model="True")" than the first requirement is met. How can I add more filters to the users?
Current error message:
FieldError at /explore/ Cannot resolve keyword 'model' into field. Choices are: date_joined, email, emailaddress, favorite, first_name, groups, id, images, is_active, is_staff, is_superuser, last_login, last_name, logentry, owner, password, profile, socialaccount, user_permissions, username, webhook
I understand that the error means. However, I'm not sure how to implement it in the code.
view.py
def explore(request, pk=None):
template_name = 've/cp/explore.html'
users_list = User.objects.exclude(id=request.user.id).filter(model="True")
paginator = Paginator(users_list, 16) # Show x per page
page = request.GET.get('page')
users = paginator.get_page(page)
try:
favorite = Favorite.objects.get(current_user=request.user)
favorites = favorite.users.all()
except Favorite.DoesNotExist:
favorites = None
args = {
'favorites': favorites, 'users': users,
}
return render(request, template_name, args)
models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
bio = models.TextField(max_length=500, blank=True, null=True)
model = models.BooleanField(default=False)
...