Django-3. Add a custom data source and save the model configuration file

1. Configure the top-level setting.py file

DATABASES = {
    
    
    'default': {
    
    
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    },
    "sale": {
    
    
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'sale',
        'HOST': 'test-renrenche1.db.58dns.org',
        'PORT': 3306,
        'USER': 'work',
        'PASSWORD': 'RqQb5YFfOH5ojZ16'
    }
}

2. Export the table corresponding to the library to generate the model to a file

python manage.py inspectdb --database sale customer_info customer_cycle_info > models.py

Guess you like

Origin blog.csdn.net/u013553309/article/details/128777513