shortcut for Django Get data and mark_safe a specific column -
i'm wondering if there shortcut code? code get's video data , mark_safe embed code.
videos = video.objects.all() mark_safe_videos = [] video in videos: video.embed_code = mark_safe(video.embed_code) mark_safe_videos.append(video)
i'm using django 1.8
you can add property model , avoid additional code in view:
from django.template.defaultfilters import mark_safe class video(models.model): . . . @property def safe_embed(self): return mark_safe(self.embed_code)
i tend favor "fat model, skinny controller (view in django)" methodology.
Comments
Post a Comment