39 | | fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] |
40 | | fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter)) |
| 39 | if 'base_fields' in attrs: |
| 40 | fields = attrs['base_fields'] |
| 41 | else: |
| 42 | fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] |
| 43 | fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter)) |
42 | | # If this class is subclassing another Form, add that Form's fields. |
43 | | # Note that we loop over the bases in *reverse*. This is necessary in |
44 | | # order to preserve the correct order of fields. |
45 | | for base in bases[::-1]: |
46 | | if hasattr(base, 'base_fields'): |
47 | | fields = base.base_fields.items() + fields |
| 45 | # If this class is subclassing another Form, add that Form's fields. |
| 46 | # Note that we loop over the bases in *reverse*. This is necessary in |
| 47 | # order to preserve the correct order of fields. |
| 48 | for base in bases[::-1]: |
| 49 | if hasattr(base, 'base_fields'): |
| 50 | fields = base.base_fields.items() + fields |