unsaved related object fix #1551

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

Projects

None yet

1 participant

@phillxnet
Contributor

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
Contributor

Having a quick look at this one now.

@phillxnet phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Nov 29, 2016
@phillxnet phillxnet save pool object as django 1.8 more strict #1551
Akin to an earlier change in disk.py but this time in
pool.py
560bd92
@phillxnet
Contributor

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 schakrava added a commit that referenced this issue Nov 30, 2016
@phillxnet @schakrava phillxnet + schakrava save pool object as django 1.8 more strict #1551
Akin to an earlier change in disk.py but this time in
pool.py
f01345b
@schakrava schakrava added a commit that referenced this issue Nov 30, 2016
@schakrava schakrava Remove redundant save(). #1551
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
035ed73
@phillxnet
Contributor

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

@phillxnet phillxnet closed this Nov 30, 2016
@schakrava schakrava changed the title from django save issue in testing channel to 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