Fixed #23915 -- Made sure m2m fields through non-pk to_field are allowed in the admin.

refs #23754, #23862
This commit is contained in:
Simon Charette 2014-11-25 14:27:46 -05:00
parent f9c4e14aec
commit 3a9aa155e2
3 changed files with 21 additions and 12 deletions

View file

@ -855,13 +855,19 @@ class InlineReferer(models.Model):
refs = models.ManyToManyField(InlineReference)
# Models for #23604
# Models for #23604 and #23915
class Recipe(models.Model):
pass
rname = models.CharField(max_length=20, unique=True)
class Ingredient(models.Model):
recipes = models.ManyToManyField(Recipe)
iname = models.CharField(max_length=20, unique=True)
recipes = models.ManyToManyField(Recipe, through='RecipeIngredient')
class RecipeIngredient(models.Model):
ingredient = models.ForeignKey(Ingredient, to_field='iname')
recipe = models.ForeignKey(Recipe, to_field='rname')
# Model for #23839