How can I delete a RelationValue from a dx content type object?

Hi,

I have an object and there is a relation set to another object. I used a Relation Choice field in dexterity.
How can I remove the relation using code so that I would be able to delete the related object?

My current code looks like:

    obj = brain.getObject()
    obj.rel = None
    notify(ObjectModifiedEvent(obj))

This seems to work, but I was wondering if there is a better way.

thx

This looks fine.

1 Like

Plone Foundation Code of Conduct