This file contains hidden or 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 django.http import HttpResponse | |
from .models import FirstModel | |
# this view will make crazy use of the RAM ;) | |
def my_view(request): | |
# this queryset contains about 100k records | |
# each of them has many ForeignKeys to other models | |
huge_queryset = FirstModel.objects.all() | |
This file contains hidden or 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
import objgraph | |
import sys | |
import logging | |
from django.http import HttpResponse | |
from .models import FirstModel | |
logger = logging.getLogger(__name__) |
This file contains hidden or 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 django.contrib.auth.models import User | |
from django.views.generic import UpdateView | |
from .forms import UserProfileForm | |
class UserProfileUpdateView(UpdateView): | |
model = User | |
def get_initial(self): | |
initial = super(UserProfileUpdateView, self).get_initial() |
This file contains hidden or 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 django import forms | |
from django.contrib.auth.models import User, Group | |
class UserProfileForm(forms.ModelForm): | |
group = forms.ModelChoiceField(queryset=Group.objects.all(), | |
required=True) | |
class Meta: | |
model = User | |
fields = ['first_name', 'last_name', 'email', 'group'] |
This file contains hidden or 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
#!/usr/bin/python | |
import requests | |
from xlsxwriter import Workbook | |
import sys | |
from datetime import date, timedelta | |
import argparse | |
from math import floor, ceil | |
def toExcelTime(time, round_minutes=0, round_func=round): | |
# time is in milliseconds |
NewerOlder