View default
# full nginx conf for Django w/web-sockets
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
upstream websocket {
server 127.0.0.1:8002 fail_timeout=0;
}
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 cli.txt
# view all running processes
ps aux
# kill a process
sudo kill <PID>
# edit SSH keys
cd ~/.ssh
nano authorized_keys
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'))