1

This is the situation:

models.py:

class Question(models.Model):
    text = models.charField(max_length=200)

class Choice(models.Model):
    question = models.foreignKey(Question)
    option = models.charField(max_length=75)

admin.py

class ChoiceAdminInline(admin.stackedInline):
    model = Choice

class QuestionAdmin(admin.ModelAdmin):
    inlines = [ChoiceAdminInline]

In the admin, choices are displayed in an inline list below the question. Adding a new choice works fine, but deleting a choice removes the choice and also the question, which is unexpected. Deleting the choice in the Django shell only deletes the choice. Am I missing something about the behavior of inline admin elements?

I'm using Grappelli and Django 1.7. Upgrading Django isn't an option at the moment.

bill__
  • 101
  • 1
  • 4
  • Just for the sake of clarity, when you're deleting a `Choice` in the admin panel, you're clicking the checkbox of the item you want to delete, then you're hitting the "save" button on the `Question` model, right? – themanatuf Feb 19 '16 at 21:05
  • 1
    Thanks. Your question sparked a moment of clarity. I was clicking the 'X' at the end of the row and then clicking delete, when I should have been just clicking save and continue or just save. The admin's UX needs some work. – bill__ Feb 19 '16 at 21:12

0 Answers0