Validate, if reference follow the official naming conventions. Throws a ConfigurationError with a hopefully helpful message. If successful, returns the app and the model name. :raises ConfigurationError: If reference is invalid.
(reference: str)
| 146 | ) |
| 147 | |
| 148 | def split_reference(reference: str) -> tuple[str, str]: |
| 149 | """ |
| 150 | Validate, if reference follow the official naming conventions. Throws a |
| 151 | ConfigurationError with a hopefully helpful message. If successful, |
| 152 | returns the app and the model name. |
| 153 | |
| 154 | :raises ConfigurationError: If reference is invalid. |
| 155 | """ |
| 156 | if len(items := reference.split(".")) != 2: # pragma: nocoverage |
| 157 | raise ConfigurationError( |
| 158 | f"'{reference}' is not a valid model reference Bad Reference." |
| 159 | " Should be something like '<appname>.<modelname>'." |
| 160 | ) |
| 161 | return items[0], items[1] |
| 162 | |
| 163 | def init_fk_o2o_field(model: type[Model], field: str, is_o2o: bool = False) -> None: |
| 164 | fk_object = cast( |
nothing calls this directly
no test coverage detected