Loading django/db/models/fields/files.py +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ class FieldFile(File): return self.name == other.name return self.name == other def __ne__(self, other): return not self.__eq__(other) # 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. Loading tests/regressiontests/file_storage/models.py +16 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,18 @@ if Image: >>> p.mug_width 16 # Bug #9786: Ensure '==' and '!=' work correctly. >>> image_data = open(os.path.join(os.path.dirname(__file__), "test1.png"), 'rb').read() >>> p1 = Person(name="Bob") >>> p1.mugshot.save("mug", ContentFile(image_data)) >>> p2 = Person.objects.get(name="Joe") >>> p.mugshot == p2.mugshot True >>> p.mugshot != p2.mugshot False >>> p.mugshot != p1.mugshot True # Bug #8175: correctly delete files that have been removed off the file system. >>> import os >>> p2 = Person(name="Fred") Loading tests/regressiontests/file_storage/test1.png 0 → 100644 +480 B Loading image diff... Loading
django/db/models/fields/files.py +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ class FieldFile(File): return self.name == other.name return self.name == other def __ne__(self, other): return not self.__eq__(other) # 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. Loading
tests/regressiontests/file_storage/models.py +16 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,18 @@ if Image: >>> p.mug_width 16 # Bug #9786: Ensure '==' and '!=' work correctly. >>> image_data = open(os.path.join(os.path.dirname(__file__), "test1.png"), 'rb').read() >>> p1 = Person(name="Bob") >>> p1.mugshot.save("mug", ContentFile(image_data)) >>> p2 = Person.objects.get(name="Joe") >>> p.mugshot == p2.mugshot True >>> p.mugshot != p2.mugshot False >>> p.mugshot != p1.mugshot True # Bug #8175: correctly delete files that have been removed off the file system. >>> import os >>> p2 = Person(name="Fred") Loading