Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
Hi Malcolm, > With the patch to check an instance rather than a class, perhaps I should extend the checks to check the result of get_readonly_fields() rather than just obj.readonly_fields. What do you think? I think the checks should be run statically against ModelAdmin instances, that is only

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
Hi Simon, On Thursday, 10 September 2015 16:57:51 UTC+1, Simon Charette wrote: > > Hi Malcolm, > > > The system check checks that all the values returned from > get_readonly_fields exist as class attributes on the ModelAdmin (or are > callable/fields on model, neither of which helps here). With

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
Hi Malcolm, > The system check checks that all the values returned from get_readonly_fields exist as class attributes on the ModelAdmin (or are callable/fields on model, neither of which helps here). With them being created via __getattr__, they don't. There might be something else going on he

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
Ticket filed: https://code.djangoproject.com/ticket/25374 On Thursday, 10 September 2015 11:27:13 UTC+1, Malcolm Box wrote: > > Hi Simon, > > I've tried that, and it still fails the same system check. > > The system check checks that all the values returned from > get_readonly_fields exist as cla

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
Hi Simon, I've tried that, and it still fails the same system check. The system check checks that all the values returned from get_readonly_fields exist as class attributes on the ModelAdmin (or are callable/fields on model, neither of which helps here). With them being created via __getattr__, t

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-09 Thread Simon Charette
Hi Malcom, What I meant to suggest is to remove the fields from `fields`/`readonly_fields` and dynamically return them in the `get_(fields|readonly_fields)` fields method. e.g. class ThumbnailFieldsAdmin(models.ModelAdmin): fields = [] readonly_fields = [] thumbnail_fields = []

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-09 Thread Malcolm Box
Hi Simon, Thanks for the pointer, but I don't think that helps. The fields are already declared using the existing fields / readonly_fields attributes on the ExampleAdmin class - and this is what get_fields / get_readonly_fields return. The system check fails because the fields declared don't exi

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Simon Charette
Hi Malcom! I would suggest you have a look at the ModelAdmin.get_fields() method to append your thumbnail read-only field names. As documented

Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Malcolm Box
Hi, I'm trying to add a dynamic method to a ModelAdmin so that I can have automatically generated thumbnail fields for any image by simply adding '_thumbnail' to the field definitions - which saves a lot of code when there's a load of admin classes with image fields that need thumbnails. e.g.