Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
Created July 18, 2013 12:53
Show Gist options
  • Save JamesTheBard/6029055 to your computer and use it in GitHub Desktop.
Save JamesTheBard/6029055 to your computer and use it in GitHub Desktop.
A quick update...
from django import template
from cms_downloads.models import FileRevisions
import os
register = template.Library()
def get_latest_download_by_name(file_name):
download_query = FileRevisions.objects.filter(name__name__startswith=filename).order_by('-version')[0]
if download_query.count == 0: download_query = None
return {'cms_download': download_query}
register.inclusion_tag('cms_downloads/single-download.html')(get_download_from_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment