From: David Kerkeslager Date: Fri, 4 Mar 2022 15:18:53 +0000 (-0500) Subject: Admin interface for nutrition and training X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=dd2225e0e296d6c6a5f37d75242abaaeb4c3db33;p=climbing.kerkeslager.com Admin interface for nutrition and training --- diff --git a/src/nutrition/admin.py b/src/nutrition/admin.py index 8c38f3f..3ce2535 100644 --- a/src/nutrition/admin.py +++ b/src/nutrition/admin.py @@ -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 index 0000000..fec2f88 --- /dev/null +++ b/src/nutrition/migrations/0002_name_and_brand_as_char_fields.py @@ -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), + ), + ] diff --git a/src/nutrition/models.py b/src/nutrition/models.py index ba7d415..67ccd61 100644 --- a/src/nutrition/models.py +++ b/src/nutrition/models.py @@ -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) diff --git a/src/training/admin.py b/src/training/admin.py index 8c38f3f..17b01e6 100644 --- a/src/training/admin.py +++ b/src/training/admin.py @@ -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 index 0000000..308cc30 --- /dev/null +++ b/src/training/migrations/0002_notes_not_required.py @@ -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), + ), + ] diff --git a/src/training/models.py b/src/training/models.py index 618588d..238b40e 100644 --- a/src/training/models.py +++ b/src/training/models.py @@ -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