a few admin changes to make entering data easier

This commit is contained in:
chriscauley 2016-11-03 20:59:40 -04:00
parent 5ac046a715
commit 0ceef46268
5 changed files with 35 additions and 6 deletions

View File

@ -2,5 +2,9 @@ from django.contrib import admin
from cookbook.ingredients.models import Category, Ingredient
admin.site.register(Ingredient)
@admin.register(Ingredient)
class IngredientAdmin(admin.ModelAdmin):
list_display = ("id","name","category")
list_editable = ("name","category")
admin.site.register(Category)

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-11-04 00:50
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ingredients', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='ingredient',
name='notes',
field=models.TextField(blank=True, null=True),
),
]

View File

@ -10,7 +10,7 @@ class Category(models.Model):
class Ingredient(models.Model):
name = models.CharField(max_length=100)
notes = models.TextField()
notes = models.TextField(null=True,blank=True)
category = models.ForeignKey(Category, related_name='ingredients')
def __str__(self):

View File

@ -2,5 +2,9 @@ from django.contrib import admin
from cookbook.recipes.models import Recipe, RecipeIngredient
admin.site.register(Recipe)
admin.site.register(RecipeIngredient)
class RecipeIngredientInline(admin.TabularInline):
model = RecipeIngredient
@admin.register(Recipe)
class RecipeAdmin(admin.ModelAdmin):
inlines = [RecipeIngredientInline]

View File

@ -6,14 +6,15 @@ from cookbook.ingredients.models import Ingredient
class Recipe(models.Model):
title = models.CharField(max_length=100)
instructions = models.TextField()
__unicode__ = lambda self: self.title
class RecipeIngredient(models.Model):
recipes = models.ForeignKey(Recipe, related_name='amounts')
ingredient = models.ForeignKey(Ingredient, related_name='used_by')
amount = models.FloatField()
unit = models.CharField(max_length=20, choices=(
('unit', 'Units'),
('kg', 'Kilograms'),
('l', 'Litres'),
('', 'Units'),
('st', 'Shots'),
))