AttributeError with multiple ForeignKeyField to the same table.
Sorry. I forgot to write peewee's version. 2.1.4
 This is because there are two foreign keys to the same model on `Student`.  Specify `related_name` attributes (the backref on `Parent`):

``` python
class Student(Model):
    name = CharField()
    father = ForeignKeyField(Parent, related_name='father_students')
    mother = ForeignKeyField(Parent, related_name='mother_students')
```

This is a new error that is raised because both parent fks would use the same backref (`student_set`), which is ambiguous.
 But when a large database is generated with Pwiz, related_names are not written, and the models.py is unusable (except if I edit models.py by hand, but it's tedious...)
 > But when a large database is generated with Pwiz, related_names are not written, and the models.py is unusable (except if I edit models.py by hand, but it's tedious...)

What would you propose?
 As a begginer in ORM, not relevant things I guess :)
Maybe Pwiz could be improved to automatically add "related_name=XXX" statement in those cases?
You are better than me to know if it's relevant or not ^^
For my purposes, I dit by hand on a 2000 lines models file. It's not as long as it sounds, but the problem is that people using pwiz won't know how to solve the problem (maybe a little update on the documentation about this "issue" would be suitable). 
 Charles,
could peewee use the attribute name in place of class name to reference to set?
 I agree that it would be nice if pwiz generated working models out of the box, no matter the names. Couldn't it simply use the field name of the referenced model to this effect, i.e. set it as a default `related_name`? Whether it's `father_students`, `fathers`, `mother_students` or what not wouldn't really matter since you can always change it when you find it too awkward.
 I'll look into it, but I'm going to go out on a limb and say that `pwiz` does a pretty damn good job at what it does.
 I agree! I actually just found out about peewee and used it to generate models for quite large existing databases. With search/replace, I had fixed all problems within minutes. I'm already pretty amazed as it is! This is awesome! :-)

Charles,

Here a simple example to reproduce:

``` python
from peewee import *

class Parent(Model):
    name = CharField()

class Student(Model):
    name = CharField()
    father = ForeignKeyField(Parent)
    mother = ForeignKeyField(Parent)
```

```
AttributeError: Foreign key: student.mother related name "student_set" collision with foreign key using same related_name.
```

It seems that peewee tries to make a set with all the references to same table, but there is case where the attributes are different.
