python - Subclasses in Django databases -
if have
class foo(models.model): widgets = models.foreignkey('widgets.widget', related_name='widgets') i want save subclass, xwidget of widget database. ok, though foo.widgets of widget parent class not xwidget?
when reading foo.widgets, if want find xwidgets filter way this?
cheers
yes, may save subclass foreign key referencing parent, because xwidget is-a widget. won't work in reverse, though. instance, if foreign key 'widgets.xwidget', couldn't save widget it.
Comments
Post a Comment