博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
django项目基础
阅读量:5977 次
发布时间:2019-06-20

本文共 3511 字,大约阅读时间需要 11 分钟。

 

D:\>django-admin startproject GodWork1

D:\>cd GodWork1

D:\GodWork1>python manage.py startapp User

D:\GodWork1>python manage.py startapp Log

D:\GodWork1>python manage.py startapp Api

D:\GodWork1>python manage.py startapp Service

在User 的app下进行模型的定义

class User(models.Model):

  username=models.CharField(max_length=32,verbose_name="用户名")
  password=models.CharField(max_length=32,verbose_name="密码")
  email=models.EmailField(verbose_name="邮箱")
  phone=models.CharField(max_length=28,verbose_name="用户手机",blank=True,null=True)
  photo=models.ImageField(upload_to="image/userPhoto",verbose_name='用户头像',blank=True,null=True)

class Group(models.Model):

  name=models.CharField(max_length=32,verbose_name='组名称')

class Method(models.Model):

  name=models.CharField(max_length=32,verbose_name="权限名称")

在Log 的app下进行模型的定义

class Log(models.Model):

  user=models.CharField(max_length=32,verbose_name="用户名称")
  time=models.DateTimeField(verbose_name="日志时间")
  operation=models.CharField(max_length=128,verbose_name="操作")
  level=models.IntegerField(verbose_name="日志等级")
  types=models.CharField(max_length=16,verbose_name="日志类型")

 

在Service 的app下进行模型的定义

class Service(models.Model):

  host=models.CharField(max_length=32,verbose_name="主机名称")
  ip=models.CharField(max_length=32,verbose_name="主机IP")
  mac=models.CharField(max_length=32,verbose_name="mac")
  cpu=models.CharField(max_length=32,verbose_name="cpu")
  mem=models.CharField(max_length=32,verbose_name="内存")
  disk=models.CharField(max_length=32,verbose_name="磁盘")
  system=models.CharField(max_length=32,verbose_name="系统")
  model=models.CharField(max_length=32,verbose_name="服务器型号")

 

D:\GodWork1>python manage.py check

System check identified no issues (0 silenced).

D:\GodWork1>

D:\GodWork1>
D:\GodWork1>
D:\GodWork1>python manage.py makemigrations
Migrations for 'Service':
0001_initial.py:
- Create model Service
Migrations for 'Log':
0001_initial.py:
- Create model Log
Migrations for 'User':
0001_initial.py:
- Create model Group
- Create model Method
- Create model User

D:\GodWork1>python manage.py syncdb

C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages
django\core\management\commands\syncdb.py:24: RemovedInDjango19Warning: The syn
db command will be removed in Django 1.9
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDj
ngo19Warning)

Operations to perform:

Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: contenttypes, sessions, Service, auth, Log, admin, User
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying Log.0001_initial... OK
Applying Service.0001_initial... OK
Applying User.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK

You have installed Django's auth system, and don't have any superusers defined.

Would you like to create one now? (yes/no): yes
Username (leave blank to use 'administrator'): admin
Email address: admin@qq.com
Password:
Password (again):
Superuser created successfully.

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/yingdiblog/p/6947399.html

你可能感兴趣的文章
Leetcode03
查看>>
Mysql常用命令
查看>>
Vuex的基本使用
查看>>
在DigitalOcean玩Kubernetes(K8S)
查看>>
python学习干货教程(11):元组
查看>>
神秘围棋AI“神之一手”:5秒一步令日本高手叹服
查看>>
vivo Y81s的usb调试模式在哪里,打开vivo Y81susb调试模式的流程
查看>>
docker-ce版本私有仓库搭建
查看>>
我的友情链接
查看>>
auto drop ssh failed ip address
查看>>
SSHv1版本的crc32漏洞
查看>>
我的友情链接
查看>>
hbase性能优化2
查看>>
Exchange 2007迁移2010后部分手机邮箱不能使用解决办法
查看>>
java try、catch、finally及finally执行顺序详解
查看>>
Operating System Concepts--chap9 Memory Management;
查看>>
ORA-01994 故障一例
查看>>
Notepad++添加右键菜单
查看>>
Java之JVM 优化经验总结
查看>>
CSS Hack 和向后兼容
查看>>