Django Parler Models + Prepopulated Fields issue

I am trying to use django-parler to translate my models. I am using TranslateableModel and TranslatedFields. This is what my class looks like:

class Category(TranslatableModel):
   translations = TranslatedFields(
       category_name = models.CharField(_('name'), max_length=50, unique=True),
       description = models.TextField(_('description'), max_length=255, blank=True),
   )
   slug = models.SlugField(max_length=100, unique=True)
   image = models.ImageField(_('image'), default='default_category_image.jpg', upload_to='category_photos')

But I get this error:

**django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS: <class 'categories.admin.CategoryAdmin'>: (admin.E030) The value of 'prepopulated_fields["slug"][0]' refers to 'category_name', which is not a field of 'categories.Category'.**

The error is caused because in my model's admin class slug is a prepopulated field:

class CategoryAdmin(admin.ModelAdmin):
   prepopulated_fields = {'slug': ('category_name', )}

If I put the slug field within the TranslatedFields I get the errors:

<class 'categories.admin.CategoryAdmin'>: (admin.E027) The value of 'prepopulated_fields' refers to 'slug', which is not a field of 'categories.Category'. <class 'categories.admin.CategoryAdmin'>: (admin.E030) The value of 'prepopulated_fields["slug"][0]' refers to 'category_name', which is not a field of 'categories.Category'.

How would I fix this error while still having a slug in my model?

Back to Top