Skip to content

Instantly share code, notes, and snippets.

View mjtamlyn's full-sized avatar

Marc Tamlyn mjtamlyn

  • Photocrowd
  • Oxford
View GitHub Profile
diff --git a/tests/runtests.py b/tests/runtests.py
index e852346..16f6e7b 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -58,6 +58,7 @@ ALWAYS_INSTALLED_APPS = [
def get_test_modules():
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
+ from django.db import connection
modules = []
diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py
index 5a01adc..db88c94 100644
--- a/django/core/mail/__init__.py
+++ b/django/core/mail/__init__.py
@@ -3,6 +3,8 @@ Tools for sending email.
"""
from __future__ import unicode_literals
+from contextlib import contextmanager
+
diff --git a/django/forms/forms.py b/django/forms/forms.py
index bcc0d6d..46192ad 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -15,7 +15,7 @@ from django.forms.widgets import Media, MediaDefiningClass, TextInput, Textarea
from django.utils.html import conditional_escape, format_html
from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
from django.utils.safestring import mark_safe
-from django.utils.translation import ugettext as _
+from django.utils.translation import ugettext as _, ugettext_lazy
@mjtamlyn
mjtamlyn / gist:8304266
Created January 7, 2014 18:38
Django 1.7 on python 2.7 with the saferef patch
PYTHONPATH=.. ./runtests.py dispatch
Testing against Django installed in '/Users/marc/code/django/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.FFFFFFF...E
======================================================================
ERROR: dispatch.tests.test_saferef (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: dispatch.tests.test_saferef
Traceback (most recent call last):
@mjtamlyn
mjtamlyn / apps.py
Created January 1, 2014 17:15
THIS MAKES ME SO HAPPY
from django import apps
from django.contrib import admin
class AdminConfig(apps.AppConfig):
name = 'django.contrib.admin'
def ready(self):
admin.autodiscover()
@mjtamlyn
mjtamlyn / gist:8195542
Created December 31, 2013 11:29
Django stable/1.6.X on python 3.4b1
(django-py3.4) ~/code/django/tests  ± stable/1.6.X  PYTHONPATH=.. ./runtests.py --settings=test_sqlite
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/platform.py:647: DeprecationWarning: The readPlist function is deprecated, use load() instead
pl = plistlib.readPlist(fn)
Creating test database for alias 'default'...
/Users/marc/.virtualenvs/django-py3.4/bin/../lib/python3.4/codecs.py:897: DeprecationWarning: 'U' mode is deprecated
file = builtins.open(filename, mode, buffering)
Creating test database for alias 'other'...
...................................................................................................................................................s.....................................................................................................................................................................................x.............................................................................................................................................
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 2f94f64..8b864c3 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1820,11 +1820,14 @@ class ModelFormInheritanceTests(TestCase):
class ModelForm(forms.ModelForm):
class Meta:
model = Writer
- fields = '__all__'
+ fields = ['name']
diff --git a/feincms/module/extensions/translations.py b/feincms/module/extensions/translations.py
index cf4c7fd..0210b80 100644
--- a/feincms/module/extensions/translations.py
+++ b/feincms/module/extensions/translations.py
@@ -117,6 +117,7 @@ def get_current_language_code(request):
# ------------------------------------------------------------------------
class Extension(extensions.Extension):
def handle_model(self):
+ print 'translation extension being applied to:', self.model
cls = self.model
@mjtamlyn
mjtamlyn / gcbv2.md
Last active April 12, 2019 18:55
Django generic class based views - version 2?

Django generic class based views - version 2?

Firstly, lets start with some full disclosure. I'm a big fan of class based views. Since they first came out, I've pretty much not written a functional view at all. I use the generic ones almost all the time, when they don't fit I build my own. I've written some websites with wonderfully complex heirarchy of composed features, using almost every individual mixin from Django and a few of my own. When I want to do some work on Django, my first port of call is normally the list of issues tagged as "generic views". I envisaged CCBV and then helped rewrite the official documentation. In

@mjtamlyn
mjtamlyn / gist:5782021
Created June 14, 2013 14:00
What warnings? \o/
(django)marc tests $ python -Wd runtests.py --settings=test_sqlite
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..............................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................