Skip to content

Commit

Permalink
Make example models work with python 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jieter committed Jan 25, 2018
1 parent 0ec5b65 commit 7743708
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ example:
shell:
cd example && PYTHONPATH=.. ./manage.py shell_plus

notebook:
cd example && PYTHONPATH=.. ./manage.py shell_plus --notebook

isort:
isort --recursive --diff --check modeltrans tests test_migrations example

Expand Down
8 changes: 5 additions & 3 deletions example/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from __future__ import unicode_literals

from django.db import models

from django.utils.encoding import python_2_unicode_compatible
from modeltrans.fields import TranslationField


@python_2_unicode_compatible
class Category(models.Model):
name = models.CharField(max_length=255)

Expand All @@ -14,10 +15,11 @@ class Category(models.Model):
class Meta:
verbose_name_plural = 'categories'

def __unicode__(self):
def __str__(self):
return self.name_i18n


@python_2_unicode_compatible
class Blog(models.Model):
title = models.CharField(max_length=255)
body = models.TextField(null=True, blank=True)
Expand All @@ -26,5 +28,5 @@ class Blog(models.Model):

i18n = TranslationField(fields=('title', 'body', ))

def __unicode__(self):
def __str__(self):
return self.title_i18n

0 comments on commit 7743708

Please sign in to comment.