diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 22546c2..1d9fbe5 100644
a
|
b
|
def __init__(self, verbose_name=None, name=None, primary_key=False,
|
124 | 124 | self.error_messages = messages |
125 | 125 | |
126 | 126 | def __cmp__(self, other): |
127 | | # This is needed because bisect does not take a comparison function. |
128 | | return cmp(self.creation_counter, other.creation_counter) |
| 127 | if isinstance(other, Field): |
| 128 | # This is needed because bisect does not take a comparison function. |
| 129 | return cmp(self.creation_counter, other.creation_counter) |
| 130 | return NotImplemented |
129 | 131 | |
130 | 132 | def __deepcopy__(self, memodict): |
131 | 133 | # We don't have to deepcopy very much here, since most things are not |
diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py
index 30ed3de..658c37c 100644
a
|
b
|
|
3 | 3 | from datetime import datetime |
4 | 4 | |
5 | 5 | from django.core.exceptions import ObjectDoesNotExist |
6 | | from django.db.models.fields import FieldDoesNotExist |
| 6 | from django.db.models.fields import Field, FieldDoesNotExist |
7 | 7 | from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature |
8 | 8 | |
9 | 9 | from .models import Article |
… |
… |
def test_hash_function(self):
|
508 | 508 | |
509 | 509 | s = set([a10, a11, a12]) |
510 | 510 | self.assertTrue(Article.objects.get(headline='Article 11') in s) |
| 511 | |
| 512 | def test_field_comparison(self): |
| 513 | # Field instances have a cmp function to allow the ORM to determine |
| 514 | # in which order fields are defined on a model. Plus, field should |
| 515 | # be comparable to non Field objects also. Make sure it works correctly |
| 516 | # since it overrides __cmp__ method. |
| 517 | f1 = Field() |
| 518 | f2 = Field(auto_created=True) |
| 519 | f3 = Field() |
| 520 | self.assertTrue(f2 < f1) |
| 521 | self.assertTrue(f1 < f3) |
| 522 | self.assertFalse(f1 == None) |
| 523 | self.assertFalse(f2 in (None, 1, '')) |
511 | 524 | |
512 | 525 | def test_extra_method_select_argument_with_dashes_and_values(self): |
513 | 526 | # The 'select' argument to extra() supports names with dashes in |