I always thought it was OK to just import all of your modules at the top of a view file. Then if you ever change a model name you can just edit the import at the top and not go digging through every view function that you need it imported in.
Well, I just ran into an instance where I had imported a model at the top of a view file, and then used it in a function, but for some reason django threw an unbound variable error when I tried to use the model to do a query, which leads me to believe that I do need to do my imports for each function?
So, my question is, what is the proper way to do it? Import everything at the top of the file or in each function as needed.
Thanks