Make FileFile.get_file_name cope with sitiuations where is not set. #84

merged 1 commit into from Jan 15, 2013


None yet

2 participants


Issue reproduced with:

Steps to reproduce:
1. Upload a file to filer (foo_file)
2. In any page add a filer file plugin that points to the file you've just added


  • plugin successfully added

Actual :
AttributeError at /admin/cms/page/2/edit-plugin/8/
'FilerFile' object has no attribute 'name'

File "/home/kux/workspace/src/other/django/django/core/handlers/" in get_response

  1. response = callback(request, callback_args, *callback_kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapped_view
  2. response = view_func(request, args, *kwargs) File "/home/kux/workspace/src/other/django/django/views/decorators/" in _wrapped_view_func
  3. response = view_func(request, args, *kwargs) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in inner
  4. return view(request, args, *kwargs) File "/home/kux/workspace/envs/contribute/local/lib/python2.7/site-packages/reversion/" in do_revision_context
  5. return func(args, *kwargs) File "/home/kux/workspace/src/other/django-cms/cms/admin/" in edit_plugin
  6. response = plugin_admin.add_view(request) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapper
  7. return bound_func(args, *kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapped_view
  8. response = view_func(request, args, *kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in bound_func
  9. return func(self, args2, *kwargs2) File "/home/kux/workspace/src/other/django/django/db/" in inner
  10. return func(args, *kwargs) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in add_view
  11. return self.response_add(request, new_object) File "/home/kux/workspace/src/other/django-cms/cms/" in response_add
  12. return super(CMSPluginBase, self).response_add(request, obj) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in response_add
  13. msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)} File "/home/kux/workspace/src/other/django/django/utils/" in force_unicode
  14. s = unicode(s) File "/home/kux/workspace/src/other/cmsplugin-filer/cmsplugin_filer_file/" in unicode
  15. return self.get_file_name() File "/home/kux/workspace/src/other/cmsplugin-filer/cmsplugin_filer_file/" in get_file_name
  16. return

Exception Type: AttributeError at /admin/cms/page/2/edit-plugin/8/
Exception Value: 'FilerFile' object has no attribute 'name'

@kux kux Make FileFile.get_file_name cope with sitiuations where self.file.nam…
…e is not set.

This is quite an often situation: an user uploads a file to filer it doesn't set the name explicitly, therefore the original_filename is used.

The implementation is the same as filer.models.filemodels.File.unicode

An alternative would be to just have:

def get_file_name(self):
    return unicode(self.file)
@stefanfoulis stefanfoulis merged commit e23b33c into divio:develop Jan 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment