Starting from scratch-the problem of the Django database created before the site was built

Source: Internet
Author: User

A little bit familiar with Django inside the data operation, found that met a lot of problems.

Django's manipulation of the data is a code-style operation.

It's normal to start creating parameters for a table in models, like Username,password, and then use Makemigrations, migrations to create the fields. The fields I created also appear in the database. But when I add a field in the table to find that it is not updated in the database, this is very annoying ah ....

Baidu for a long time found that my project does not have migrations this package, this package is not Django itself created (I guess), but we need to create manually , this package is recorded in our data on the creation of various fields and delete. So I created this package and deleted all the tables I created in the database and recreated them (makemigrations, migrations). At the time of observation, the dataset field was created, and there were some records of database operations in the migrations I built. At this point, I re-add the deletion field in the models, and then create, this time the database can create or delete my models changes. That's probably it.

Starting from scratch-the problem of the Django database created before the site was built

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.