[damned-lies] Set file_hashes default to '' so as field always returns a dict (and not None)



commit 7ec3ff192206dbdcd0c991a1b7ec8da84a243e7f
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Oct 23 12:05:17 2010 +0200

    Set file_hashes default to '' so as field always returns a dict (and not None)

 stats/migrations/0004_add_file_hashes.py |    4 ++--
 stats/models.py                          |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/stats/migrations/0004_add_file_hashes.py b/stats/migrations/0004_add_file_hashes.py
index dcb794f..b6e3e33 100644
--- a/stats/migrations/0004_add_file_hashes.py
+++ b/stats/migrations/0004_add_file_hashes.py
@@ -9,7 +9,7 @@ class Migration(SchemaMigration):
     def forwards(self, orm):
         
         # Adding field 'Branch.file_hashes'
-        db.add_column('branch', 'file_hashes', self.gf('common.fields.DictionaryField')(null=True, blank=True), keep_default=False)
+        db.add_column('branch', 'file_hashes', self.gf('common.fields.DictionaryField')(default='', blank=True), keep_default=False)
     
     
     def backwards(self, orm):
@@ -75,7 +75,7 @@ class Migration(SchemaMigration):
         },
         'stats.branch': {
             'Meta': {'unique_together': "(('name', 'module'),)", 'object_name': 'Branch', 'db_table': "'branch'"},
-            'file_hashes': ('common.fields.DictionaryField', [], {'null': 'True', 'blank': 'True'}),
+            'file_hashes': ('common.fields.DictionaryField', [], {'default': "''", 'blank': 'True'}),
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
             'module': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['stats.Module']"}),
             'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
diff --git a/stats/models.py b/stats/models.py
index 410b6c8..bda2667 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -159,7 +159,7 @@ class Branch(models.Model):
     vcs_subpath = models.CharField(max_length=50, null=True, blank=True)
     module      = models.ForeignKey(Module)
     weight      = models.IntegerField(default=0, help_text="Smaller weight is displayed first")
-    file_hashes = DictionaryField(null=True, blank=True)
+    file_hashes = DictionaryField(default='', blank=True)
     # 'releases' is the backward relation name from Release model
 
     # May be set to False by test suite



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]