Django zip longest templatetags to handle more than 3 arguments.
Django zip longest templatetags to handle more than 3 arguments.
- django
- templatetags
- zip
Django zip longest templatetags to handle more than 3 arguments.
Sometimes we need to build a ChoiceField from data in a Model or more than just one model via fk's but the ModelChoiceField is not *that* flexible. So, in order to obtain a list of tuples with pk and a descriptive text for the choices parameter of the ChoiceField use this little function.
Django Filebrowser (http://code.google.com/p/django-filebrowser/) provides a signal called filebrowser_post_upload. Adding this method to a model that has a FileBrowse field will cause uploaded .zip files to be detected and unzipped on the server in place, then deleted (leaving their folder behind). It will also delete the garbage __MACOSX folder created by Mac zip files. This is probably not safe to do for publicly uploaded files. The use case here was to allow journalists to upload entire SoundSlides projects into a custom CMS.
3 snippets posted so far.