title: Django - models - how to describe a specific bidirectional relation between two models?
body: <p>I have two models: <strong>Person</strong> and <strong>Department</strong>. Each person can work in one department. Department can be run by many people. I'm not sure how to construct this relation in Django models.</p>
  
  <p>Here's one of my unsuccessful tryings [models.py]:</p>
  
  <pre><code>class Person(models.Model):
       department = models.ForeignKey(Department)
       firstname = models.TextField(db_column='first_name')
       lastname = models.TextField(db_column='last_name')
       email = models.TextField(blank=True)
  
  class Department(models.Model):
      administration = models.ManyToManyField(Person)
      name = models.TextField()
  </code></pre>
  
  <p>I am aware that the code does not work, because the <code>Person</code> class references the <code>Department</code> class in its ForeignKey relationship before the Department is defined. Likewise, if I move the Department definition before the Person definition, the <code>Department</code> class will reference the <code>Person</code> class in its ManyToMany relationships before the Person is defined.</p>
  
  <p>What is the proper way to model this specific relation in Django?
  I would appreciate if you could provide the example (I'm a newbie).</p>