• model


    一 先用sqlite测试一把:

    1.1 修改配置文件 server/server/setting.py

    # Database
    # https://docs.djangoproject.com/en/dev/ref/settings/#databases
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }

    1.2 自定义model    /server/blog/models.py

    from django.db import models
    
    # Create your models here.
    class User(models.Model):
        name=models.CharField(max_length=20)

    温馨提示:记得要Application definition  (setting.py)

    INSTALLED_APPS = (                                                                                                          
        'django.contrib.admin',                                                                                                              
        'django.contrib.auth',                                                                                                              
        'django.contrib.contenttypes',                                                                                                          
        'django.contrib.sessions',                                                                                                            
        'django.contrib.messages',                                                                                     
        'django.contrib.staticfiles',                                                                                                               
        'blog',                                                                                                                                 
    )   

     

    1.3   检查model 是否合法。

    If you’re interested, also run the following commands:

    Looking at the output of those commands can help you understand what’s actually happening under the hood.

     1.4  创建数据库

    python manage.py syncdb



    用mysql修改下数据库就可以了。

    修改配置文件 server/server/setting.py
    # Database
    # https://docs.djangoproject.com/en/dev/ref/settings/#databases
    
    DATABASES = {
        'sqlite': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        },
        'default':{
            'ENGINE': 'django.db.backends.mysql',
            'NAME'  : 'pytest',
            'USER'  : 'root',
            'PASSWORD'  :   '1111',
        },
    }





    用MYSQL数据库实现:








  • 相关阅读:
    Oracle用户管理
    Oracle基本使用
    Oracle 11g安装、卸载
    Oracle
    C#面向对象
    看看Google用户体验十大设计原则
    [转]Delphi 常用控件之TlistView总结
    github + hexo 搭建博客
    CSS3 filter属性学习
    border-box——一种改变盒子尺寸的方法
  • 原文地址:https://www.cnblogs.com/canbefree/p/3945687.html
Copyright © 2020-2023  润新知