MCPcopy
hub / github.com/django/django / contribute_to_class

Method contribute_to_class

django/db/models/fields/__init__.py:1558–1574  ·  view source on GitHub ↗
(self, cls, name, **kwargs)

Source from the content-addressed store, hash-verified

1556 return super().pre_save(model_instance, add)
1557
1558 def contribute_to_class(self, cls, name, **kwargs):
1559 super().contribute_to_class(cls, name, **kwargs)
1560 if not self.null:
1561 setattr(
1562 cls,
1563 "get_next_by_%s" % self.name,
1564 partialmethod(
1565 cls._get_next_or_previous_by_FIELD, field=self, is_next=True
1566 ),
1567 )
1568 setattr(
1569 cls,
1570 "get_previous_by_%s" % self.name,
1571 partialmethod(
1572 cls._get_next_or_previous_by_FIELD, field=self, is_next=False
1573 ),
1574 )
1575
1576 def get_prep_value(self, value):
1577 value = super().get_prep_value(value)

Callers

nothing calls this directly

Calls 1

contribute_to_classMethod · 0.45

Tested by

no test coverage detected