I have a django app and I need to import existing data from text files into the new database.
Usually I would do something like this:
for i in lines():
a = Mymodel()
a.field1 = i[0]
a.field2 = i[0]
a.save()
this works fine, but no data validation takes place (except for the matching data type of the fields).
For inputting data via the webinterface, I wrote some ModelForm forms, which do all the data validation for me (in the clean() method). I do know how to populate and validate a form using request.POST as an input, but is it also possible to do the same on python shell? Can I somehow feed my original data into a dict and populate the form with these data?
yes,
in forms.py
in views.py