Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_next_id(curr_id):
- result = []
- Image_list = Image.objects.all()
- total = Image.objects.all().count()
- for i in range(len(Image_list)):
- result.append(Image_list[i].id)
- index_curr = result.index(curr_id)
- if index_curr == total:
- new_index = 0
- else:
- new_index = index_curr + 1
- return Image_list[new_index]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement