# Maneira 1
last_banner = Banner.objects.order_by('-pk')[:1]
if last_banner.exists():
instance['sort_order'] = last_banner[0].sort_order + 1
# Maneira 2
# Pode gerar erro caso não exista registro
last_banner = Banner.objects.latest('id')
Last active
April 17, 2021 15:32
-
-
Save richellyitalo/0038d9bb77f4da1cd8421dfd022959ba to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment