4👍
✅
the problem is because the primary field for both the models are id, and a table cannot have 2 columns based on same name, do this and it will solve your error
class Article(Piece):
id = models.AutoField(primary_key=True)
name= models.CharField(max_length=100)
class Book(Piece):
book_id = models.AutoField(primary_key=True)
book_name= models.CharField(max_length=100)
0👍
You should try calling init on subclasses, like:
class Monday(Book, Article):
id = models.AutoField(primary_key=True)
name= models.CharField(max_length=100)
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class OtherDay(Book, Article):
book_id = models.AutoField(primary_key=True)
book_name= models.CharField(max_length=100)
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
This is because, as a Python class, the super() method will call the superclasses definition only one time, while the simple inheritance would call ini() for each superclass.
- [Django]-Django rest_framework, disable authentication and permission in specific method
- [Django]-Django transaction using multi-db
- [Django]-Django Broken Pipe Message
Source:stackexchange.com