This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# need to add the below or DRF will throw auth errors | |
WSGIPassAuthorization On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/nginx.conf | |
## | |
# `gzip` Settings | |
# | |
# | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gunicorn.conf | |
description "Gunicorn app server for Django Project" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
setuid username | |
setgid www-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# connect to db | |
sudo -u postgres psql postgres | |
# export table as CSV | |
COPY table_name TO '/tmp/users_export.csv' DELIMITER ',' CSV HEADER; | |
# create db | |
CREATE DATABASE <name>; | |
# create role |