{"id":16555,"date":"2021-11-23T02:37:41","date_gmt":"2021-11-22T18:37:41","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=16555"},"modified":"2026-03-03T13:20:07","modified_gmt":"2026-03-03T05:20:07","slug":"django-and-tej-api-part-1","status":"publish","type":"insight","link":"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/","title":{"rendered":"Django and TEJ API (Part 1)"},"content":{"rendered":"\n<p>Use Python Django to create a website<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized caption-align-center\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_0rcl-SRYzHWC8d_MG.jpg\" alt=\"\" width=\"841\" height=\"600\"\/><figcaption class=\"wp-element-caption\">Photo by\u00a0<a href=\"https:\/\/unsplash.com\/@kmuza?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Carlos Muza<\/a>\u00a0on\u00a0<a href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noreferrer noopener\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a10e44dc4cd6\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a10e44dc4cd6\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Highlights\" >Highlights<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Preface\" >Preface<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#The_Editing_Environment_and_Modules_Required\" >The Editing Environment and Modules Required<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Virtual_Environment\" >Virtual Environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Start_a_Project\" >Start a Project<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Add_a_New_Application_app\" >Add a New Application (app)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Extended_Reading\" >Extended Reading<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/django-and-tej-api-part-1\/#Related_Link\" >Related Link<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"4187\"><span class=\"ez-toc-section\" id=\"Highlights\"><\/span>Highlights<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Difficulty\uff1a\u2605\u2606\u2606\u2606\u2606<\/li>\n\n\n\n<li>Django development setting<\/li>\n\n\n\n<li>Advice: This series of articles aims to introduce the common application of Django modules and how it can be used with TEJ API database. Thus, we\u2019ll not dive into the detailed functions or the knowledge of a webpage\u2019s front-end and back-end. If readers are interested in what was mentioned above, you can refer to this&nbsp;<a href=\"https:\/\/tutorial.djangogirls.org\/en\/\" rel=\"noreferrer noopener\" target=\"_blank\">document<\/a>, which explains the details quite well<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"f185\"><span class=\"ez-toc-section\" id=\"Preface\"><\/span>Preface<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"6bb4\">Django is a Python-based application framework of web. Since it has advantages such as fixed framework and abundant libraries, users can develop a website in a more straightforward and efficient way.<\/p>\n\n\n\n<p id=\"28c6\">In this series, we\u2019ll cover the topics including the setting of Django, framework introduction, connection of TEJ API database, creation of back-end database, the usage of css and js and converting django project to exe file. We\u2019ll guide the readers step by step to build something like the picture shown below. And in this week, we are going to elaborate how to set Django development environment properly to avoid annoying errors in the future.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_12v20XPqYaogJocXs3hiaVQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ea2b\"><span class=\"ez-toc-section\" id=\"The_Editing_Environment_and_Modules_Required\"><\/span>The Editing Environment and Modules Required<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"7570\">Windows OS and Visual Studio<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6fdd\"><span class=\"ez-toc-section\" id=\"Virtual_Environment\"><\/span>Virtual Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"7e55\"><strong>Step 1.\u00a0Enter into Visual Studio and open newly-created file (medium)<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1m71tR0CCqF_pl2p_a6l_vQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3784\"><strong>Step 2.\u00a0Add a terminal and type\u00a0<code>python -m venv (your_env_name)<\/code>\u00a0to create a virtual environment. The purpose of this step is to avoid different versions of modules might have some conflicts and some errors will somehow occur.<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1OU440J_0HIm3tUdSfhdduA.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"c17a\"><strong>Step 3.Type<code>(your_env_name)\\Scripts\\activate<\/code>\u00a0to enter into virtual environment. If there\u2019s green word showing up, meaning you are correctly in a virtual environment. Then you can start to install Django module by using pip.\u00a0Remember each time you go into this project and install any modules, you should always enter the virtual environment first.<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1hxzZpBIC_iarxijRkeIPew.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"9025\"><span class=\"ez-toc-section\" id=\"Start_a_Project\"><\/span>Start a Project<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"7995\"><strong>Step 1.\u00a0Type\u00a0<code>django-admin.py startproject (your_project_name)<\/code>in terminal. The a project file (finance) will occur under the project file(medium). The current structure of files is shown on the left hand side<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_12Ws3SXXGvmSGqWRm9ay5yA.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"48f8\"><strong>Step 2.\u00a0Move to the project file and type\u00a0<code>python manage.py runserver (port)<\/code>, which will activate a simple web server. The port is set 8000 by default and you can change it according to your perference<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_15neOSlDRRRDg90L60Jl7VQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"0d02\"><strong>Step 3.\u00a0Click the link and you can see it\u2019s successfully launched<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_19svGoM4Y9hO5mKzcvxe91A.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c59d\"><span class=\"ez-toc-section\" id=\"Add_a_New_Application_app\"><\/span>Add a New Application (app)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"ddb5\">When the project is complicated, we usually divide it into different applications. Thus, we also need some applications under the project file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4580\"><strong>Step 1.\u00a0If you don\u2019t want to terminate the web server, you can add another terminal and make sure you\u2019re in virtual environment by identifying the green words. Next, move to project file and type\u00a0<code>python manage.py startapp dashboard\u00a0<\/code>to create your first app. Here we name it as dashboard, and then the app file (dashboard) will show up right under the project file (finance)<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1UqmHUptNhwHuhnfDfforJg.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"e6d0\"><strong>Step 2.\u00a0To notify Django that the new app should also be under control, we need to add something in setting file. The setting file is called setting.py and located in \u201cfinance\\finance\\settings.py\u201d.\u3002Then find the INSTALLED_APPS block and add your app name at the end of the list.<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1JzUgvaRT8A6UkmHeATGyHg.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"0f52\"><strong>Step 3.\u00a0Current structure of the project<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">finance<br>\u251c\u2500\u2500 manage.py<br>\u251c\u2500\u2500 finance<br>\u2502   \u251c\u2500\u2500 __init__.py<br>\u2502   \u251c\u2500\u2500 settings.py<br>\u2502   \u251c\u2500\u2500 urls.py<br>\u2502   \u2514\u2500\u2500 wsgi.py<br>\u2514\u2500\u2500 dashboard<br>    \u251c\u2500\u2500 __init__.py<br>    \u251c\u2500\u2500 admin.py<br>    \u251c\u2500\u2500 migrations<br>    \u251c\u2500\u2500 models.py<br>    \u251c\u2500\u2500 tests.py<br>    \u2514\u2500\u2500 views.py<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"a0d1\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"a0e3\">This article mainly introduces how to set Django development environment, such as virtual environment, project and applications. Some details shouldn\u2019t be ignored like entering into virtual environment, familiar with project structure and change of setting file. Otherwise, it will trigger many problems. That\u2019s why we write this article to make sure everything is in place, and then we can start to build our finance-related webpage in our next article !<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"14d9\"><span class=\"ez-toc-section\" id=\"Extended_Reading\"><\/span>Extended Reading<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/build-your-own-company-dashboard\/\" class=\"ek-link\">Build Your Own Company Dashboard<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/xgboost-algorithm-predicts-returns-part-1\/\" class=\"ek-link\">XGBoost Algorithm Predicts Returns (Part 1)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2ad8\"><span class=\"ez-toc-section\" id=\"Related_Link\"><\/span>Related Link<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/api.tej.com.tw\/index.html\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_intro\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ E-Shop<\/a><\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Use Python Django to create a website Highlights Preface Django is a Python-based application framework of web. Since it has advantages such as fixed framework and abundant libraries, users can develop a website in a more straightforward and efficient way. In this series, we\u2019ll cover the topics including the setting of Django, framework introduction, connection [&hellip;]<\/p>\n","protected":false},"featured_media":16556,"template":"","tags":[3176,3007],"insight-category":[690,50,3509],"class_list":["post-16555","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-python-2","tag-tejapi-data-analysis","insight-category-data-analysis","insight-category-fintech","insight-category-fintech-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight\/16555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/types\/insight"}],"version-history":[{"count":2,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight\/16555\/revisions"}],"predecessor-version":[{"id":44098,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight\/16555\/revisions\/44098"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/media\/16556"}],"wp:attachment":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/media?parent=16555"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/tags?post=16555"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight-category?post=16555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}