I hereby claim:
- I am sjkingo on github.
- I am sjkingo (https://keybase.io/sjkingo) on keybase.
- I have a public key ASC2GrxtlLaSX3EU3RMgZCWRREzbpr15bs4pr3x5bxRbfgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import logging | |
class SuppressDeprecated(logging.Filter): | |
def filter(self, record): | |
WARNINGS_TO_SUPPRESS = [ | |
'RemovedInDjango110Warning' | |
] | |
# Return false to suppress message. | |
return not any([warn in record.getMessage() for warn in WARNINGS_TO_SUPPRESS]) |
libglew-2.0
is required and Fedora only ships with version 1.13. Build and override the system-wide libglew
:
# build glew at /path/to/glew-2.0.0
$ export PKG_CONFIG_PATH=/path/to/glew-2.0.0/dest/lib/pkgconfig
$ cd /path/to/kitty
$ python3 setup.py build
$ LD_PRELOAD=/path/to/glew-2.0.0/dest/lib64/libGLEW.so python3 .
from django.db import models | |
class SomeModel(models.Model): | |
# fields here | |
class Meta: | |
pass | |
def get_absolute_url(self): | |
return reverse('pdf_view', id=self.id) |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>{{ title }}</title> | |
<meta name="generator" content="fantail-{{ version }}"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> |
Django 1.8 drops the name
field from ContentType
in favour of a property on the model itself (see https://docs.djangoproject.com/en/1.8/ref/contrib/contenttypes/#the-contenttype-model).
If you update to 1.8 and then back to 1.7 (for whatever crazy reason..) you will come across exceptions as the name
property doesn't exist (and neither does the database field).
These scripts restore that functionality to Django 1.7 (by recreating the field and populating it correctly).
It does not cause any data loss, but as always: Use at your own risk.
filename = 'image.jpg' | |
source_fp = open(filename, 'rb') | |
p = Product.objects.get(...) | |
# Create the ProductImage if it doesn't exist already and assign to Product | |
images = ProductImage.objects.filter(description=filename) | |
if len(images) == 0: | |
the_file = File(source_fp) | |
the_image = p.images.create( | |
product=p, |