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
This file contains 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 functools | |
from django.db.models import Prefetch, QuerySet | |
import attr | |
import graphene | |
from cursor_pagination import CursorPaginator | |
from graphene.utils.str_converters import to_snake_case | |
from graphql_relay import connection_from_list |
This file contains 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
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': True, | |
'formatters': { | |
'verbose': { | |
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' | |
}, | |
'simple': { | |
'format': '%(levelname)s %(message)s' | |
}, |
This file contains 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
# Extra imports | |
from rest_framework.authtoken.models import Token | |
from rest_framework.response import Response | |
from rest_framework import status | |
class Login(ObtainAuthToken): | |
serializer_class = MyAuthTokenSerializerWithExtraChecks | |
def post(self, request): | |
"""Override the post method to use custom serializer class.""" |
This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am mjtamlyn on github. | |
* I am mjtamlyn (https://keybase.io/mjtamlyn) on keybase. | |
* I have a public key whose fingerprint is 43B2 D38F 7D86 E0FD B442 D407 2D52 B74A 095C B09A | |
To claim this, I am signing this object: |
Simple utility class for creating context objects (e.g. context=Context(user=user)
)
A wrapper class for strings to say "don't touch me". Can be used for arguments and as keys of the object passed to build_query
.
A unittest.TestCase mixin with utility functions
This file contains 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
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 | |
+ |
This file contains 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
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 |
This file contains 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
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): |
This file contains 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 apps | |
from django.contrib import admin | |
class AdminConfig(apps.AppConfig): | |
name = 'django.contrib.admin' | |
def ready(self): | |
admin.autodiscover() |
NewerOlder