Turned on the filed attachment to build the function.
Added the new function to upload via ajax a file.
Removed the comment from attachment field in the template.
Created a new model to store uploaded images from form.
Created a new "form" class based on StoredDocs class.
This will make easy to work with the class StoredDocs in our form.
Changed the "attachment" field.
Now in this field we store just the ID of the uploaded file.
This could be changed with a better AJAX call I suppose but for now this is the
better solution I found to upload an image via AJAX.
Importing the new form.
Slightly changed the construction of json_data.
=> TrackForm() has been deleted because has no utility here (form sent via AJAX).
the success = True now is made just after the for loop finishes.
Created a function that manages the saving of the attachment via AJAX.
Changed the django variable according to the new model.
Imported new form from models.
Eliminated attachment field.
This field is now passive in our Engine model and will hold the id of the saved image on the server.
Passing the new form to the template.
Instantiate the new form before passing it to the template.
Changed the call order.
The first function to be called is now AjaxUpload.
Just spacing.
Intead of redirect call another function.
The function is actually a dummy function but can be filled with somejQuery magic
to show some fine "successful green message" or something.
Adding spaces for readability.
The function now accepts an argument.
The argument is supposed to be a must but we have to be sure that if it is not
will be properly escaped by jQuery. <-- TO DO
Check if a valid ID has been passed to the function.