The database configuration in the project is in bysms/settings.py
in , here
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
python manage.py migrate # Create table , Each with models.py and migrations Of app Will create a table
I use the navicat Connect to database
1. Create an application
2. stay models.py in utilize orm Create a table and add fields , for example 、
from django.db import models
class Customer(models.Model):
# Customer name
name = models.CharField(max_length=200)
# contact number
phonenumber = models.CharField(max_length=200)
# Address
address = models.CharField(max_length=200)
3. stay setting.py Lieutenant general app register , Make the project aware of app And pay attention to the addition, deletion, modification and query of its tables .
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Join the following line
'common.apps.CommonConfig',
]
4. Execute the command after adding
python manage.py makemigrations common # Generate the command to update the table
python manage.py migrate # Update table
be used for , You can modify the table
1. Create super admin
python manage.py createsuperuser
2. stay 127.0.0.1/admin You can operate the project's own table in
3. Add self created table Code can be found in admin Show
from django.contrib import admin
from .models import Customer
admin.site.register(Customer)
前言下面的這篇文章主要教大家如何搭建一個基於Transfor
Ubuntu下的Nginx+Uwsgi+DjangoProj
Record the process of your own