ContentType for proxy models

50 views
Skip to first unread message

TallFurryMan

unread,
May 26, 2010, 9:25:42 AM5/26/10
to Django users
Hello,

I wrote a model which is not abstract, and from which a few
specialized classes derive:

| class Action( Model ):
| item = ForeignKey( Item )
| # A few other properties
|
| class Move( Action ):
| class Meta:
| proxy = True
|
| class Pick( Action )
| class Meta:
| proxy = True
|

(the foreign key to Item may seem strange, but Actions change their
properties during the life cycle of an Item)

My Action could be abstract, but I'd like to be able to select generic
Actions. Am I correct in creating a non-abstract model for this
purpose?

My derived Actions add specialized interactions with other models, but
I don't need more fields and I want to avoid changing the db when
adding behaviours. Am I correct in creating proxy models for those
specialized Actions?

Consequently, my problem is that I can't restore a Move from an Action
once saved.

I tried to use ContentType, but its manager refers to the base model
and loses the proxy.

I could use a factory to instantiate the derived Actions, but fiddling
with dynamic import doesn't sound right and portable.

There is something I am missing here. Any tip?

Reply all
Reply to author
Forward
0 new messages