A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
class LoginRequiredMixin(object): | |
""" | |
View mixin which requires that the user is authenticated. | |
""" | |
@method_decorator(login_required) | |
def dispatch(self, request, *args, **kwargs): | |
return super(LoginRequiredMixin, self).dispatch( | |
self, request, *args, **kwargs) |
# create a file C:\Users\[user]\.bashrc | |
# add this content | |
# add your onw aliases or changes these ones as you like | |
# to make a dot (.bashrs) file in windows, create a file ".bashrs." (without extention) and save. windows will save it as ".bashrc" | |
alias ls='ls -alh' | |
alias cdnginx='cd /c/nginx && ls' | |
alias cdmcga='cd /c/Users/[user]/sbox/node/mcga && ls' | |
alias cdfood9='cd /c/Users/[user]/sbox/node/food9 && ls' | |
alias cdmysql='cd /c/nginx/mysql/bin && ls' |
##Some points to mention... | |
## | |
##The model knows nothing about the view or the controller. | |
##The view knows nothing about the controller or the model. | |
##The controller understands both the model and the view. | |
## | |
##The model uses observables, essentially when important data is changed, | |
##any interested listener gets notified through a callback mechanism. | |
## | |
##The following opens up two windows, one that reports how much money you |
{ | |
"presets": [ | |
["env", { | |
"targets": { | |
"node": "6.10" | |
} | |
}] | |
] | |
} |
Run pip install pipenv
to install pipenv
Run pipenv shell
to create an environment, if does not exist, and activate it.
Run pipenv install python_decouple whitenoise dj_database_url Pillow gunicorn
May take a while.
This should create two files: Pipfile
and Pipfile.lock
. Keep them in the project root.
from django.contrib import admin | |
from .models import User | |
admin.site.register([User]) |
sudo apt-get install curl | |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
sudo apt-get install nodejs | |
node -v | |
npm -v |
# Dibuja aleatoriamente polígonos con efecto caleidoscópico. | |
# Esta versión solo funciona correctamente desde la app Pythonista. | |
import turtle | |
from random import * | |
# Configuramos la pizarra para la tortuga. | |
t = turtle |