python - django models.py增加后MySQL数据库中并没有生成相应的表
PHPz
PHPz 2017-04-18 09:34:32
0
2
440
PHPz
PHPz

学习是最好的投资!

reply all(2)
大家讲道理

First you need to check your settings.py configuration, where:

# settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': '/path/to/my.cnf',
        },
    }
}
# my.cnf
[client]
database = NAME
user = USER
password = PASSWORD
default-character-set = utf8

If your configuration is not mysql, Django will use sqlite by default, and when you run the above command, a sqlite database file will be generated in the project directory.

If the configuration is correct and it is mysql, after running your script, the corresponding table will be generated in the corresponding mysql database. The default table name is <app_name>_<model_name>

If you still have questions, please refer to:
https://docs.djangoproject.co...

左手右手慢动作

There are several situations when this situation occurs:
1. The db configuration in django settings.py is incorrect
2. There may be a problem with the db model writing
There may be other situations

A little suggestion: Show the results of executing the python manage.py migrate command, so that others can help you quickly analyze, locate and solve the problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template