一、创建单表
models.py
#!/usr/bin/env python # -*- coding:utf-8 -*- from __future__ import unicode_literals from django.db import models class UserInfo(models.Model): USER_TYPE_LIST = ( (1,"F"), (2,"M"), ) name = models.CharField(max_length=32,primary_key=True) user_type = models.IntegerField(choices=USER_TYPE_LIST,default=1) ctime = models.DateTimeField(auto_now=True) uptime = models.DateTimeField(auto_now_add=True) email = models.EmailField(max_length=32,null=True) email_default = models.EmailField(max_length=32,default="[email protected]") ip = models.GenericIPAddressField(protocol=‘both‘,null=True,blank=True) img = models.ImageField(null=True,blank=True,upload_to="upload") def __unicode__(self): return self.name
创建数据库单表效果如下:
创建用户:
再次查看表数据:
时间: 2024-12-09 18:38:05