This currently fails on python 3, maybe try something like this instead...

fields = [f.name for f in sorted(opts.fields + opts.many_to_many) if not isinstance(f, models.AutoField)]