Skip to content

Commit

Permalink
Support Py3's new metaclass syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
karanlyons committed Sep 10, 2013
1 parent 79a3e90 commit 712ed42
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions save_the_change/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from copy import copy

from django.db import models
from django.utils.six import iteritems
from django.utils import six


__all__ = ('SaveTheChange', 'TrackChanges')
Expand Down Expand Up @@ -115,7 +115,7 @@ def save(self, *args, **kwargs):
"""

if self.pk and hasattr(self, '_changed_fields') and 'update_fields' not in kwargs and not kwargs.get('force_insert', False):
kwargs['update_fields'] = [key for key, value in iteritems(self._changed_fields) if hasattr(self, key)]
kwargs['update_fields'] = [key for key, value in six.iteritems(self._changed_fields) if hasattr(self, key)]

super(SaveTheChange, self).save(*args, **kwargs)

Expand Down Expand Up @@ -202,7 +202,6 @@ def __new__(cls, name, bases, attrs):
meta = getattr(base, '_meta')

break

if meta and hasattr(meta, 'update_together'):
update_together = getattr(meta, 'update_together')
delattr(meta, 'update_together')
Expand All @@ -224,9 +223,7 @@ def __new__(cls, name, bases, attrs):
return new_class


class UpdateTogetherModel(BaseChangeTracker, models.Model):
__metaclass__ = UpdateTogetherMeta

class UpdateTogetherModel(BaseChangeTracker, models.Model, six.with_metaclass(UpdateTogetherMeta)):
def save(self, *args, **kwargs):
if 'update_fields' in kwargs:
update_fields = set()
Expand Down

0 comments on commit 712ed42

Please sign in to comment.