Please have view support for databases
|Reported by:||benedict.m.holland@…||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I am linking django to a legacy app database with views. The views have primary keys associated with them and can not be synced using the ./managed.py syncdb if and when I need to recreate this db on my test environment. I can create the views with manual sql code but when I run the syncdb command the view doesn't exist and it throws and error saying that the foreign key to this view can not be created because the table doesn't exist.
I think the solution is a signal which is sent directly after the model is saved to the database which would allow me to hook off of it to create the views. Currently the REALLY nasty hack I am doing is creating my own view, subclassing off an unmanaged model which is the view, and after the syncdb running custom sql to create the view. I have to foreign key off of the actual table (not the view) which means that none of the associated view columns are available with that object when I do foreign object referencing in code like: foo.object = object where foo.object is a foreign key. The only work around is to alter every single reference to foo.object to foo.object = View.objects.get() which is prohibitively expensive and could in fact break a lot of stuff.
Change History (6)
comment:1 Changed 5 years ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:2 Changed 5 years ago by aaugustin
- Component changed from ORM aggregation to Database layer (models, ORM)