Get the Python library:
pip install newrelic
Add this to your ProcFile:
web: newrelic-admin run-program python cn_project/manage.py run_gunicorn -b "0.0.0.0:$PORT" -w 3 --settings=settings.prod
/* exported Script */ | |
/* globals console, _, s */ | |
/** Global Helpers | |
* | |
* console - A normal console instance | |
* _ - An underscore instance | |
* s - An underscore string instance | |
*/ |
class ProductAutochangeInlineFormSet( | |
forms.inlineformset_factory(ProductAutochangeSet, ProductAutochange, form=ProductAutochangeForm, extra=1)): | |
def clean(self): | |
super(ProductAutochangeInlineFormSet, self).clean() | |
product_pks = [] | |
num_productautochanges = 0 | |
for form in self.forms: | |
if not form.is_valid(): | |
continue |
Get the Python library:
pip install newrelic
Add this to your ProcFile:
web: newrelic-admin run-program python cn_project/manage.py run_gunicorn -b "0.0.0.0:$PORT" -w 3 --settings=settings.prod
pipenv install ipykernel jupyter | |
pipenv shell | |
python -m ipykernel install --user --name=$(basename $(pwd)) | |
jupyter notebook | |
# then in UI, switch kernel to the one matching your pipenv shell name |
Django channels are official way for implementing async messaging in Django.
The primary caveat when working with GraphQL subscription is that we can't serialize message before broadcasting it to Group of subscribers. Each subscriber might use different GraphQL query so we don't know how to serialize instance in advance.
See related issue
remember_me = forms.BooleanField(required=False, widget=forms.CheckboxInput()) | |
if not self.cleaned_data.get('remember_me'): | |
self.request.session.set_expiry(0) |
As configured in my dotfiles.
start new:
tmux
start new with session name:
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard | |
from django.contrib import admin | |
from django.db.models import Count, Sum, Min, Max, DateTimeField) | |
from django.db.models.functions import Trunc | |
from . import models | |
def get_next_in_date_hierarchy(request, date_hierarchy): |
# -*- encoding: utf-8 -*- | |
# -------------------------- | |
# Ripped from django project | |
# -------------------------- | |
from django.contrib.contenttypes.models import ContentType | |
from django.utils.translation import ugettext as _ | |
from django.utils.encoding import force_unicode |