Skip to content

Instantly share code, notes, and snippets.

@scott-w
Created March 18, 2017 13:18
Show Gist options
  • Save scott-w/6285526a3c53f1d9d369f9e47b502703 to your computer and use it in GitHub Desktop.
Save scott-w/6285526a3c53f1d9d369f9e47b502703 to your computer and use it in GitHub Desktop.
Classes in Six
from __future__ import absolute_import, print_function, unicode_literals
from six import python_2_unicode_compatible
from django.db import models
@python_2_unicode_compatible
class MyModelClass(models.Model):
"""Python 2 and 3 compatible model.
"""
value_1 = models.IntegerField(default=0)
def __str__(self):
"""Replaces __unicode__ because of the above decorator
"""
return 'MyModelClass: {s.value_1}'.format(s=self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment