My first setup files
Project description
测试有序列表
- a
- b
- c
djangoshortcuts
提供一个全局命令,用于方便快捷生成模板等相关文件。
安装
python setup.py install
使用方式
在安装成功之后,获得一个全局命令:dj,通过 dj -h 可以查看到该命令的使用方式
$dj -h
usage: dj [-h] --app APP [-a ADD] [-t TEMPLATE] [-s STATIC]
Easily to create files when using django
optional arguments:
-h, --help show this help message and exit
--app APP input the app name which django created
-a, --add ADD add file automatically, the value must be one of
['forms', 'urls']
-t, --template TEMPLATE
add templates html files
-s, --static STATIC add static files
You must cd BASE_DIR to run this script
全局命令备忘查询
有时候忘记安装这些模块都提供了哪些全局命令,可以通过以下这种方式查询。
$python -m djangoshortcuts -h
Please use command [dj -h] for the detail.
举例说明
下面简要举例说明这个命令的使用方式,其实看上面的 usage 就可以明白九成以上了。
假设 django app 名称为 polls, 首先需要切换到网站的根目录下,就可以运行以下命令
- 生成 forms.py 或者 urls.py 文件
dj --app polls -a forms
dj --app polls -a urls
- 生成 index.html 文件
dj --app polls -t index.html
该命令会自动创建 polls/templates/polls 相关的文件夹,并生成 polls/templates/polls/index.html 文件
- 生成 style.css 文件
dj --app polls -s style.css
该命令会自动创建 polls/static/polls 相关的文件夹,并生成 polls/static/polls/style.css 文件
- 考虑到静态文件夹下常增加 css 和 js 文件夹来管理相关静态文件,所以在 -s 参数的行动逻辑多增加一个功能
dj --app polls -s css/style.css
该命令和 3 的区别在于,文件的路径为 polls/static/polls/css/style.css,相关的文件夹会自动创建
dj --app polls -s js/login.js
同样地,文件的路径为 polls/static/polls/js/login.js
后记
以上参数中,--app 是必选参数,除此之外的参数都是可选参数并且不互斥。也就是说添加文件的时候,不同的参数可以同时进行。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zhang_hello-1.0.2.tar.gz
(2.5 kB
view details)
File details
Details for the file zhang_hello-1.0.2.tar.gz.
File metadata
- Download URL: zhang_hello-1.0.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c95ab29ca3ea12d0f6d1518f37290110b96229591c9eee92ed24143a8d9e007
|
|
| MD5 |
2080d905ce4fc388625946dabf122e8c
|
|
| BLAKE2b-256 |
b012cfc13920e756bcb5657322b1ccfbf6d3648d45b9f5176d485bdb48d91769
|