Admin interface for nutrition and training
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 15:18:53 +0000 (10:18 -0500)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 15:29:57 +0000 (10:29 -0500)
src/nutrition/admin.py
src/nutrition/migrations/0002_name_and_brand_as_char_fields.py [new file with mode: 0644]
src/nutrition/models.py
src/training/admin.py
src/training/migrations/0002_notes_not_required.py [new file with mode: 0644]
src/training/models.py

index 8c38f3f..3ce2535 100644 (file)
@@ -1,3 +1,7 @@
 from django.contrib import admin
 
-# Register your models here.
+from . import models
+
+class FoodAdmin(admin.ModelAdmin):
+    pass
+admin.site.register(models.Food, FoodAdmin)
diff --git a/src/nutrition/migrations/0002_name_and_brand_as_char_fields.py b/src/nutrition/migrations/0002_name_and_brand_as_char_fields.py
new file mode 100644 (file)
index 0000000..fec2f88
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 4.0.3 on 2022-03-04 15:16
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('nutrition', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='food',
+            name='brand',
+            field=models.CharField(max_length=64),
+        ),
+        migrations.AlterField(
+            model_name='food',
+            name='name',
+            field=models.CharField(max_length=64),
+        ),
+    ]
index ba7d415..67ccd61 100644 (file)
@@ -1,6 +1,9 @@
 from django.db import models
 
 class Food(models.Model):
-    name = models.TextField(max_length=64)
-    brand = models.TextField(max_length=64)
+    name = models.CharField(max_length=64)
+    brand = models.CharField(max_length=64)
     calories = models.PositiveIntegerField()
+
+    def __str__(self):
+        return '{} ({})'.format(self.name, self.brand)
index 8c38f3f..17b01e6 100644 (file)
@@ -1,3 +1,7 @@
 from django.contrib import admin
 
-# Register your models here.
+from . import models
+
+class ExerciseAdmin(admin.ModelAdmin):
+    pass
+admin.site.register(models.Exercise, ExerciseAdmin)
diff --git a/src/training/migrations/0002_notes_not_required.py b/src/training/migrations/0002_notes_not_required.py
new file mode 100644 (file)
index 0000000..308cc30
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 4.0.3 on 2022-03-04 15:16
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('training', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='exercise',
+            name='notes',
+            field=models.TextField(blank=True, null=True),
+        ),
+    ]
index 618588d..238b40e 100644 (file)
@@ -2,4 +2,7 @@ from django.db import models
 
 class Exercise(models.Model):
     name = models.CharField(max_length=64)
-    notes = models.TextField()
+    notes = models.TextField(blank=True, null=True)
+
+    def __str__(self):
+        return self.name