EDITED in response to comments and answers:
I am new to django and web development and I feel like I'm missing something basic about how to use django views.
I have a django app that I set up following the instructions in the django tutorial: here. Specifically, I end up with the autogenerated directory and file structure described there:
mysite/
manage.py
settings.py
urls.py
myapp/
models.py
views.py
templates/
*.html
static/
*.css
In my app I receive some user input from a template form and save it in my model in a function in views.py.
Before doing this I want to run some functions to check the input - depending on what it is I decide whether or not and where to put it in the database and also what content to display to the user next.
For example, one thing I want to do is check whether the words that were input are in the dictionary. I have a word list in a text file and I want to check whether the words from the input are in that list.
I want to be able to do something like:
wordlist = set(w.strip() for w in open(filename).readlines())
Where should I put this text file and how can I refer to it (in order to open it) in views.py? Where should I put that line of code - is there a way to only make this set once and then access it whenever any user submits input?
Note that I tried just putting the text file in myapp/ and then doing open(filename) but I get an error:
IOError No such file or directory.
I also tried to put the file in static/ and then do open(STATIC_URL + filename) but I get an error:
NameError Name 'STATIC_URL' is not defined.
However I do have from django.contrib import staticfiles so it should be defined.