Django ORM - confusion about Router.allow_relation()
<p>In the documentation of the new version of Django there is an ambiguity between what is said in the text and the code shown.</p>

<p>In the section that describes the multidatabase configuration it speaks about the router configuration, and there is a method:</p>

<blockquote>
  <p><code>allow_relation(obj1, obj2, **hints)</code></p>
  
  <p>Return True if a relation between obj1 and obj2 should be allowed, False if the relation should be prevented, or None if the router has
  no opinion. This is purely a validation operation, used by foreign key
  and many to many operations to determine if a relation should be
  allowed between two objects.</p>
</blockquote>

<p>At the end of the documentation there is this:</p>

<blockquote>
  <p>Django doesn’t currently provide any support for foreign key or
  many-to-many relationships spanning multiple databases. If you have
  used a router to partition models to different databases, any foreign
  key and many-to-many relationships defined by those models must be
  internal to a single database.</p>
  
  <p>This is because of referential integrity. In order to maintain a
  relationship between two objects, Django needs to know that the
  primary key of the related object is valid. If the primary key is
  stored on a separate database, it’s not possible to easily evaluate
  the validity of a primary key.</p>
</blockquote>

<p>But the router code given as an example is the following:</p>

<pre><code>def allow_relation(self, obj1, obj2, **hints):
     """
     Relations between objects are allowed if both objects are
     in the primary/replica pool.
     """
     db_list = ('primary', 'replica1', 'replica2')
     if obj1._state.db in db_list and obj2._state.db in db_list:
         return True
     return None
</code></pre>

<p>So even if the objects are from different databases the relation is allowed by the software.</p>

<p>Does anyone know what it means?</p>

<p>Thanks.</p>