Skip to content

ManyToMany class

edgy.ManyToManyField

Bases: ForeignKeyFieldFactory

get_column_type classmethod

get_column_type(**kwargs)

Returns the propery column type for the field

PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/many_to_many.py
76
77
78
79
@classmethod
def get_column_type(cls, **kwargs: Any) -> Any:
    """Returns the propery column type for the field"""
    return None

get_constraints classmethod

get_constraints(**kwargs)
PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/many_to_many.py
81
82
83
@classmethod
def get_constraints(cls, **kwargs: Any) -> Any:
    return []

__new__

__new__(to, *, through=None, **kwargs)
PARAMETER DESCRIPTION
to

TYPE: Union[Model, str]

through

TYPE: Optional[Model] DEFAULT: None

**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/many_to_many.py
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
def __new__(  # type: ignore
    cls,
    to: Union["Model", str],
    *,
    through: Optional["Model"] = None,
    **kwargs: Any,
) -> BaseField:
    null = kwargs.get("null", None)
    if null:
        terminal.write_warning("Declaring `null` on a ManyToMany relationship has no effect.")

    kwargs = {
        **kwargs,
        **{key: value for key, value in locals().items() if key not in CLASS_DEFAULTS},
    }
    kwargs["null"] = True
    return super().__new__(cls, **kwargs)

validate classmethod

validate(**kwargs)
PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/many_to_many.py
222
223
224
225
226
227
228
229
@classmethod
def validate(cls, **kwargs: Any) -> None:
    related_name = kwargs.get("related_name", None)

    if related_name:
        assert isinstance(related_name, str), "related_name must be a string."

    kwargs["related_name"] = related_name.lower() if related_name else None