craigds/django-typed-models

Allow for custom field name rather than `type`

Opened this issue · 2 comments

One limitation of this library as written today is that it reserves type as a field to hold the model type. When migrating an existing codebase in which type is already reserved, this causes difficulties.

It would be great if there were a way to specify a different field to use to store the polymorphic type in the database.

jwtnb commented

any luck on this?

I'd probably consider making a change to the name to make it less likely to collide with other apps, e.g. dtm_type - such a change wouldn't cause too much drama, it's not hard to migrate the field to a new name.

At the same time perhaps we should change it to be a content-type foreign key rather than a app.model string. So the actual db column would be dtm_type_id I guess.

I don't want to make the field name chooseable; my experience with django-mptt is that it leads to a horribly messy codebase.