Chapter 3:Code Style in Django

简介: • Django coding style• Using IDE for Django web development• Django project structure• Best practices—using version control• Django rescue ...

• Django coding style
• Using IDE for Django web development
• Django project structure
• Best practices—using version control
• Django rescue team (where to ask Django questions)
• Faster web development—using Twitter-Bootstrap

The Django project structure
$ django-admin.py startproject django_mytweets

Paste_Image.png

manage.py: This is utility script is used to manage our project. You can think of it as your project's version of django-admin.py. Actually, both django-admin.py and manage.py share the same backend code.

settings.py 参数说明:

  • DEFAULT_APPS: This parameter contains the default Django installedapplications (such as the admin)
  • THIRD_PARTY_APPS: This parameter contains other application likeSocialAuth used for social authentication

  • LOCAL_APPS: This parameter contains the applications that arecreated by you

Best practices - using version control

Let's take a look at the following commands and their uses(git常用命令):

  • $git add <file-name> or $git add: For adding all files to the staging area in bulk.
  • $git status: To know the status of your working directory, which files have been added, and which files have not been added.
  • $git diff: To get the status of what is modified and staged, or what is modified and has not been staged.
  • $ git commit -m: To commit the changes made, first you have to add them to the staging area; then, you have to commit them using this command.
  • $ git rm <file-name>: If you have mistakenly added any file to the staging area, you can remove it from the staging area by using this command.
  • $git stash: Git doesn't track the renamed files. In other words, if you have renamed already staged files, you will have to add them again to the staging and then commit. You can save the changes by not actually committing to the repository by using the following command.
  • $git stash apply: It takes all the current changes and saves it to the stack. Then, you can continue working with your changes. Once you are in a position to get your saved changes, you can do so using this command.

分支

  • $git branch: To list an existing branch using Git, we need to use this command.

Paste_Image.png
  • $git checkout -b <new-branch-name>: A new branch can be created in the existing repository using this command. We can see logically how it looks with the help of the following block diagram:

Paste_Image.png

You will get a message informing you that you have switched to the new branch. If you want to switch back to the old branch, you can use the following command:

  • $git checkout <old-branch-name>: You will see the message Switched to branch <old-branch-name>.

  • $git merge <branch-name>: After the feature is complete, you can merge it to the branch of your choice using this command. This will merge the
    branch <branch-name> to your current branch. To sync the changes back to
    the <branch-name>, you can check out from your current branch to the
    branch <branch-name> and merge again. You can also mark the important points in your commit history by using tags.

  • After the commit, you can tag an important commit by using the $git tag-a v1.0 command.

  • To get new changes from the remote server, you can fetch the changes from Git using the $git fetch command.

  • To merge the changes directly to your current branch, you can use the $git pull command.

  • After you are done with your changes, you can commit and push them to the remote repository using the $git push command.

运行服务,切换到根目录下执行如下语句:

$ python3 manage.py runserver 8080
目录
相关文章
|
存储 测试技术 编译器
芯片测试:万字长文一起聊聊IC测试机-ATE
芯片测试:万字长文一起聊聊IC测试机-ATE
1902 0
|
机器学习/深度学习 边缘计算 5G
室内定位之5G定位
室内定位之5G定位
717 1
|
SQL 弹性计算 安全
一文教你如何从零构建机密计算平台解决方案-ECS安全季
本文整理自【弹性计算技术公开课——ECS安全季】中,阿里云弹性计算产品专家唐湘华和阿里云弹性计算高级技术专家聂百川带来的收官课程《从零构建机密计算平台的解决方案》一节。
|
流计算
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)【6节点 9节点 14节点 26节点 30节点 57节点】(Matlab代码实现)
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)【6节点 9节点 14节点 26节点 30节点 57节点】(Matlab代码实现)
481 0
|
容器
Vite项目当中的SVG图标的配置及图标全局组件的封装
Vite项目当中的SVG图标的配置及图标全局组件的封装
401 0
|
JSON 编解码 Go
【Go语言专栏】Go语言中的JSON编码与解码
【4月更文挑战第30天】Go语言内置JSON编码解码支持,简化了数据交换。`json.Marshal`用于将Go结构体转换为JSON,如示例中`Person`结构体的编码。`json.Unmarshal`则将JSON数据反序列化到结构体,需传入结构体变量的地址。错误处理至关重要,特别是在处理大量数据时,要注意性能优化,如避免不必要的转换和重复操作。了解自定义编码解码和最佳实践能提升开发效率。掌握这些技能,有助于构建高效Go应用。
159 0
|
数据可视化 算法 前端开发
一文吃透低代码平台源代码交付的重要性(避坑指南)
一文吃透低代码平台源代码交付的重要性(避坑指南)
596 0
|
存储 缓存 算法
【大数据】RAID介绍(一)
【大数据】RAID介绍
374 0
【大数据】RAID介绍(一)
IDEA版SpringBoot全教程 04 整合JSP
IDEA版SpringBoot全教程 04 整合JSP
256 0
|
存储 前端开发 API
低代码钉钉宜搭 TODOMVC 小白教程
TODOMVC for LCAP - Dingtalk YIDA
1395 0
低代码钉钉宜搭 TODOMVC 小白教程