I have manually imported data (via a .csv file) into a database, how can I now connect the values imported into the database to a Django model so that I could then reference the data via application logic? (i.e. Model.objects.all().values('field')
)
I know that this is the opposite of the standard process and as a result, I have been able to find no references to this process online.
I would like to be able to call Model.objects.all().values('field')
and display a column of the csv that I imported into the database.
My model format is a Geodjango based model with environmental data mapped to it. The shp file is too large to directly sync with the proxy database I am using (it would take an estimated 300+ days) so I transferred the values to a csv and imported the csv directly into the assigned model table in the database. However, when using the Django shell I can see that the values of the csv were not synced with the models despite being imported to the same table.
I wasted 50 reps on this question. Easy fix, just took me a day to figure it out. My CSV was not being properly imported but I was not receiving any error messages from the managed database I was importing to (Google Cloud). Once I ran some tests to confirm, I noticed nothing was imported. I then just reformatted and imported the file and everything was in sync and ran smoothly. No need for any obscure Django commands or writing custom commands for syncing with databases in unique circumstances. Just plain old csv formatting issues. Great.