Answer the question
In order to leave comments, you need to log in
How to filter objects of one model by filtering another model in django?
There is a model extending the User model:
class Profile(models.Model):
'''additional parameters to the user'''
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
teamleader = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, related_name='workers_of_group', null=True) #user teamleader
class TestData(models.Model):
'''data table'''
worker = models.ForeignKey(User, on_delete=models.CASCADE, related_name='worker',)
data1 = models.IntegerField()
data2 = models.IntegerField()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question