I'd like to allow embedded youtube videos (and other commonly embedded media) to be displayed using Django. Is there anyway in Django to allow this to happen?
The context is that I'm trying to display rss items, which may or may not have one or more embedded videos in a given item. Using the "safe" filter discards them, and writing a custom filter that returns mark_safe(html), where "html" is the passed through item, also discards them. Is there anyway to get past this?
Would you have to pull out the embedded objects from the rss items from within the view, and then re-embed them inside the template?
While I'm new to Django, I've done a fair amount of searching on this topic, and haven't found a useful answer yet. Any help would be much appreciated.
preguntado el 04 de julio de 12 a las 05:07
I figured out the answer to this question... I was using feedparser, which was removing certain content. I ended up adding a monkey patch (I believe this is the correct term) to allow more material make it through:
feedparser._HTMLSanitizer.acceptable_elements.add("object") feedparser._HTMLSanitizer.acceptable_elements.add("embed") feedparser._HTMLSanitizer.acceptable_elements.add("iframe")