Adrian Holovaty wrote: > Thoughts? > > http://code.djangoproject.com/wiki/RemovingTheMagic > > Please comment here rather than on the wiki. > > Adrian > > -- > Adrian Holovaty > holovaty.com | djangoproject.com | chicagocrime.org >
Hi, Just looking over the wiki page again, I really dislike the class Person(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) objects = models.TextField() class META: manager = Manager(name='more_objects') class Person(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) class META: manager = PersonManager() For overriding the manager name and class. I don't think class META needs to get involved at all. This seems much cleaner ( and avoids random things like "manager = "): class Person(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) objects = models.TextField() more_objects = Manager() A manager in the class will suppress the creation of a default one by the metaclass. class Person(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) objects = PersonManager() This fits in especially well with the idea of leaving the fields in the class as a descriptor, and Manager will also be a descriptor (as I said before, one which forbids access via an instance). It also easily allows people to do manual pluralisation if they want to. Another possibility is that the PersonManager() acts similarly to the related field sets I talked about previously, and you can optionally define multiple Managers, eg: class Person(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=30) nice = models.BooleanField() people = PersonManager() nice_people = PersonManager().filter(nice__exact=True) This would be a simple way to define stuff in one place. Obviously it could be done with methods as well, but this seems more consistent.