﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1224	Use inner class for custom Manager in magic removal branch 	Simon Willison	Adrian Holovaty	"The current (implemented) proposal for adding custom table-level methods in RemovingTheMagic is a little clumsy:

{{{
class PersonManager(models.Manager):
    def get_list(self, **kwargs):
        # Changes get_list() to hard-code a limit=10.
        kwargs['limit'] = 10
        return models.Manager.get_list(self, **kwargs) # Call the ""real"" get_list() method.

class Person(models.Model):
    first_name = models.CharField(maxlength=30)
    last_name = models.CharField(maxlength=30)
    objects = PersonManager()
}}}

How about doing this using an inner class instead?

{{{
class Person(models.Model):
    first_name = models.CharField(maxlength=30)
    last_name = models.CharField(maxlength=30)
    class Manager(models.Manager):
        def get_list(self, **kwargs):
            # Changes get_list() to hard-code a limit=10.
            kwargs['limit'] = 10
            return self.get_list(self, **kwargs) # Call the ""real"" get_list() method.
}}}

Are there any reasons this couldn't work?"	enhancement	closed	Database layer (models, ORM)	magic-removal	normal	wontfix			Unreviewed	0	0	0	0	0	0
