博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Chapter 3:Code Style in Django
阅读量:5909 次
发布时间:2019-06-19

本文共 3446 字,大约阅读时间需要 11 分钟。

• 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
1240
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.
1240
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:
1240
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

转载地址:http://qstpx.baihongyu.com/

你可能感兴趣的文章
windows和linux下获取当前程序路径以及cpu数
查看>>
[转]Asp.net MVC中Html.Partial, RenderPartial, Action,RenderAction 区别和用法
查看>>
有关android 应用的plugin框架调研
查看>>
(太强大了) - Linux 性能监控、测试、优化工具
查看>>
GlusterFS源代码解析 —— GlusterFS 简单介绍
查看>>
Asp.Net Web Api 图片上传
查看>>
混沌的艺术--- YChaos通过数学公式生成混沌图像
查看>>
codechef Little Elephant and Permutations题解
查看>>
如何从github上面拷贝源码
查看>>
C++标准 bind函数用法与C#简单实现
查看>>
【POJ】2096 Collecting Bugs
查看>>
【Linux】linux经常使用基本命令
查看>>
[JAVA设计模式]第二部分:创建模式
查看>>
nyoj86-找球号(一) 【set 二分查找 hash】
查看>>
关于数组集合之间的转换
查看>>
Object-C 基础学习笔记(for,foreach,while,switch)
查看>>
[推荐]DDOS攻击与防范知识介绍
查看>>
Android SDK下载项的说明
查看>>
**PHP二维数组遍历时同时赋值
查看>>
Java读写Excel之POI超入门
查看>>