Created
September 12, 2015 13:35
-
-
Save alexkahn/3bb3261cd053975e4063 to your computer and use it in GitHub Desktop.
Stuff for every Django file in Python 2
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
""" | |
This goes at the top of every file. | |
""" | |
# -*- coding: utf-8 -*- | |
""" | |
Python 3 has it SOoOo easy... | |
""" | |
from __future__ import unicode_literals | |
""" | |
Use this to decorate classes | |
""" | |
from django.utils.encoding import python_2_unicode_compatible | |
@python_2_unicode_compatible | |
class Epic(models.Model): | |
""" | |
WHAT?!? The __str___ method in Python 2 that makes future python 3 | |
upgrades possible!??!11! | |
""" | |
data = models.CharField(max_length=3) | |
def __str__(self): | |
return self.data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment