I have a django project where I want to save web scraped data to the database via the django ORM- which will be used in the django app.
The data is currently in the form of JSON -> converted to python dict via json.loads
I setup my model with the narrowest/ most constrained field type possible - (e.g. DecimalField with decimal_places=2 and max_digits=4 for prices)
I naively tried to save the data/values from the relevant keys in the JSON directly to the relevant model field, however, this raised errors due to data format.
It looks like data entered via a form is converted to the relevant python object in the form validation - e.g. a date string '24 May 2015' is converted to a datetime object and the date format validated.
None of this appears to happen when saving directly to a model? (would be good to have my understanding here confirmed?) and so saving '24 May 2015' directly to a DateField in a model produces a format error.
What validation (if any) does Django do when saving to a database directly via the ORM? - Does it just rely on the type checking in the database (so for sqlite this would be nothing but would for postgres)?
Thanks.