python manage.py debugsqlshell from main.models import Telephone phones = list(Telephone.objects.filter(number__startswith="310")[:50]) for phone in phones: print(phone.user)