We did this quite extensively in our MySQL applications to work with the only limitation of the Django database. Our application has a couple of databases running in a single instance of MySQL. We can make the cross-database model integrate this way while we create the views for each table in the “current” database.
As for the insert / update in the views, in our use cases, the view is basically "select * from [db.table];". In other words, we don't do any complex joins or filtering, so the insert / updates trigger from save () works just fine. If your use case requires such complex joins or advanced filtering, I suspect that you will not have problems with read-only scripts, but there may be a problem with the insert / update. I think that in MySQL there are some basic restrictions that prevent updating views that intersect tables, have complex filters, etc.
In any case, your mileage may change if you use a DBMS other than MySQL, but Django does not care if it sits on top of a physical table or view. It will be an RDBMS that determines whether it really works as you expect. As the previous commentator noted, you are most likely to throw syncdb out of the window, although we successfully worked on it using the post-syncdb signal, which removes the physical table created by Django and runs our "create view ..." command. However, the signal after synchronization is a bit esoteric in the sense in which it is triggered, so also caution emptor.
EDIT: Of course, “postsynchronous signal” means “postsynchronous listener”
Joe Holloway Feb 07 '09 at 2:56 2009-02-07 02:56
source share