I'm trying to read from a text file that contains a bunch of words line by line.
I tried to use this question's solution but I couldn't do it.
This is how I setup my models.py
file:
from django.db import models
class words(models.Model):
wordslist = models.CharField(null='True', max_length=128)
I tried to run this code in the python manage.py shell
:
from app.models import words
WORDLIST_FILENAME = "app/words.txt"
inFile = open(WORDLIST_FILENAME, 'r')
wordlist = []
for line in inFile:
wordlist.append(line.strip().lower()) # wordlist: list of strings
words.objects.create()
This doesn't end up completing and I have to keyboard interrupt. I'm using Django 1.11