string representation of translated models

22 views
Skip to first unread message

Matthias Verstraete

unread,
May 4, 2017, 2:51:19 PM5/4/17
to django-modeltranslation
I just applied the model-translation module in my project. However, before, the admin interface showed the result of __str__ in the admin interface.
Now, all my objects just appear as "()".
Does anybody have an idea why this is happening?
My model looks like this:

class Post(models.Model):
    title = models.CharField(max_length=100)
    message = models.TextField()
    date = models.DateTimeField('date published')

    def __str__(self):
        return self.title + " (" + self.message[0:50] + ")"

The rest is just the standard code from the model-translation documentation.

Thanks.
Reply all
Reply to author
Forward
0 new messages