mirror of https://github.com/django/django.git
Refs #27358 -- Fixed system check crash with an empty FileField.upload_to.
This commit is contained in:
parent
ddf169cdac
commit
1a9bd75bfa
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue