django中setting配置数据库连接:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', #数据库引擎
'NAME': 'logined', #使用的数据库名
'USER': 'root', #数据库用户名
'PASSWORD': '369369',
'PORT': '3306', #端口
'POST': '127.0.0.1', #本机IP
}
}
django的models.py中配置:
from django.db import models
# Create your models here.
class User(models.Model):
gender = (
('male', "男"),
('female', "女"),
)
name = models.CharField(max_length=128, unique=True)
password = models.CharField(max_length=256)
email = models.EmailField(unique=True)
sex = models.CharField(max_length=32, choices=gender, default="男")
c_time = models.DateTimeField(auto_now_add