Django uses INSPECTDB to connect to existing MySQL database problems

Source: Internet
Author: User

./manage.py Inspectdb encountered the problem:
Unable to find test_db.id because the original database was not found PRIMARY_KEY,INSPECTDB automatically model creates a field with the name test_db.id in it.
The workaround is to model.py Select a field in, using Primary_key, such as:

Class test_db (models. Model)    start_id = models. Charfield (Unique=true, max_length=32, Primary_key=true)

Reference:

  1. StackOverflow
  2. Django:auto primary key fields

Django uses INSPECTDB to connect to existing MySQL database problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.