django-bulk-hooks 0.1.280__tar.gz → 0.1.281__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of django-bulk-hooks might be problematic. Click here for more details.

Files changed (17) hide show
  1. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/PKG-INFO +1 -1
  2. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/queryset.py +32 -2
  3. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/pyproject.toml +1 -1
  4. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/LICENSE +0 -0
  5. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/README.md +0 -0
  6. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/__init__.py +0 -0
  7. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/conditions.py +0 -0
  8. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/constants.py +0 -0
  9. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/context.py +0 -0
  10. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/decorators.py +0 -0
  11. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/engine.py +0 -0
  12. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/enums.py +0 -0
  13. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/handler.py +0 -0
  14. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/manager.py +0 -0
  15. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/models.py +0 -0
  16. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/priority.py +0 -0
  17. {django_bulk_hooks-0.1.280 → django_bulk_hooks-0.1.281}/django_bulk_hooks/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.280
3
+ Version: 0.1.281
4
4
  Summary: Hook-style hooks for Django bulk operations like bulk_create and bulk_update.
5
5
  Home-page: https://github.com/AugendLimited/django-bulk-hooks
6
6
  License: MIT
@@ -1899,7 +1899,22 @@ class HookQuerySetMixin:
1899
1899
  if hasattr(source_obj, field.name):
1900
1900
  value = getattr(source_obj, field.name, None)
1901
1901
  if value is not None:
1902
- setattr(parent_obj, field.name, value)
1902
+ # Handle foreign key fields properly
1903
+ if (
1904
+ field.is_relation
1905
+ and not field.many_to_many
1906
+ and not field.one_to_many
1907
+ ):
1908
+ # For foreign key fields, extract the ID if we have a model instance
1909
+ if hasattr(value, "pk") and value.pk is not None:
1910
+ # Set the foreign key ID field (e.g., loan_account_id)
1911
+ setattr(parent_obj, field.attname, value.pk)
1912
+ else:
1913
+ # If it's already an ID or None, use it as-is
1914
+ setattr(parent_obj, field.attname, value)
1915
+ else:
1916
+ # For non-relation fields, copy the value directly
1917
+ setattr(parent_obj, field.name, value)
1903
1918
  if current_parent is not None:
1904
1919
  for field in parent_model._meta.local_fields:
1905
1920
  if (
@@ -1932,7 +1947,22 @@ class HookQuerySetMixin:
1932
1947
  if hasattr(source_obj, field.name):
1933
1948
  value = getattr(source_obj, field.name, None)
1934
1949
  if value is not None:
1935
- setattr(child_obj, field.name, value)
1950
+ # Handle foreign key fields properly
1951
+ if (
1952
+ field.is_relation
1953
+ and not field.many_to_many
1954
+ and not field.one_to_many
1955
+ ):
1956
+ # For foreign key fields, extract the ID if we have a model instance
1957
+ if hasattr(value, "pk") and value.pk is not None:
1958
+ # Set the foreign key ID field (e.g., loan_account_id)
1959
+ setattr(child_obj, field.attname, value.pk)
1960
+ else:
1961
+ # If it's already an ID or None, use it as-is
1962
+ setattr(child_obj, field.attname, value)
1963
+ else:
1964
+ # For non-relation fields, copy the value directly
1965
+ setattr(child_obj, field.name, value)
1936
1966
 
1937
1967
  # Set parent links for MTI
1938
1968
  for parent_model, parent_instance in parent_instances.items():
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "django-bulk-hooks"
3
- version = "0.1.280"
3
+ version = "0.1.281"
4
4
  description = "Hook-style hooks for Django bulk operations like bulk_create and bulk_update."
5
5
  authors = ["Konrad Beck <konrad.beck@merchantcapital.co.za>"]
6
6
  readme = "README.md"