From 15423ec74d770bd3c00180ca85c13d951ad8fb61 Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Wed, 1 Aug 2012 14:23:21 -0400 Subject: [PATCH] Default to null=True for Django Fields. Fixes issue #161. Reviewed in http://codereview.appspot.com/6448098/ --- oauth2client/django_orm.py | 10 ++++++++++ samples/django_sample/settings.py | 17 ++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/oauth2client/django_orm.py b/oauth2client/django_orm.py index f9ce26d..d54d20c 100644 --- a/oauth2client/django_orm.py +++ b/oauth2client/django_orm.py @@ -31,6 +31,11 @@ class CredentialsField(models.Field): __metaclass__ = models.SubfieldBase + def __init__(self, *args, **kwargs): + if 'null' not in kwargs: + kwargs['null'] = True + super(CredentialsField, self).__init__(*args, **kwargs) + def get_internal_type(self): return "TextField" @@ -51,6 +56,11 @@ class FlowField(models.Field): __metaclass__ = models.SubfieldBase + def __init__(self, *args, **kwargs): + if 'null' not in kwargs: + kwargs['null'] = True + super(FlowField, self).__init__(*args, **kwargs) + def get_internal_type(self): return "TextField" diff --git a/samples/django_sample/settings.py b/samples/django_sample/settings.py index df10f0a..ceb4b29 100644 --- a/samples/django_sample/settings.py +++ b/samples/django_sample/settings.py @@ -10,12 +10,12 @@ ADMINS = ( MANAGERS = ADMINS -DATABASE_ENGINE = 'sqlite3' -DATABASE_NAME = 'database.sqlite3' -DATABASE_USER = '' -DATABASE_PASSWORD = '' -DATABASE_HOST = '' -DATABASE_PORT = '' +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'mydatabase' + } + } # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -53,9 +53,8 @@ SECRET_KEY = '_=9hq-$t_uv1ckf&s!y2$9g$1dm*6p1cl%*!^mg=7gr)!zj32d' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', ) MIDDLEWARE_CLASSES = (