4 examples of 'django media url' in Python

Every line of 'django media url' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
7@register.simple_tag
8def media_url():
9 return settings.MEDIA_URL
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

49@register.filter
50def media(url):
51 media_url = url
52 url_is_absolute = bool(urlparse(url).netloc)
53 if not url_is_absolute:
54 media_url = os.path.join(settings.MEDIA_URL, url)
55 return media_url
38def resolve_get_absolute_url(self, _args, *_kwargs):
39 return self.get_absolute_url()
16def get_video_url(self, video):
17 from videos.models import VIDEO_TYPE_HTML5, VIDEO_TYPE_YOUTUBE, VIDEO_TYPE_BLIPTV, VIDEO_TYPE_VIMEO, VIDEO_TYPE_DAILYMOTION
18 if video.video_type == VIDEO_TYPE_HTML5:
19 return video.video_url
20 elif video.video_type == VIDEO_TYPE_YOUTUBE:
21 return 'http://www.youtube.com/watch?v={0}'.format(video.youtube_videoid)
22 elif video.video_type == VIDEO_TYPE_BLIPTV:
23 return 'http://blip.tv/file/{0}/'.format(video.bliptv_fileid)
24 elif video.video_type == VIDEO_TYPE_VIMEO:
25 return 'http://vimeo.com/{0}'.format(video.vimeo_videoid)
26 elif video.video_type == VIDEO_TYPE_DAILYMOTION:
27 return 'http://dailymotion.com/video/{0}'.format(video.dailymotion_videoid)
28 else:
29 return video.video_url

Related snippets