1.主项目下的url配置:urls.py文件

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url from django.views.generic import TemplateView urlpatterns = [
path('admin/', admin.site.urls),
url('^appName/', include('appName.urls')),
url(r'^index/', TemplateView.as_view(template_name="index.html")),
# url(r'^xingyunwa/', TemplateView.as_view(template_name="lucky.html")),
] 2.settings.py文件 1)允许什么ip可以访问:
ALLOWED_HOSTS = [
'127.0.0.1',
] 2)加入创建的APP:如appName
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', 'appName',
]
3)配置数据库链接
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME':'qfautodb',
'USER':'root',
'PASSWORD':'root',
'HOST':'localhost',
'PORT':'3306',
},
} 4)静态文件的配置:
STATIC_URL = '/static/'

# STATIC_ROOT = os.path.join(BASE_DIR, "collectstatic")

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"), 'commonstatic/static/' ]

3.app中的url.py文件配置:如appName
from django.conf.urls import url
from appName.views import home
urlpatterns = [
url('^home', home, name='home'),
] HTML页面中引用: 引用url:href="{% url 'home' %} # 对应name的值 引用数据:{{ variable_name }} # 后端返回数据的变量名或字典key

4.django寻找HTML文件的路径:

  1)本项目下的templates目录下
  2)各app下的templates目录下 5.django寻找静态文件路径:
  
  1)本项目下的static目录下
  2)settings.py配置文件中的目录:
    STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"), 'commonstatic/static/' ]

Django -- some config的更多相关文章

  1. python virtualenv环境运行django

    python virtualenv环境运行django 安装前准备 检查pip版本与python版本是否一致 [root@localhost bin]# whereis pip pip: /usr/b ...

  2. django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python?

    Error msg: Unhandled exception in thread started by <function check_errors.<locals>.wrapper ...

  3. Django常见问题集

    django2.0发行文档说,django2.0最后一个支持的是python3.4+... 所以,还在用python2.7的同学只能手动指定版本下载了 pip2 install django==1.8 ...

  4. centos 7下 django 1.11 + nginx 1.12 + uwsgi 2.0

    之前写过一个博客关于如何安装django的,见下网址, http://www.cnblogs.com/qinhan/p/8732626.html 还有一个网址如何安装nginx的 http://www ...

  5. Django 日志配置按日期滚动

    记录下Django关于日期的配置,以及如何根据日期滚动切割日志的问题. 配置的源码在githun上 https://github.com/blackmatrix7/django-examples/tr ...

  6. Django 框架 数据库操作

    数据库与ORM 1    django默认支持sqlite,mysql, oracle,postgresql数据库.  <1> sqlite django默认使用sqlite的数据库,默认 ...

  7. 【Django】ModuleNotFoundError: No module named 'books_ordersschool'

    Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000 ...

  8. Ununtu 15.04 安装MySql(Django连接Mysql)

    本文介绍Ubuntu 15.04下安装MySQL ubuntu 15.04安装mysql django项目连接mysql 一.安装数据库 1.sudo apt-get install mysql-se ...

  9. Django问题 TypeError: __init__() missing 1 required positional argument: 'on_delete'

    问题:在执行python manage.py makemigrations learning_logs时,系统会报错,提示:TypeError: __init__() missing 1 requir ...

随机推荐

  1. Atitit.软件仪表盘(0)--软件的子系统体系说明

    Atitit.软件仪表盘(0)--软件的子系统体系说明 1. 温度检测报警子系统 2. Os子系统 3. Vm子系统 4. Platform,业务系统子系统 5. Db数据库子系统 6. 通讯子系统 ...

  2. Out of Hay(poj2395)(并查集)

    Out of Hay Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11580   Accepted: 4515 Descr ...

  3. shell取余数

    shell取余数 技术分享 » linux | 阅读(9993) | 评论(0) Sep 3 2010 备忘脚本date取得分钟数$(()) 运算 #execute every 5 minutesa= ...

  4. 使用Crypto++库的CBC模式实现加密(二)

    前面已经有一篇介绍使用Crypto++库实现的加密的文章了,但是代码中考虑的不完全,所以就重新发了个二 C++封装: #include "zyaes.h" #include < ...

  5. FreeRTOS——任务调度—抢占式,时间片和合作式

    以下转载自安富莱电子: http://forum.armfly.com/forum.php 本章教程为大家将介绍 FreeRTOS 操作系统支持的任务调度方式:抢占式,时间片和合作式,这部分算是 Fr ...

  6. w3c html dom

    http://www.w3school.com.cn/ SQL语句学习 http://www.w3school.com.cn/sql/sql_like.asp

  7. Android App性能測试

    一.内存 1.查看单个应用App最大内存限制 Command:adb shell "getprop|grep heapgrowthlimit" C:\Users\hujiachun ...

  8. [I2C]pca9555应用层测试代码

    注意点: 如果在设置I2C_SLAVE的时候,提示device_busy,可以使用I2C_SLAVE_FORCE, 在驱动里面二者对应同一个case语句 应用层可以调用接口:i2c_smbus_wri ...

  9. Java Spring Boot: Unable to determine jdbc url from datasource

    如果你和我一样从github或码云上下载了一个几年前别人写的demo代码,想用来做学习用.编译的时候遇到下面这样的错误,然后死命上网查各种方案,百试不灵.试尽了各种方案,就是还连接不上数据库.你可以试 ...

  10. ubuntu安装wineqq遇到错误

    在安装中发生了错误:Errors were encountered while processing: wine-qqintl 原因是还有lib没有配置,所以再输入sudo apt-get insta ...