Browse files

[1.0.X] Fixed #10347 -- Fixed incorrect AttributeError raised when at…

…tempting to access a FileField without an instance. Thanks for the report and patch dc.

[9902] from trunk.  Also updated svnmerge metadata; all trunk changesets have either been merged or blocked.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
kmtracey committed Feb 24, 2009
1 parent 3550aa2 commit c9a63889f6d51159e0c029d6210f50b44e247659
Showing with 7 additions and 1 deletion.
  1. +1 −1 django/db/models/fields/
  2. +6 −0 tests/modeltests/files/
@@ -118,7 +118,7 @@ def __init__(self, field):
def __get__(self, instance=None, owner=None):
if instance is None:
- raise AttributeError, "%s can only be accessed from %s instances." % (
+ raise AttributeError("The '%s' attribute can only be accessed from %s instances." % (, owner.__name__))
file = instance.__dict__[]
if not isinstance(file, FieldFile):
# Create a new instance of FieldFile, based on a given file name
@@ -34,6 +34,12 @@ def random_upload_to(self, filename):
default = models.FileField(storage=temp_storage, upload_to='tests', default='tests/default.txt')
__test__ = {'API_TESTS':"""
+# Attempting to access a FileField from the class raises a descriptive error
+>>> Storage.normal
+Traceback (most recent call last):
+AttributeError: The 'normal' attribute can only be accessed from Storage instances.
# An object without a file has limited functionality.
>>> obj1 = Storage()

0 comments on commit c9a6388

Please sign in to comment.