Skip to content

Instantly share code, notes, and snippets.

@sjl
Created June 1, 2011 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjl/1003164 to your computer and use it in GitHub Desktop.
Save sjl/1003164 to your computer and use it in GitHub Desktop.
Allow empty values in FileBrowseField's with blank=True, null=False
diff --git a/filebrowser/fields.py b/filebrowser/fields.py
--- a/filebrowser/fields.py
+++ b/filebrowser/fields.py
@@ -96,10 +96,12 @@
return FileObject(url_to_path(value))
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
+ if not value:
+ return value
return value.url_save
def formfield(self, **kwargs):
attrs = {}
attrs["directory"] = self.directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment