mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-01-30 19:24:08 +03:00
a few admin changes to make entering data easier
This commit is contained in:
parent
5ac046a715
commit
0ceef46268
|
@ -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)
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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'),
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue
Block a user