Hello All,

I have a situation where I would like to combine two fields from two
abstract child classes into a parent class.

class A(model):
    field = MyField()

    class Meta:
        abstract = True

class B(model):
    field = MyField()

    class Meta:
        abstract = True

class C(A, B, model):
    pass


It is stated explicitly in the documentation that this cannot be done,
but I'd like to know if that's necessarily true.

In a class decorator or metaclass which works up class C, the
following can be done:


fields = [f for f in cls._meta.fields if isinstance(f, MyField)]
keep_field = fields.pop()

for field in fields:
    cls._meta.local_fields.remove(field)
del cls._meta._field_name_cache


This seems to work great for me. But I'd like to know what side
effects there might be in working up the internal machinery of the
model class this way. If this is not a good way to remove fields, is
there another?

thanks,

Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to