Why can't I create an instance of a class inside an abstract class

282 views Asked by At

I am using django-parler for language translation in an abstract class model but I get this error: raise TypeError("Can't create TranslatedFieldsModel for abstract class {0}".format(shared_model.__name__)) TypeError: Can't create TranslatedFieldsModel for abstract class MyClass

I want to know why I can't create an instance of this TranslatedFieldsModel in an abstract class. Are there some instance or some type of classes/objects that cannot be instantiated in an abstract class? I really don't know much about abstract classes, please explain to me why this TranslatedFieldsModel cannot be created and how to go about it

Here is a code example:

from django.db import models
from parler.models import TranslatableModel, TranslatedFields

class MyClass(TranslatableModel):
    translations = TranslatedFields(
        title = models.CharField(max_length=500)
    )
    class Meta:
        abstract = True

when I run my app I get the error above: My question now is why is this so that I cannot create this instance in my abstract class? How can I make this work?

0

There are 0 answers