Spaces:
Build error
Build error
Download tecnicas/utils/general_controllers.py from chartManD/cata_system: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/spaces/chartManD/cata_system/resolve/main/tecnicas/utils/general_controllers.py
- Command line
-
hf download hf://spaces/chartManD/cata_system/tecnicas/utils/general_controllers.py
-
curl -L -o general_controllers.py https://huggingface.co/spaces/chartManD/cata_system/resolve/main/tecnicas/utils/general_controllers.py
666 Bytes
| from django.shortcuts import redirect | |
| from django.urls import reverse | |
| from urllib.parse import urlencode | |
| def getId(value: object | int) -> int | None: | |
| if isinstance(value, int): | |
| return value | |
| elif hasattr(value, "id"): | |
| return value.id | |
| elif hasattr(value, "pk"): | |
| return value.pk | |
| return None | |
| def noValidTechnique(params: dict, query_params: dict, name_view: str): | |
| if query_params: | |
| query_string = urlencode(query_params) | |
| url_redireccion = f"{reverse(name_view, kwargs=params)}?{query_string}" | |
| else: | |
| url_redireccion = f"{reverse(name_view, kwargs=params)}" | |
| return redirect(url_redireccion) | |