From 4c14e51225e284c5b81d53e7f6a5cd0f46ec4d05 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 23 Sep 2014 16:45:56 +0200 Subject: [PATCH 1/1] Python3 compatible --- apps/quiz/models.py | 11 +++++++---- koedquiz/settings.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/quiz/models.py b/apps/quiz/models.py index b5e588d..74142da 100644 --- a/apps/quiz/models.py +++ b/apps/quiz/models.py @@ -4,6 +4,7 @@ # from django.db import models from django.contrib.sites.models import Site +from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from django.conf import settings @@ -36,6 +37,7 @@ class Quiz(Site): return self.get_absolute_url() +@python_2_unicode_compatible class Result(models.Model): quiz = models.ForeignKey(Quiz) slug = models.SlugField(db_index=True) @@ -47,7 +49,7 @@ class Result(models.Model): verbose_name_plural = _('results') ordering = ['quiz', 'title'] - def __unicode__(self): + def __str__(self): return self.title @models.permalink @@ -55,6 +57,7 @@ class Result(models.Model): return ('quiz_result', [self.slug]) +@python_2_unicode_compatible class Question(models.Model): quiz = models.ForeignKey(Quiz) slug = models.SlugField(db_index=True) @@ -69,7 +72,7 @@ class Question(models.Model): ordering = ['quiz', 'ordering'] unique_together = [['quiz', 'slug'], ['quiz', 'ordering']] - def __unicode__(self): + def __str__(self): return self.title @models.permalink @@ -84,7 +87,7 @@ class Question(models.Model): return self.quiz.where_to() - +@python_2_unicode_compatible class Answer(models.Model): title = models.CharField(max_length=255) question = models.ForeignKey(Question) @@ -98,7 +101,7 @@ class Answer(models.Model): verbose_name_plural = _('answers') ordering = ['question', 'ordering'] - def __unicode__(self): + def __str__(self): return self.title def where_to(self): diff --git a/koedquiz/settings.py b/koedquiz/settings.py index d4755da..13ce2ef 100644 --- a/koedquiz/settings.py +++ b/koedquiz/settings.py @@ -151,6 +151,6 @@ LOGGING = { # Load localsettings, if they exist try: - from localsettings import * + from .localsettings import * except ImportError: pass -- 2.20.1