We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Knowing yourself is the beginning of all wisdom.
Django Blog
Blog
Django
Bootstrap
Solr
Tomcat
urls.py
URL
models.py
Python
sqlite3
MySQL
PostgreSQL
settings.py
makemigrations
makemigrate
views.py
tempaltes
templates 文件夹
HTML
admin.py
forms.py
project
django-admin.py startproject project_name
project_name
project_name/ manage.py project_name/ __init__.py settings.py urls.py wsgi.py
manage.py
python manage.py help
__init__.py
wsgi.py
WSGI
app
django-admin.py startapp app_name
app_name
app_name/ __init__.py admin.py apps.py models.py tests.py views.py migrations/ __init__.py
migrations
python manage.py makemigrations
python manage.py runserver
http://localhost:8000
python manage.py runserver 8888
python manage.py runserver 0.0.0.0:8000
http://192.168.0.103:8000
Django Tips
urlpatterns
URLpattern
('^p/$', fun1)
/
/$
APPEND_SLASH
APPEND_SLASH=True
Python Tips
#!/usr/bin/env python
Shebang
unix
shell
./XX.py
import
The text was updated successfully, but these errors were encountered:
No branches or pull requests
0x01 Django
Django Blog
学习总结Blog
这个项目跟着书本断断续续的差不多20天,了解了Django
开发的基本流程,顺带了点Bootstrap
、Solr
、Tomcat
的知识Django
主要组成部分urls.py
URL
对应什么样的视图,利用了正则匹配来一一对应models.py
Python
类来描述数据表,Django
支持sqlite3
(Python
自带,无需安装),MySQL
,PostgreSQL
等数据库,只需在settings.py
中更改配置即可切换数据库,每次编辑更改models.py
文件,如果需要将改动应用到数据库中,需要进行数据迁移(也就是同步到数据库),利用makemigrations
和makemigrate
命令views.py
tempaltes
中的网页模板文件来显示内容templates 文件夹
HTML
模板,用于被渲染admin.py
forms.py
settings.py
Django
设置和配置文件Django
项目实践步骤project
django-admin.py startproject project_name
project_name
文件夹manage.py
: 一种命令行工具,允许以多种方式和Django
项目进行交互,python manage.py help
可以查看帮助,无需编辑__init__.py
: 空文件,无需编辑,让Python
认为这是开发所需文件settings.py
:Django
项目的设置和配置文件urls.py
:Django
项目的URL
设置文件,利用正则匹配将URL
和视图一一对应wsgi.py
: 用WSGI
应用的配置来运行项目app
project_name
文件夹内,创建app_name
文件夹migrations
文件夹 : 运行python manage.py makemigrations
所产生的数据改动文件都会被放在此文件夹内python manage.py runserver
http://localhost:8000
仅监听本地连接python manage.py runserver 8888
python manage.py runserver 0.0.0.0:8000
http://192.168.0.103:8000
Django Tips
urls.py
中的urlpatterns
URLpattern
都是一个元组('^p/$', fun1)
Django
在检查URL
模式前,会移除每一个申请的URL
开头的斜杠/
,所以写URLpattern
的时候前面不用写斜杠/
,末尾结束如果是/$
的话,如果匹配的时候,URL
没有输入/
,虽然不匹配,但是默认会将尾部没有斜杠/
的申请URL
,重定向至尾部包含斜杠的相同字眼URL
(这个情况受settings.py
中的APPEND_SLASH
控制,默认APPEND_SLASH=True
会自动添加斜杠,默认这个参数是没有的)Python Tips
#!/usr/bin/env python
Shebang
,类unix
系统根据文件头决定脚本运行方式,可以直接在shell
中输入./XX.py
来运用文件关联程序来打开Python
搜索路径import
语句,Python
会首先在当前目录查找,如果文件不存在,就在系统设置的目录查找The text was updated successfully, but these errors were encountered: