[Answered ]-Pulling data from uploaded text file into django database

2👍

Assuming your model looks something like this:

models.py

class MyModel(models.Model):
    fileData = models.TextField()

views.py

def handle_uploaded_file(file, filename):
    for s in file.read().split(','):
        myobject = MyModel(fileData=s)
        myobject.save()              
👤Ryan W

Leave a comment