Home

Search IconIcon to open search

Django

A Python framework for creating websites and web apps.

# Notes

Use timezone.now() instead of datetime stuff.

python manage.py shell to open a shell and interact with Django API. Can write stuff to databases!

1
2
3
4
5
6
# Django provides a rich database lookup API that's entirely driven by
# keyword arguments.
>>> Question.objects.filter(id=1)
<QuerySet [<Question: What's up?>]>
>>> Question.objects.filter(question_text__startswith='What')
<QuerySet [<Question: What's up?>]>

When sending POST request, use {% csrf_token %}. Whatever that means.

forloop.counter indicates how many times the for tag has gone through its loop.

Should do .save() to commit changes to DB.

To create a custom 404 page, just add 404.html to templates folder. Don’t know why this works.

# Stuff to read later

# Not that important, but interesting

# Example projects