Chat.objects.filter(participants=request.user).filter(participants__id=friend_id_from_url)
def validate_phone(value):
try:
CustomUser.objects.get(phone=value)
raise ValidationError("занят")
except CustomUser.DoesNotExist:
return value
The app should contain a templatetags directory, at the same level as models.py, views.py, etc.