liberation / django-admin-tabs

Make possible to display fieldsets and inline in cols and tabs in the Django admin
Do What The F*ck You Want To Public License
32 stars 15 forks source link

Better encapsulation #5

Open andybak opened 11 years ago

andybak commented 11 years ago

This is going to be a rather vague issue report but I'll try and explain myself as best I can.

I ran the example project and loved the result.

However - when I looked at the code - too much of the work seemed to be happening in the template for the example app and not enough in the app itself.

I currently lack any concrete suggestions for fixing this but my hunch is that with some clever template inheritance, mixins to use with ModelAdmin subclasses or maybe some templatetags to use in admin templates, then implementing this could be a lot simpler and cleaner.

diox commented 11 years ago

I think we all agree here :)

We need specific extensions points in templates and we couldn't find a clean way to do this without redefining our own, sadly. It might be a little better in 1.4 and 1.5 (and we could drop 1.3 support if needed), I haven't checked. Feel free to submit more concrete ideas, a proof-of-concept, or even a full pull request if you have some time to work on it, we'll gladly accept any help :-)

andybak commented 11 years ago

Thanks for the reply.

I've always regarded copy+pasting whole admin templates to be something to use only as a last resort (and by 'last resort' I mean only after I've tried chewing off my own leg!)

If there are no {% block %} tags that could possibly allow me to override a smaller part of the template I've usually resorted to manipulating the DOM with jQuery to get the result I need. It's actually not as bad as it sounds. It is brittle but is easy to fix up if the underlying HTML changes.

I do understand if you have aesthetic objections to this approach but it's worked well for some of my admin customizations.