diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-10-02 19:06:05 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-05 10:51:52 +0100 |
commit | a9724939bde8190cd703cfb3491a4374f92e9a40 (patch) | |
tree | 6e7d9806c603b930c1fdf491c98168b37df812b1 /ishtar_common/utils.py | |
parent | 443e6592b9a6ea77feeccc9a9cdd7d3e81bd45aa (diff) | |
download | Ishtar-a9724939bde8190cd703cfb3491a4374f92e9a40.tar.bz2 Ishtar-a9724939bde8190cd703cfb3491a4374f92e9a40.zip |
✨ import sheet
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 0f4e7ecd6..1a7fecba4 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -1239,11 +1239,15 @@ def get_all_field_names(model): ) -def get_all_related_m2m_objects_with_model(model): +def get_all_related_m2m_objects_with_model(model, related_name=None): + for f in model._meta.get_fields(include_hidden=True): + if f.many_to_many and f.auto_created: + print(f.related_name) return [ (f, f.model if f.model != model else None) for f in model._meta.get_fields(include_hidden=True) - if f.many_to_many and f.auto_created + if f.many_to_many and f.auto_created and + (not related_name or f.related_name.startswith(related_name)) ] |