This is a draft cheat sheet. It is a work in progress and is not finished yet.
PEP8
- Use 4 spaces per indentation level.
- Separate top-level function and class definitions with two blank lines
- Method deô€…€nitions inside a class are separated by a single blank line. |
Imports Order
1. Standard library imports.
2. Imports from core Django.
3. Imports from third-party apps including those unrelated to Django.
4. Imports from the apps that you created as part of your Django project. |
|
|
urls.py
Underscores |
url(regex='^add/$', view=views.add_topping, name='add_topping'), |
|
|
NULL AND BLANK - How to use
Field Type |
NULL |
BLANK |
CharField, TextField, SlugField, EmailField, CommaSeparatedInteger- Field, UUIDField |
Don't do this. |
Okay. |
FileField, ImageField |
Don't do this. |
Okay. |
BooleanField |
Don't do this. |
Don't do this. |
IntegerField, FloatField, DecimalField, DurationField, etc |
Okay |
Okay |
DateTimeField, DateField, TimeField, etc. |
Okay |
Okay |
ForeignKey, ManyToManyField, OneToOneField |
Okay |
Okay |
GenericIPAddressField |
Okay |
Okay |
IPAddressField |
Not recommended for use |
Not recommended for use |
|
|
|