zoukankan      html  css  js  c++  java
  • django项目环境设置

    1.连接数据库,如mysql

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'django_comi',
            'USER': 'root',
            'PASSWORD': 'rootpasswd',
            'HOST': '127.0,0,1',
            'PORT': '3306'
        }
    }

    2.模板文件

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'templates')]
            ,
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
                'builtins': ['django.templatetags.static']  # 自动加载staic文件  == {% load static %}
            },
        },
    ]

    3.配置static路径,一般在setting文件末添加

    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'static'),
    )

    4.设置时区

    TIME_ZONE = 'Asia/Shanghai'
  • 相关阅读:
    56. Merge Intervals
    Reorder List
    Merge Two Sorted Lists
    彻底删除kafka topic数据
    什么时候类加载
    checkpoint的作用
    case when
    SQL:将查询结果插入到另一个表的三种情况
    IFNULL函数
    kafka主要配置
  • 原文地址:https://www.cnblogs.com/tangpg/p/9198036.html
Copyright © 2011-2022 走看看