tickets_full: 1224

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
1224 2006-01-14 13:11:50 2006-10-16 14:21:26 2019-06-24 00:28:16.411060 Unreviewed closed Database layer (models, ORM) enhancement normal magic-removal wontfix Use inner class for custom Manager in magic removal branch 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? adrian Simon Willison   0 0 0 0 0 0