class Companies models Model user models ForeignKey User company_name

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class Companies(models.Model)
user = models.ForeignKey(User)
company_name = models.CharField(max_length=200)
dealing = models.ForeignKey(Dealings)
class Dealings(models.Model)
dealing_number = models.CharField(max_length=200)
dealing_item = models.ForeignKey(DealingsItem)
class DealingsItem(models.Model)
propfield = models.CharField(max_length=200)
"""
The problem is that the request should go on Dealing
Dealing.objects.select_related().filter(dealing_number__startswith=201)
But still I need to do filter by company name
"""