I have written this model.
class Course(TranslatableModel):
translations = TranslatedFields(
title = models.CharField(max_length=200),
overview = models.TextField(),
slug = models.SlugField(max_length=200, unique=True))
owner = models.ForeignKey(User, related_name='courses_created')
subject = models.ForeignKey(Subject, related_name='courses')
created = models.DateTimeField(auto_now_add=True)
order = OrderField(blank=True, for_fields=['title'])
class Meta:
ordering = ('order',)
def __unicode__(self):
return self.title
AND ALSO THIS mixin class
class OwnerCourseEditMixin(OwnerCourseMixin, OwnerEditMixin):
fields = ['subject', 'title', 'slug', 'overview']
success_url = reverse_lazy('manage_course_list')
template_name = 'courses/manage/course/form.html'
The "fields = ['subject', 'title', 'slug', 'overview']" line is causing the error
Exception Type: FieldError Exception Value: Unknown field(s) (overview, slug, title) specified for Course
How do I refer to the translated fields? If I remove 'title', 'slug', 'overview' from the fields list it works.
SOLVED
When translated fields are created django-parler creates a model for each translatable model. So, the model to work with is not the Course model itself, but the generated CourseTranslation model.
I still needed to add the subject field to the Translation model, then all worked.