Django operation model, error: Attributeerror: ' Programmingerror ' object has no attribute ' __traceback__ '

Source: Internet
Author: User

Cause: The model (that is, Class) that is configured under the models.py configuration under the Django project is not created as a corresponding table.

What's going on here?

First, the models.py inside the model is created as the corresponding database table execution command (DOS command) is: manage.py syncdb.

But when I execute the command on my own computer, it is displayed. Unknown command:syncdb. Execute, manage.py help did not find this sub-command. Finally, the online search found that the command has been canceled in the Django1.9. And StackOverflow inside said can be replaced with migrate command. But the previous execution of manage.py migrate did not help me create the model corresponding table in the database.

Recommendations: 1. Django changed to a low-point version.

2.ProgrammingError or Operationalerror is a MySQL (database) operation error. If you report such a mistake in Django. The former should be the action table when the corresponding table was not found. The latter is generally a problem with the created table. Of course, it should be no problem to create a table from SYNCDB. But if you create it yourself. There may be a problem. For example, the name of the table is wrong (the model name may be uppercase, but the table names are converted to lowercase), or a default ID is not added as the primary key. Because DJangoa model that does not explicitly define a primary key variable will be assigned aIDproperty.If you want to have more control of the primary key, just specify it on a variable on the modelprimary_key=trueThis variable will take the place ofID (At thisIDwill be ignored .).

Django operation model, error: Attributeerror: ' Programmingerror ' object has no attribute ' __traceback__ '

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.