mysql - Working with primary key field in legacy database using Django -


i have create simple crud panel active mysql database. when try migrate application receive following error:

assertionerror: model can't have more 1 autofield

i've read following in django book, chapter 18:

each generated model has attribute every field, including id primary key fields. however, recall django automatically adds id primary key field if model doesn’t have primary key. thus, you’ll want remove lines this:

id = models.integerfield(primary_key=true) not these lines redundant, can cause problems if application adding new records these tables.

i have same scenario field:

id_call = models.bigintegerfield(primary_key=true) 

however, if follow above suggestion , remove line, original application (not django application) using table may not work because calling data table using id_call field.

how can resolve situation?

for me, changing models.autofield(unique=true) models.autofield(primary_key=true), while working wordpress database.

i had 4 of them in generated models.py python manage.py --database='olddb' inspectdb > models.py. here used 1 more db, olddb, if use default db can remove --database='olddb'.

i tried running python manage.py runserver. fixed each line things mentioned above.

reference:-

https://docs.djangoproject.com/en/1.8/topics/db/models/#automatic-primary-key-fields

https://docs.djangoproject.com/en/1.8/topics/db/multi-db/#


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -