Added JSON field to animal model.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Aug 2015 18:57:45 +0000 (20:57 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Aug 2015 18:57:45 +0000 (20:57 +0200)
animals/admin.py
animals/migrations/0002_animal_properties.py [new file with mode: 0644]
animals/models.py

index 618797ec8d4b3b08b33557680860dbbcab1c6b7b..5518bd898bb9758cc6e7c7bc35e29e4bd8a37b67 100644 (file)
@@ -3,7 +3,7 @@ from .models import Animal
 
 
 class AnimalAdmin(admin.ModelAdmin):
-    list_display = ('name_german', 'size_cm')
+    list_display = ('name_german', 'size_cm', 'properties')
 
 
 # Register your models here.
diff --git a/animals/migrations/0002_animal_properties.py b/animals/migrations/0002_animal_properties.py
new file mode 100644 (file)
index 0000000..ff47c07
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import jsonfield.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('animals', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='animal',
+            name='properties',
+            field=jsonfield.fields.JSONField(null=True),
+        ),
+    ]
index 72568d1321e0d7479fa5cc206786a104428b8b07..cc4abdcce8f5ff473323bee1d92a911bbf7b818b 100644 (file)
@@ -1,11 +1,12 @@
 from django.db import models
+import jsonfield # https://github.com/bradjasper/django-jsonfield (7f87e68f)
 
-# Create your models here.
 
 class Animal(models.Model):
     name_german = models.CharField(max_length=255)
     size_cm = models.IntegerField()
     edible = models.BooleanField()
+    properties = jsonfield.JSONField(null=True)
 
     def __str__(self):
         return self.name_german