On Oct 7, 2009, at 2:30 AM, Geobase Isoscale wrote: > I intend to write ORM code that will create views and triggers in > the database? Which parts of the source code should I alter?
Django can work just fine with views and triggers, but the Django ORM layer will not create them for you. Views tend to be extremely database-specific, and triggers even more so. In the case of views, you can create them using the database's native view creation mechanism, and then set up a Django model to access them, just as if they were a table (in this case, you would not use syncdb to create the tables). If you are using PostgreSQL, you can even set them up to be updatable using the rules system. As long as they can be used just like a table with standard SQL SELECT / INSERT / DELETE, Django should be perfectly happy to access them. In the case of triggers, there's no reason that a database that Django is accessing cannot use triggers. The only thing to keep in mind is that if a trigger modifies a database row that also exists in memory as a model object instance, nothing will cause the model object instance to automatically reflect the changes in the database row, so you might have "cache" consistency problems. So, if what you are asking is, "Can I use the Django ORM to access a database in which I have created views and triggers," the answer is "yes, provided you understand potential interactions." If the question is, "Can the Django ORM create views and triggers in the database through its API," the answer is no. -- -- Christophe Pettus x...@thebuild.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---