Ticket #1844: remove_fields.patch

File remove_fields.patch, 1.7 KB (added by anonymousChris Chamberlin <dja @…>, 19 years ago)

patch to implement remove_fields

  • base.py

     
    5151        # Add Fields inherited from parents
    5252        for parent in new_class._meta.parents:
    5353            for field in parent._meta.fields:
    54                 # Only add parent fields if they aren't defined for this class.
    55                 try:
    56                     new_class._meta.get_field(field.name)
    57                 except FieldDoesNotExist:
    58                     field.contribute_to_class(new_class, field.name)
     54                # Only add parent fields if they aren't defined for this class,
     55                # and haven't been explicitly removed in the derived class
     56                if field.name not in new_class._meta.remove_fields:
     57                    try:
     58                        new_class._meta.get_field(field.name)
     59                    except FieldDoesNotExist:
     60                        field.contribute_to_class(new_class, field.name)
    5961
    6062        new_class._prepare()
    6163
  • options.py

     
    1313
    1414DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
    1515                 'unique_together', 'permissions', 'get_latest_by',
    16                  'order_with_respect_to', 'app_label')
     16                 'order_with_respect_to', 'app_label', 'remove_fields')
    1717
    1818class Options:
    1919    def __init__(self, meta):
     
    2727        self.object_name, self.app_label = None, None
    2828        self.get_latest_by = None
    2929        self.order_with_respect_to = None
     30        self.remove_fields = []
    3031        self.admin = None
    3132        self.meta = meta
    3233        self.pk = None
Back to Top