A simple introduction to Python's Django Framework's Dj-scaffold Project

Source: Internet
Author: User
Tags virtual environment
Since Django does not specify a directory structure specification for a project like rails, many people are confused about how the directory structure of the Django project is organized. For this I have created a new open source project Dj-scaffold (Django Scaffolding). This project is used to automatically generate a labeled Django Project and App.

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

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

Use

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

This script is used to replace the Django Startproject command. Use the following methods:

dj-scaffold.py ProjectName  

After the command executes, the project ProjectName is created. Scripts create_env.py and env.rc are available 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 Python manage.py. You can invoke $mg in any directory to execute the Django command. For example, you use $MG runserver to start the test server.

The directory structure of the project corresponds to the following:

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


dj-scaffold.py ProjectName |+docs/  #用于存放项目的相关文档 |+env/   #python虚拟环境, automatically generated by script |~requirements/   # Where a third-party dependency package resides | '-requirements.pip  #pip的依赖说明文件 |~scripts/  #系统相关的脚本 | |-create_env.py  #创建python虚拟环境 (env directory) | '-env.rc  #进入python虚拟环境. also provides shortcut $mg for Python manger.py. You can use $MG. |~sites/#Django的项目文件 in any directory  . A partial default configuration is added to the settings file. If the database uses SQLite by default, set the project's template and the static file directory. |+media/  #项目静态文件 (user uploads) | |+static/  #项目静态文件 (CSS, JS, etc.) | ' +templates/  # Project Template |+tools/  #一些项目依赖的第三方工具包. such as the Python virtual environment initialization script. ' ~wsgi/  #项目部署用的wsgi文件 '-dj_scaffold.wsgi


Lbstartapp

Lbstartapp is provided as a Django extension command. This command can be used after adding dj_scaffold to Installed_apps. This command will generate a standard app that will generate the less common app default directories compared to the Django Startapp,lbstartapp. The corresponding directory structure is as follows:

|+management/  #命令目录 |+static/  #静态文件目录 |+templates/  #模板目录 |+templatetags/  #tag目录 |-__init__.py | admin.py  #admin管理后台的models配置文件 |-forms.py |-models.py |-settings.py  #app自己的settings文件 |-tests.py |-urls.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.