Sunday, June 7, 2015

Python

try...except...else
http://stackoverflow.com/questions/16138232/is-it-a-good-practice-to-use-try-except-else-in-python

Nodes on Django

The question_id='34' part comes from (?P<question_id>[0-9]+). Using parentheses around a pattern “captures” the text matched by that pattern and sends it as an argument to the view function; ?P<question_id> defines the name that will be used to identify the matched pattern; and [0-9]+ is a regular expression to match a sequence of digits (i.e., a number).
https://docs.djangoproject.com/en/1.8/intro/tutorial03/

In short, all POST forms that are targeted at internal URLs should use the {% csrf_token %} template tag.


# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.