From f4ec8cd116eb2699b9c2ee99e1943019fa05db78 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 18 Nov 2017 17:22:05 +0000 Subject: [PATCH] Django cheatsheet --- backend/django.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 backend/django.py diff --git a/backend/django.py b/backend/django.py new file mode 100644 index 0000000..3676b5c --- /dev/null +++ b/backend/django.py @@ -0,0 +1,38 @@ +# ***************************************************************************** +# CODING STYLE > MAKING YOUR CODE READABLE +# ***************************************************************************** + + +# 1. Avoid abbreviating variable names. +# 2. Write out your function argument names. +# 3. Document your classes and methods. +# 4. Comment your code. +# 5. Refactor repeated lines of code into reusable functions or methods. +# 6. Keep functions and methods short. A good rule of thumb is that scrolling +# should not be necessary to read an entire function or method. + +# TIP: Use Flake8 for Checking Code Quality. + + +# ***************************************************************************** +# CODING STYLE > THE WORD ON IMPORTS +# ***************************************************************************** + + +# Imports should be grouped in the following order: + +# 1. Standard library imports. +# 2. Core Django imports. +# 3. Third-party app imports. +# 4. Imports from your apps. + +# Use explicit relative imports. +# Avoid using import * + + +# ***************************************************************************** +# CODING STYLE > OTHERS +# ***************************************************************************** + + +# Use underscores in URL pattern names rather than dashes.