Repository: django-cms/django-filer

Issue:
 MultiStorageFileField can handle only File object
Getting this warning all of a sudden

```
filer/fields/multistorage_file.py:106: SyntaxWarning: MultiStorageFileField can handle only File objects;<function generate_filename_multistorage at 0x10288fde8> passed
  "%s passed" % upload_to, SyntaxWarning)
```

On top of the  "SyntaxWarning: FilerImageField can only be a ForeignKey to Image; filer.Image passed" warning which I think already has a fix.

This is using filer 0.98, django 1.7.2



Discussion:
Same here:

```
/home/vagrant/.virtualenvs/myproject/lib/python3.4/site-packages/filer/fields/multistorage_file.py:106: SyntaxWarning: MultiStorageFileField can handle only File objects;<function generate_filename_multistorage at 0xb6c03c8c> passed
  "%s passed" % upload_to, SyntaxWarning)
```

Also on django 1.7.2, filer 0.9.8


Resolving patch:
diff --git a/filer/fields/file.py b/filer/fields/file.py
--- a/filer/fields/file.py
+++ b/filer/fields/file.py
@@ -113,14 +113,19 @@ class FilerFileField(models.ForeignKey):
 
     def __init__(self, **kwargs):
         # We hard-code the `to` argument for ForeignKey.__init__
-        if "to" in kwargs.keys():
+        if "to" in kwargs.keys():  # pragma: no cover
             old_to = kwargs.pop("to")
-            msg = "%s can only be a ForeignKey to %s; %s passed" % (
-                self.__class__.__name__, self.default_model_class.__name__, old_to
+            dfl = "%s.%s" % (
+                    self.default_model_class._meta.app_label,
+                    self.default_model_class.__name__
             )
-            warnings.warn(msg, SyntaxWarning)
+            if old_to != dfl:
+                msg = "%s can only be a ForeignKey to %s; %s passed" % (
+                    self.__class__.__name__, self.default_model_class.__name__, old_to
+                )
+                warnings.warn(msg, SyntaxWarning)
         kwargs['to'] = self.default_model_class
-        return super(FilerFileField, self).__init__(**kwargs)
+        super(FilerFileField, self).__init__(**kwargs)
 
     def formfield(self, **kwargs):
         # This is a fairly standard way to set up some defaults
diff --git a/filer/fields/folder.py b/filer/fields/folder.py
--- a/filer/fields/folder.py
+++ b/filer/fields/folder.py
@@ -18,6 +18,7 @@
 class AdminFolderWidget(ForeignKeyRawIdWidget):
     choices = None
     input_type = 'hidden'
+    is_hidden = False
 
     def render(self, name, value, attrs=None):
         obj = self.obj_for_value(value)
@@ -107,14 +108,19 @@ class FilerFolderField(models.ForeignKey):
 
     def __init__(self, **kwargs):
         # We hard-code the `to` argument for ForeignKey.__init__
-        if "to" in kwargs.keys():
+        if "to" in kwargs.keys():  # pragma: no cover
             old_to = kwargs.pop("to")
-            msg = "%s can only be a ForeignKey to %s; %s passed" % (
-                self.__class__.__name__, self.default_model_class.__name__, old_to
+            dfl = "%s.%s" % (
+                    self.default_model_class._meta.app_label,
+                    self.default_model_class.__name__
             )
-            warnings.warn(msg, SyntaxWarning)
+            if old_to != dfl:
+                msg = "%s can only be a ForeignKey to %s; %s passed" % (
+                    self.__class__.__name__, self.default_model_class.__name__, old_to
+                )
+                warnings.warn(msg, SyntaxWarning)
         kwargs['to'] = self.default_model_class
-        return super(FilerFolderField, self).__init__(**kwargs)
+        super(FilerFolderField, self).__init__(**kwargs)
 
     def formfield(self, **kwargs):
         # This is a fairly standard way to set up some defaults
diff --git a/filer/fields/multistorage_file.py b/filer/fields/multistorage_file.py
--- a/filer/fields/multistorage_file.py
+++ b/filer/fields/multistorage_file.py
@@ -100,10 +100,11 @@ class MultiStorageFileField(easy_thumbnails_fields.ThumbnailerField):
 
     def __init__(self, verbose_name=None, name=None,
                  storages=None, thumbnail_storages=None, thumbnail_options=None, **kwargs):
-        if 'upload_to' in kwargs:
+        if 'upload_to' in kwargs:  # pragma: no cover
             upload_to = kwargs.pop("upload_to")
-            warnings.warn("MultiStorageFileField can handle only File objects;"
-                          "%s passed" % upload_to, SyntaxWarning)
+            if upload_to != generate_filename_multistorage:
+                warnings.warn("MultiStorageFileField can handle only File objects;"
+                              "%s passed" % upload_to, SyntaxWarning)
         self.storages = storages or STORAGES
         self.thumbnail_storages = thumbnail_storages or THUMBNAIL_STORAGES
         self.thumbnail_options = thumbnail_options or THUMBNAIL_OPTIONS


Test patch: