Created
March 18, 2017 13:18
-
-
Save scott-w/6285526a3c53f1d9d369f9e47b502703 to your computer and use it in GitHub Desktop.
Classes in Six
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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