shangxiao / django-db-constraints

Add database table-level constraints to your Django model's Meta
MIT License
44 stars 4 forks source link

python2 support #2

Open rrauenza opened 6 years ago

rrauenza commented 6 years ago

Would you be open to supporting python 2.7?

It looks like the only issues are the calls to super(). Python2 requires the (current classname, self) to be passed, but you can just 'from builtins import (super,)' at the top.

The other issue is dictionary keys are lists in python2 so you can't do set operations on them -- You can fix this by changing the code to:

  to_constraints = set(getattr(to_model._meta, self.option_name, {}).keys())
  from_constraints = set(getattr(from_model._meta, self.option_name, {}).keys())
rrauenza commented 6 years ago

See Pull Request https://github.com/rapilabs/django-db-constraints/pull/3