django-ccfiletypes

Django templatefilters for displaying info about files
Download

django-ccfiletypes Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • designcc
  • Publisher web site:
  • https://github.com/designcc

django-ccfiletypes Tags


django-ccfiletypes Description

django-ccfiletypes is a small collection of template filters for Django that make the displaying of information from FileFields a little easier.It's useful for displaying an icon for a certain filetype or getting just the filename without the full path.InstallationInstall via pip:pip install django-ccfiletypesOnce installed you will need to add it to your settings.INSTALLED_APPS:INSTALLED_APPS = ( ... 'ccfiletypes',)Finally you will need to run the collectstatic command to get the icon files into your static root:python manage.py collectstaticUsageInclude the tags in your template:{% load ccfiletype_tags %}Now you have access to two filtersiconicon will return an icon for the filetype based on it's extention:{{object.filefield.path|icon:"size"}}It can be called with an argument for size which can be small, medium, large or xlarge. If no argument is supplied then small will be the default.The returned string from the icon filter is formed by using the value from settings.STATIC_URL.namename will return only the filename from a path:{{objects.filefield.path|name}}Full ExampleA common usage for these filters would be for something like this:< img src="{{object.filefield.path|icon}}" alt="{{object.filefield.path|name}}" >AttributionThe icons in this package come from the Free File Icons project by Teambox and a copy of the license can be found the ccfiletypes/static/ccfiletypes directory.Product's homepage


django-ccfiletypes Related Software