Kaydet (Commit) 1a9bd75b authored tarafından Lex Berezhny's avatar Lex Berezhny Kaydeden (comit) Tim Graham

Refs #27358 -- Fixed system check crash with an empty FileField.upload_to.

üst ddf169cd
......@@ -256,7 +256,7 @@ class FileField(Field):
return []
def _check_upload_to(self):
if isinstance(self.upload_to, six.string_types) and self.upload_to[0] == '/':
if isinstance(self.upload_to, six.string_types) and self.upload_to.startswith('/'):
return [
checks.Error(
"%s's 'upload_to' argument must be a relative path, not an "
......
......@@ -431,6 +431,12 @@ class DecimalFieldTests(SimpleTestCase):
@isolate_apps('invalid_models_tests')
class FileFieldTests(SimpleTestCase):
def test_valid_default_case(self):
class Model(models.Model):
field = models.FileField()
self.assertEqual(Model._meta.get_field('field').check(), [])
def test_valid_case(self):
class Model(models.Model):
field = models.FileField(upload_to='somewhere')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment