We are migrating our intranet application and have decided to choose the Django framework. We control all of our database via source control and managed scripts, so we do not use the migrate
feature to create tables for us. Views and Tables can change, all business logic is held in the database.
I want to make Django API endpoint which is basically select * from my_table_or_view;
and Django can return a JSON response with the column names and values. Some database tables have close to 100 columns each so I don't want to write out each and every field name and type just to return a query. What happens if we add another column to the view - will I have to update it in Django as well? What if I change the column type - will my application fail as well?
The frontend is written in VueJS - it makes a request to the API endpoint and should use the columns selected in the frontend, obviously if I remove a column it will break but I don't want to have to add the column in the django framework even if it is not used.
I've read the raw SQL queries section of the docs but i'm not sure where this applies to. Does this logic sit in the views section?
I've tried directing a URL endpoint in URLS.py
to a custom class in views.py
but not sure this is correct, does this logic need to be in a serializer?
I'd like the simplest method possible, potentially not using models, just raw SQL is fine.