I have a django model which I want to keep the newest 40 objects from.
I have tried the following code to do this
delete = model.count() - 40
model.objects.all[:delete].delete()
I get the error "Cannot use 'limit' or 'offset' with delete." with this though.
Can anyone suggest a way to do this?