Django manages media based on the following definitions:
BASE_DIR = /var/praekelt/telkom-spliceworks/
MEDIA_ROOT = "%s/media/" % BASE_DIR| from django.utils.functional import curry | |
| class DetailsInline(admin.TabularInline): | |
| model = Details | |
| # formset = DetailsFormset | |
| extra = 3 | |
| def get_formset(self, request, obj=None, **kwargs): | |
| initial = [] | |
| if request.method == "GET": | 
| # views.py | |
| from rest_framework import exceptions | |
| from rest_framework import generics | |
| from myapp import models | |
| from myapp import serializers as ser | |
| class MethodSerializerView(object): | |
| ''' | 
| from django.db.models import Sum | |
| class AbsoluteSum(Sum): | |
| name = 'AbsoluteSum' | |
| template = '%(function)s(%(absolute)s(%(expressions)s))' | |
| def __init__(self, expression, **extra): | |
| super(AbsoluteSum, self).__init__( | |
| expression, absolute='ABS ', output_field=IntegerField(), **extra) | 
| sudo apt-get install putty-tools | |
| #private keys | |
| puttygen your_private_key.ppk -O private-openssh -o your_new_key | |
| chmod 600 your_new_key | |
| #public keys | |
| puttygen your_public_key.ppk -O public-openssh | |
| #based on answer at superuser | 
| #!/usr/bin/env python3 | |
| from reportlab.lib.pagesizes import A4 | |
| from reportlab.graphics.shapes import Drawing, String | |
| from reportlab.graphics.barcode.eanbc import Ean13BarcodeWidget | |
| from reportlab.graphics import renderPDF | |
| from reportlab.pdfgen.canvas import Canvas | |
| """ | |
| Adjust pagesize, number of labels, barcode size and | 
| from django import forms | |
| from django.contrib.postgres.fields import ArrayField | |
| class ChoiceArrayField(ArrayField): | |
| """ | |
| A field that allows us to store an array of choices. | |
| Uses Django 1.9's postgres ArrayField | |
| and a MultipleChoiceField for its formfield. | 
| class IdManyRelatedField(ManyRelatedField): | |
| field_name_suffix = '_ids' | |
| def bind(self, field_name, parent): | |
| self.source = field_name[:-len(self.field_name_suffix)] | |
| super().bind(field_name, parent) | |
| class IdPrimaryKeyRelatedField(PrimaryKeyRelatedField): | |
| """ | 
I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.