> However, simply dodging the question doesn't address the original point: > why does Django adhere to such a nannyish philosophy, and how do you > solve the problem I presented *within Django* in a reasonable way? > > Thanks and regards, > -scott anderson
Template tags really are the best place to put display-specific logic like this. The original problem specified (a custom button and associated JavaScript for an object with the object's name in the button's id) could be solved using a template filter: BUTTON_TEMPLATE = u"""<span id="%(type)sButton-%(id)s"></span> <script type="text/javascript"> Button.create("%(type)sButton-%(id)s", "%(text)s"); </script>""" def button(obj, text): """ Usage:: {{ some_object|button:"Choose me!" }} """ return BUTTON_TEMPLATE % { 'type': obj._meta.object_name.lower(), 'id': obj._get_pk_val(), 'text': ugettext(text), } button = register.filter(button) If you wanted to have the button rendered from a template file, that would be easy to add. Or if you wanted a different template file to be used depending on the type of object (say, with each specialised template inheriting from a generic button template), that would also be pretty easy. For the other options you went on to mention (including extra, optional arguments), a "full" template tag would probably be in order. You wouldn't have to place all the necessary data in the context first as you stated - e.g. if you wanted to be able to specify a class for the button, it wouldn't be too much work to implement a tag which can sort this out: {% button some_object "Choose me!" class=superButton %} Jonathan. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---