Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsaved related object fix #1551

Closed
phillxnet opened this issue Nov 29, 2016 · 3 comments
Closed

unsaved related object fix #1551

phillxnet opened this issue Nov 29, 2016 · 3 comments

Comments

@phillxnet
Copy link
Member

Thanks to forum member rockmar for reporting this 3.8.15-11 issue. It would seem that in addition to the already altered save order to cater for our new django v 1.8.16 strickter behaviour:
fd59e32
there appears to be a related issue in pool.py:

File "/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py", line 40, in handleexception
yield
File "/opt/rockstor/src/rockstor/storageadmin/views/pool.py", line 268, in post
p.disk_set.add(*disks)
File "/opt/rockstor/eggs/Django-1.8.16-py2.7.egg/django/db/models/fields/related.py", line 750, in add
obj.save()
File "/opt/rockstor/eggs/Django-1.8.16-py2.7.egg/django/db/models/base.py", line 685, in save
"unsaved related object '%s'." % field.name
ValueError: save() prohibited to prevent data loss due to unsaved related object 'pool'.

Please update the following forum thread with this issues resolution:
https://forum.rockstor.com/t/unable-to-create-pools-3-8-15-11-unsaved-related-object/2420

@phillxnet
Copy link
Member Author

Having a quick look at this one now.

phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Nov 29, 2016
Akin to an earlier change in disk.py but this time in
pool.py
@phillxnet
Copy link
Member Author

With the above added p.save() command/commit a pool was successfully created in an identical scenario that had previously reproduced the original reporters error.

schakrava pushed a commit that referenced this issue Nov 30, 2016
Akin to an earlier change in disk.py but this time in
pool.py
schakrava added a commit that referenced this issue Nov 30, 2016
disk_set.add() in the above line implicitly calls save on pool because it's a
ForeignKey. See https://docs.djangoproject.com/en/1.8/ref/models/relations/#django.db.models.fields.related.RelatedManager.add
@phillxnet
Copy link
Member Author

Closing as fixed by #1552 :
f01345b
and:
035ed73

@schakrava schakrava changed the title django save issue in testing channel unsaved related object fix Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant