pip install django-reversion
Add reversion to INSTALLED_APPS
INSTALLED_APPS = [
...
...
...
pip install django-reversion
Add reversion to INSTALLED_APPS
INSTALLED_APPS = [
...
...
...
from itertools import chain | |
from operator import attrgetter | |
# ascending oreder | |
result_list = sorted( | |
chain(queryset1, queryset2), | |
key=attrgetter('date_created')) | |
# descending order |
class ViewManager(models.Manager): | |
def bulk_create(self, *args, **kwargs): | |
raise NotImplementedError | |
def create(self, *args, **kwargs): | |
raise NotImplementedError | |
def get_or_create(self, *args, **kwargs): | |
raise NotImplementedError |
# admin.py: admin action definition | |
def make_copy(self, request, queryset): | |
form = None | |
if 'apply' in request.POST: | |
form = CopyPageForm(request.POST) | |
if form.is_valid(): | |
issue = form.cleaned_data['issue'] |
""" | |
This module provides very simple Django middleware that sleeps on every request. | |
This is useful when you want to simulate slow response times (as might be | |
encountered, say, on a cell network). | |
To use, add this middleware, and add a value for SLEEP_TIME to your settings. | |
Possible future feature: Look for an X-Django-Sleep header on each request, | |
to let the client specify per-request sleep time. |
// Sliver appbar with tabs. | |
// Adapted from: https://stackoverflow.com/a/50858058 | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MaterialApp( | |
home: SilverAppBarWithTabBarScreen(), | |
)); | |
class SilverAppBarWithTabBarScreen extends StatefulWidget { |
TL;DR
Install Postgres 10, and then:
sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.6 main
sudo pg_dropcluster 9.6 main
# -*- coding: utf-8 -*- | |
"""Add permissions for proxy model. | |
This is needed because of the bug https://code.djangoproject.com/ticket/11154 | |
in Django (as of 1.6, it's not fixed). | |
When a permission is created for a proxy model, it actually creates if for it's | |
base model app_label (eg: for "article" instead of "about", for the About proxy | |
model). |
/* | |
* Copyright (c) 2017 Emil Davtyan | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: |