python - Django multiple inheritance E005 -


in django docs stated in order use multiple inheritance 1 either has to

use explicit autofield in base models

or

use common ancestor hold autofield

in case have common ancestor in following setup (as taken docs):

class piece(models.model):     piece_id = models.autofield(primary_key=true)  class article(piece):     pass  class book(piece):     pass  class bookreview(book, article):     pass 

unfortunately results in following error:

$ python manage.py check systemcheckerror: system check identified issues:  errors: testapp.bookreview: (models.e005) field 'piece_ptr' parent model 'testapp.book' clashes field 'piece_ptr' parent model 'testapp.article'.  system check identified 1 issue (0 silenced). 

any way around this?


edit: django version 1.8.2

i found out can name link parent:

class piece(models.model):     pass  class article(piece):     article_to_piece = models.onetoonefield(piece, parent_link=true)  class book(piece):     book_to_piece = models.onetoonefield(piece, parent_link=true)  class bookreview(book, article):     pass 

i'm still curious other solutions though!


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -