django: Admin interface for an extended class
I have two classes for which I want an admin interface. But one class extends the other. Ex
class Questions(models.Model):
p开发者_如何学JAVAass
class MathQuestion(Questions):
some fields ....
Now the simplest way is to create a separate admin for MathQuestion. However, is there a possibility that I can have MathQuestion displayed in a more intuitive fashio in Admin, ex: When user goes to QuestionAdmin interface and selects a further type for Maths.
- Add extra field 'question_type' with default value of
None
and not nullable (so you can be sure Question can't have instances, not sure if it works) - overload the
save
method in child class and assign there some value to question_type, meaning MathQuestion. - Use filtering in admin as always.
精彩评论