Locked lesson.
About this lesson
There may be times when you have different Python programs you want to run on your Django project. In this lesson, we'll discuss how to use and import an external file that does something unique into your Django project.
Exercise files
Download this lesson’s related exercise files.
Using External Python Programs.docx57.4 KB Using External Python Programs - Solution.docx
57.7 KB
Quick reference
Using External Python Programs
Django allows you to use external Python programs in your Django project.
When to use
Use them whenever you need to run or use an external Python program in your Django project.
Instructions
Save the python program in your app directory of your Django project. Then, import it into the view where you want to use it.
from resume.program_name import program_function
Then pass the output of the program into your web page in the context dictionary.
Finally, reference the output that you passed through your context dictionary on the actual web page using a variable.
Hints & tips
- from resume.program_name import program_function
Lesson notes are only available for subscribers.