#27629: Inconsistent check of allow_relation in ForwardManyToOneDescriptor.__set__ -------------------------------------+------------------------------------- Reporter: Sven Coenye | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.10 (models, ORM) | Severity: Normal | Resolution: Keywords: allow_relation | Triage Stage: Accepted ForwardManyToOneDescriptor | Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Ian R-P): If all DATABASE_ROUTERS return None for db_for_write it takes the {{{hints['instance']._state.db}}} value (if one exists) and returns that for the parent model's own _state.db value. {{{ ...\django\db\utils.py:257 def_router_func(action): 267: chosen_db = method(model, **hints) 268: if chosen_db: 269: return chosen_db 270: instance = hints.get('instance') 271: if instance is not None and instance._state.db: 272: return instance._state.db 273: return DEFAULT_DB_ALIAS 274: return _route_db }}} I was able to solve this by changing my database router from return None to 'default' (for the time being, as documentation says it should return None). -- Ticket URL: <https://code.djangoproject.com/ticket/27629#comment:3> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.565e3f514192d086eeaae9941c105b16%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.