Answer the question
In order to leave comments, you need to log in
How to make a request in django?
For example, there are two models Manager and Message.
class Manager(models.Model):
name = models.CharField(max_length=255)
create = models.DateTimeField(auto_now_add=True)
class Message(models.Model):
text = models.TextField()
manager = models.ForeignKey(Manager, models.SET_NULL, null=True)
Managers = Manager.objects.all().order_by('-create')[:5]
Messages = Enc.objects.filter(manager=Managers[i])
Answer the question
In order to leave comments, you need to log in
This is of course not the case, but it's better to format the code using tags.
Modify the message model like this:
class Message(models.Model):
text = models.TextField()
manager = models.ForeignKey(Manager, models.SET_NULL, null=True, related_name="messages")
somemanager=Manager.objects.first()
messages=somemanager.messages
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question