#33945: get_previous_in_order and get_next_in_order return incorrect data when objects is stored in non-default database -------------------------------------+------------------------------------- Reporter: François | Owner: nobody Granade | Type: Bug | Status: new Component: Database | Version: 4.0 layer (models, ORM) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- Using the a simple model with an `order_with_respect_to` (slight variation of the models in https://github.com/django/django/blob/main/tests/multiple_database/models.py):
{{{ class Person(models.Model): name = models.CharField(max_length=100, unique=True) class Pet(models.Model): name = models.CharField(max_length=100) owner = models.ForeignKey(Person, models.CASCADE) class Meta: order_with_respect_to = "owner" }}} then adding some object, and declaring an order for the pets: {{{ human = Person.objects.using("other").create(name="Human") dog = Pet.objects.using("other").create(name="Dog", owner=human) cat = Pet.objects.using("other").create(name="Cat", owner=human) duck = Pet.objects.using("other").create(name="Duck", owner=human) human.set_pet_order([duck.pk, dog.pk, cat.pk], "other") }}} Then simply trying to get the previous or next pet will fail: {{{ >>> dog.get_next_in_order() # would expect `cat` models.Pet.DoesNotExist: Pet matching query does not exist. >>> dog.get_previous_in_order() # would expect `duck` models.Pet.DoesNotExist: Pet matching query does not exist. }}} -- Ticket URL: <https://code.djangoproject.com/ticket/33945> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070182c18ecd5d-f0d5641d-9e80-4cc4-aba5-bb242f0dcab7-000000%40eu-central-1.amazonses.com.