#35974: Use router.allow_relation in RelatedManager.add and GenericRelatedObjectManager.add -------------------------------------+------------------------------------- Reporter: Laurent Szyster | Owner: (none) Type: Bug | Status: new Component: Database layer | Version: 4.2 (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by Laurent Szyster):
Also, note that in the multiple database `QueryTestCase.test_generic_key_cross_database_protection`, the same error condition - a forbidden relation between distinct databases - now raises the same exception with the same message about a prevented relation: {{{ # Set a foreign key with an object from a different database msg = ( 'Cannot assign "<ContentType: Multiple_Database | book>": the ' "current database router prevents this relation." ) with self.assertRaisesMessage(ValueError, msg): review1.content_object = dive # Add to a foreign key set with an object from a different database with self.assertRaisesMessage(ValueError, msg): with transaction.atomic(using="other"): dive.reviews.add(review1) }}} Previously we would have an erroneous messages about an unsaved instance instead: {{{ - msg = ( - "<Book: Dive into Python> instance isn't saved. Use bulk=False or save the " - "object first." - ) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35974#comment:5> 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 visit https://groups.google.com/d/msgid/django-updates/01070193a0a3af36-efcfd2b7-ce69-4964-8b37-7a5befb10f27-000000%40eu-central-1.amazonses.com.