You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

proxy.py 699 B

1234567891011121314151617181920212223
  1. """
  2. Field-like classes that aren't really fields. It's easier to use objects that
  3. have the same attributes as fields sometimes (avoids a lot of special casing).
  4. """
  5. from django.db.models import fields
  6. class OrderWrt(fields.IntegerField):
  7. """
  8. A proxy for the _order database field that is used when
  9. Meta.order_with_respect_to is specified.
  10. """
  11. def __init__(self, *args, **kwargs):
  12. kwargs['name'] = '_order'
  13. kwargs['editable'] = False
  14. super(OrderWrt, self).__init__(*args, **kwargs)
  15. def deconstruct(self):
  16. name, path, args, kwargs = super(OrderWrt, self).deconstruct()
  17. del kwargs['editable']
  18. return name, path, args, kwargs