jdriscoll/django-imagekit — Issue #78: Sharing specs across models -- DRY?
Author: dmeehan
Created: 2011-12-06 02:29:36+00:00
State: open

With the old ImageKit API, I was able to create a single spec module at the site root that I could share across all of my image models within a project. This allowed me to have standard image sizes to use in various layouts. All I'd have to do is have that model inherit ImageModel and provide the path to the spec file.

Now, it seems that for each model that I want these ImageSpecs, I'll have to recreate each of the specs as fields on each individual model. And if I want to add or change specs, I'd need to edit each and every model.

Am I missing something with how this new API works? Is there a way to specify specs without having to spell out all the properties each time?

One thought that I had was to create an abstract model mixin that contains the site-wide specs have each of the models with images inherit that mixin. But this would require being very careful that the imageField be named the same field name.

The other problem is working with third party apps. Previously, I could create a proxy model that would give a third party model the ImageModel behavior and attach the spec file to it. I suppose I could do something similar now, but again the issue of field names remains.