I have a Django function "get_data_from_text_file()" that I want to test run from the command line. I tried:
>>> import v1.views
>>> get_data_from_text_file("kk")
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'get_data_from_text_file' is not defined
Why is it not defined if its imported sucessfully?
Django loaddata is a command used for pre-populating database with data, especially during the development phase. Data is loaded from fixture files that represent serialized data. Django dumpdata is a command used for dumping data from database to fixture files. Output from dumpdata can be in various file formats.
First of all make sure you're using manage.py shell
and not plain python
in the command line to make this test.
You're not importing the get_data_from_text_file function, but all the view. You could either use:
v1.views.get_data_from_text_file("kk")
or try to do the import like this:
from v1.views import get_data_from_text_file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With