from django.db.models import Max new_default = FooterLinks.objects.all().aggregate(Max('order'))['order__max']+1 FooterLinks.objects.filter(order=0).update(order=new_default)
To make the change permanent, either migrate the database with the South; or how danihp suggested overriding the save method.
However, note that if the table becomes very large, it would be better to implement this logic as a trigger in your database.
Edit:
No, you will run this one time and it will update all records in your database - ideally, you will do this during normal system / window maintenance outages.
To adjust the value in the text box, you need to update the default value specified in your model. Note that default can be either called or called (in other words, a method). Each time a field is displayed, the method will be called.
You can use this to ensure that the default value is always calculated by providing a default method.
source share