Django Get first and last record from QuerySet


Example

To get First object:

MyModel.objects.first()

To get last objects:

MyModel.objects.last()

Using Filter First object:

MyModel.objects.filter(name='simple').first()

Using Filter Last object:

MyModel.objects.filter(name='simple').last()