-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues
Does this issue exist in the latest version?
- I'm using the latest release
Describe the bug?
it raises an exception when i try to clone an object which has one GeneratedField
To Reproduce
I have some object with some generated field.
with the following script,
cloned = my_obj.make_clone(
attrs={
"phone": phone_number_formatted,
}
)
it fails:
...
web-1 | File "/usr/local/lib/python3.13/contextlib.py", line 85, in inner
web-1 | return func(*args, **kwds)
web-1 | File "/usr/local/lib/python3.13/site-packages/model_clone/mixin.py", line 277, in make_clone
web-1 | duplicate = self._create_copy_of_instance(self, using=using, parent=parent)
web-1 | File "/usr/local/lib/python3.13/site-packages/model_clone/mixin.py", line 396, in _create_copy_of_instance
web-1 | f.pre_save(new_instance, add=True)
web-1 | ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
web-1 | File "/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py", line 990, in pre_save
web-1 | return getattr(model_instance, self.attname)
web-1 | File "/usr/local/lib/python3.13/site-packages/django/db/models/query_utils.py", line 224, in __get__
web-1 | raise AttributeError(
web-1 | "Cannot read a generated field from an unsaved model."
web-1 | )
What OS are you seeing the problem on?
macOS
Expected behavior?
it should filter out the generatedfield
Relevant log output
Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working