6👍
class A(models.Model):
#some fields here
x = models.CharField()
class Meta:
abstract = True
class B(A):
pass
A
will be an abstract class, and you cannot use this class alone. But as I understood, you want to have two real classes A
and B
. In this case you need a third (abstract) class C
. So they will inherit the fields from the abstract one and add extra fields to them.
For example:
suppose that abstract is C
class C(models.Model):
# the common fields
class Meta:
abstract = True
class A(C):
#extra fields if you need or pass
class B(C):
#extra fields if you need or pass
1👍
Make a
an abstract model:
class a(models.Model):
class Meta:
abstract = True
x = models.CharField()
Also note that class names should be uppercase, so it should be A
and B
, but x
is correct.
👤agf
- [Django]-Forcing Django to use INNER JOIN instead of LEFT OUTER JOIN
- [Django]-Pip install confluent-kafka gives error in mac
Source:stackexchange.com