Skip to content

Instantly share code, notes, and snippets.

@alexkahn
Created September 12, 2015 13:35
Show Gist options
  • Save alexkahn/3bb3261cd053975e4063 to your computer and use it in GitHub Desktop.
Save alexkahn/3bb3261cd053975e4063 to your computer and use it in GitHub Desktop.
Stuff for every Django file in Python 2
"""
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