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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -