I have a file uploads table and want to have a unique, random code for each file as it is uploaded, so that my fields are id, file, code, where 'code' is generated by a given function (say, for sake of argument, randint(100000,999999)).
Is this something I can do in the model, or do I need a form to call the function as the form is submitted?

