Next objects in Django by created using the get_next_by_



You can retrieve the next objects in Django by ID using the get_next_by_


from myapp.models import MyModel


# get the current object

current_obj = MyModel.objects.get(id=current_id)


# get the next object by ID

next_obj = current_obj.get_next_by_created()


# get the second next object by ID

second_next_obj = next_obj.get_next_by_created()


To retrieve the previous objects in Django by ID, you can use the get_previous_by



Example in static generator




vim page/management/commands/gen_blog.py


vim /home/sites/auto-verkopen-belgie/www/templates/blog.html


python3 manage.py gen_blog


cp -r ../www/nl/info/auto-export/ ../www/assets/


http://dev…/assets/auto-export/index.html




Comments