On Oct 6, 3:03 am, Bernd <[EMAIL PROTECTED]> wrote: > But now I want to compare 'image/gif'. A gif works like a jpeg. But I > didn't find a solution to write > > {% ifequal mime 'image/jpeg' or 'image/gif'%} > or > {% if mime in ['image/jpeg', 'image/gif] '%} > > Is there any chance to compare multiple values? Or are there better > solution for my problem?
I'd do it one of two ways: 1. Break the mime type into type and subtype. So you'd instead do: {% ifequal mimetype 'image' %} to recognize that this needs an 'img' tag. If your mimetype is a model, you'd have a separate type and subtype on it: {% ifequal mime.type 'image' %} 2. If you have a model with mime types in it, include a default "embedable template" in the model. Your "media" model could then render its default template in a method with a name like "embed". So that in your overall template you'd write something like: {{ media.embed }} to embed the media into the web page. The media model's embed method would probably look something like this: from django.template import Context from django.template.loader import get_template def embed(self, template=False): if not template: template = self.mimetype.embed_template template = get_template(template) context = Context() context['media'] = self context['mimetype'] = self.mimetype return template.render(context) You could then have a separate template just for <img> tags and for <object> tags, perhaps in a separate template folder called, say, "media". Jerry --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---