Helper function that actually processes and saves the upload(s).
    Segregated out for readability.

def process_upload(photo_list, form, parent_object, user, status=''):
    """
    Helper function that actually processes and saves the upload(s).
    Segregated out for readability.
    """
    status += "beginning upload processing. Gathering and normalizing fields....<br>"

    for upload_file in photo_list:
        # lowercase and replace spaces in filename
        upload_file.name = upload_file.name.lower().replace(' ', '_')
        upload_name = upload_file.name

        status += """
           File is {}.
           Checking for single file upload or bulk upload... <br>
           """.format(upload_name)
        if upload_name.endswith('.jpg') or upload_name.endswith('.jpeg'):
            status += "Found jpg. Attempting to save... <br>"
            try:
                dupe = ArticleImage.objects.get(photo__contains=upload_name, article=parent_object)
            except ObjectDoesNotExist:
                dupe = None
            if not dupe:
                try:
                    upload = ArticleImage(
                        article=parent_object,
                        photo=upload_file
                    )
                    upload.save()
                    status += "Saved and uploaded jpg."
                except Exception as error:
                    status += "Error saving image: {}".format(error)
        time.sleep(1)
    return status