Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #9508 -- Added an appropriate FileField.__hash__ implementation.

Required because we declare a custom __eq__ method.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent d01c17e commit 6e415a5f90dc89e83b0e926f973c629b56642a9c @malcolmt malcolmt committed
4 django/db/models/fields/
@@ -34,6 +34,10 @@ def __eq__(self, other):
def __ne__(self, other):
return not self.__eq__(other)
+ def __hash__(self):
+ # Required because we defined a custom __eq__.
+ return hash(
# The standard File contains most of the necessary properties, but
# FieldFiles can be instantiated without a name, so that needs to
# be checked for here.
5 tests/regressiontests/file_storage/
@@ -54,6 +54,11 @@ class Person(models.Model):
>>> p.mugshot != p1.mugshot
+Bug #9508: Similarly to the previous test, make sure hash() works as expected
+(equal items must hash to the same value).
+>>> hash(p.mugshot) == hash(p2.mugshot)
# Bug #8175: correctly delete files that have been removed off the file system.
>>> import os
>>> p2 = Person(name="Fred")

0 comments on commit 6e415a5

Please sign in to comment.
Something went wrong with that request. Please try again.