[Answered ]-Django – can you use the on_delete attribute on a OnetoOneField?

2👍

From the docs:

OneToOneField accepts all of the extra arguments accepted by ForeignKey.

So yes, on_delete should work as you expect.

(If you’re curious you can look at the implementation. You’ll see that OneToOneField is a small subclass of ForeignKey that basically just forces unique to be True.)

Leave a comment