Ticket #9076: model2.py

File model2.py, 1.1 KB (added by Leonidas, 11 years ago)

The model which shows this error too

Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4from django.db import models
5from django.conf import settings
6from django.utils.translation import get_language, gettext_lazy as _
7
8languages_available = settings.LANGUAGES
9
10class Message(models.Model):
11    """A message which is to translate"""
12    text = models.TextField(_('original message'), unique=True)
13
14    def __unicode__(self):
15        """A nice representation for the user"""
16        return self.text
17
18    def save(self, *args, **kwargs):
19        self.text = self.text.strip()
20        super(Message, self).save(*args, **kwargs)
21
22class Translation(models.Model):
23    """Translation"""
24    message = models.ForeignKey(Message)
25    language = models.CharField(_('language'), max_length=5,
26                        choices=settings.LANGUAGES)
27    translation = models.TextField(_('translation'))
28
29    def save(self, *args, **kwargs):
30        self.translation = self.translation.strip()
31        super(Translation, self).save(*args, **kwargs)
32
33    def __unicode__(self):
34        return u"%s: %s" % (self.language, self.translation)
Back to Top