Getting next and previous objects in Django

Add an order_by clause to ensure it orders by number.

next_issue = Issue.objects.filter(title=title, number__gt=issue.number).order_by('number').first()

I know this is a bit late, but for anyone else, django does have a nicer way to do this, see https://docs.djangoproject.com/en/1.7/ref/models/instances/#django.db.models.Model.get_previous_by_FOO

So the answer here would be something something like

next_issue = Issue.get_next_by_number(issue, title=title)

Django managers to do that with a bit of meta class cleaverness.