This a great solution to this problem, one I've found to be very common in web development. The technique will work to add RI to Django's generic foreign keys[1], which are implemented with an id column and a type-flag column.
[1]: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations