A brief introduction to Python's Django Framework Dj-scaffold project

Source: Internet
Author: User
Tags virtual environment

This article mainly introduces the Dj-scaffold project, which introduces the Django framework of Python, which is used to assist the directory setting of the Django framework, and the friends who need it can refer to the

Since Django does not specify the directory structure specification for a project like rails, many people are puzzled by how the Django project's directory structure is organized. For this I have created a new open source project Dj-scaffold (Django Scaffolding). This project is used to automatically generate an annotated Django project and app.

Project Address: Https://github.com/vicalloy/dj-scaffold

Installation

has been posted to PyPI, so you can use PIP or Easy_install to install it.

?

1 2 Pip Install Dj-scaffold Easy_install dj-scaffold

Use

Dj-scaffold mainly provides two commands, dj-scaffold.py and Lbstartapp.

dj-scaffold.py

This script replaces the Django Startproject command. The use of the following methods:

?

1 dj-scaffold.py ProjectName

After the command executes, the project ProjectName is created. Script create_env.py and env.rc are provided in the project's scripts directory.

create_env.py execution of the script will automatically initialize the Python virtual environment. The newly generated Python virtual environment is in the Env directory.

Env.rc The script user launches the Python virtual environment (source env.rc). The script also sets the shortcut $mg for the Python manage.py. You can invoke $mg in any directory to execute the Django command. For example, you use $MG runserver to start a test server.

The corresponding directory structure for the project is as follows:

Note: There are too many files to remove some of the unimportant files

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14-15 16 dj-scaffold.py ProjectName |+docs/#用于存放项目的相关文档 |+env/#python虚拟环境, automatically generated by the script |~requirements/#第三方依赖包的存放位置 | '-requirements.pip #pip的依赖说明文件 |~scripts/#系统相关的脚本 | |-create_env.py #创建python虚拟环境 (env directory) | '-env.rc #进入python虚拟环境. also provides shortcut $mg for Python manger.py. $mg. |~sites/#Django的项目文件 can be used in any directory. Some of the default configurations are added to the settings file. If the database defaults to using SQLite, set the template for the project and the static file directory. | |+media/#项目静态文件 (user upload) | |+static/#项目静态文件 (CSS, JS, etc.) | ' +templates/#项目模板 |+tools/#一些项目依赖的第三方工具包. such as Python virtual environment initialization scripts, and so on. ' ~wsgi/#项目部署用的wsgi文件 '-dj_scaffold.wsgi

Lbstartapp

Lbstartapp is provided as a Django extension command. You can use this command after adding Dj_scaffold to Installed_apps. The command will generate a standard app that generates the less common app default directories than the Django Startapp,lbstartapp. The corresponding directory structure is as follows:

?

1 2 3 4 5 6 7 8 9 of |+management/#命令目录 |+static/#静态文件目录 |+templates/#模板目录 |+templatetags/#tag目录 |-__init__.py |-admin.py #admin管理后台的mod Els configuration file |-forms.py |-models.py |-settings.py #app自己的settings文件 |-tests.py |-urls.py #urls配置文件 '-views.py 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.