View urls.py
# place file in static root
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.storage import staticfiles_storage
urlpatterns = [
url(r'C798C4F2FDD57D2D63BF76874C080F49.txt', RedirectView.as_view(
url=staticfiles_storage.url('C798C4F2FDD57D2D63BF76874C080F49.txt'),
permanent=True),
View django
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
upstream websocket {
server 127.0.0.1:8001 fail_timeout=0;
}
#server {
# listen 80;
View gunicorn.conf
# gunicorn.conf
description "Gunicorn app server for Django Project"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid username
setgid www-data
View websockets.html
<!DOCTYPE html>
<html lang="en" dir="ltr" class="no-js">
<head>
<title>WebSockets</title>
<script language="javascript" type="text/javascript">
var wsUri = "wss://url.com.au/websockets/";
var output;
View nginx.conf
# /etc/nginx/nginx.conf
##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";
gzip_vary on;
View httpd-app.conf
# need to add the below or DRF will throw auth errors
WSGIPassAuthorization On
View pycharm-venv.txt
# Reminder for me! How to configure PyCharm to use venv
- create virtual env as per usual via command line
- PyCharm > Preferences > Project / Project Interp.
- click cog > Add Local & and select Python from within local project bin
- Done!
View django_queryset_group.py
from itertools import chain
from operator import attrgetter
group1_queryset = group1.objects.all() or filter()
group2_queryset = group2.objects.all() or filter()
result = sorted(
    chain(group1_queryset, group2_queryset),
    key=attrgetter('created'))
    
View Postgres Cheatsheet
# create db
CREATE DATABASE <name>;
# create role
CREATE ROLE <username> WITH LOGIN ENCRYPTED PASSWORD '<password>' CREATEDB;
# change bool or other
ALTER TABLE <table> ALTER <column> TYPE boolean USING (<column>::boolean);
# change smallint to bool
View django
# Your Django project's media files - amend as required
location /media {
if ($request_filename ~* ^.*?/([^/]*?)$) {
set $filename $1;
}
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
alias /django/django_project/media;