1👍
✅
Provide a method on the Application
class Application(models.Model):
name = models.CharField(max_length=50)
def next_upcoming_release(self):
future_releases = self.release_set.filter(release_date__gte=datetime.datetime.now())
return future_releases.order_by('release_date').first()
You can call this in the template with {{ application.next_upcoming_release }}
.
Source:stackexchange.com