{"id":2531,"date":"2021-11-23T02:37:41","date_gmt":"2021-11-23T02:37:41","guid":{"rendered":"https:\/\/www.tejwin.com\/en\/insights\/django-and-tej-api-part-1\/"},"modified":"2021-11-23T02:37:41","modified_gmt":"2021-11-23T02:37:41","slug":"django-and-tej-api-part-1","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insights\/django-and-tej-api-part-1\/","title":{"rendered":"Django and TEJ API (Part 1)"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Use Python Django to create a website<\/p>\n<figure class=\"wp-block-image is-resized caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"600\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_0rcl-SRYzHWC8d_MG.jpg\" width=\"841\"\/><figcaption class=\"wp-element-caption\">Photo by\u00a0<a class=\"ek-link\" href=\"https:\/\/unsplash.com\/@kmuza?utm_source=medium&amp;utm_medium=referral\" rel=\"noreferrer noopener\" target=\"_blank\">Carlos Muza<\/a>\u00a0on\u00a0<a href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" rel=\"noreferrer noopener\" target=\"_blank\">Unsplash<\/a><\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"4187\">Highlights<\/h2>\n<ul class=\"wp-block-list\">\n<li>Difficulty\uff1a\u2605\u2606\u2606\u2606\u2606<\/li>\n<li>Django development setting<\/li>\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\u00a0<a href=\"https:\/\/tutorial.djangogirls.org\/en\/\" rel=\"noreferrer noopener\" target=\"_blank\">document<\/a>, which explains the details quite well<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"f185\">Preface<\/h2>\n<p class=\"wp-block-paragraph\" 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<p class=\"wp-block-paragraph\" 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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_12v20XPqYaogJocXs3hiaVQ.png\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"ea2b\">The Editing Environment and Modules Required<\/h2>\n<p class=\"wp-block-paragraph\" id=\"7570\">Windows OS and Visual Studio<\/p>\n<h2 class=\"wp-block-heading\" id=\"6fdd\">Virtual Environment<\/h2>\n<h4 class=\"wp-block-heading\" id=\"7e55\"><strong>Step 1.\u00a0Enter into Visual Studio and open newly-created file (medium)<\/strong><\/h4>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1m71tR0CCqF_pl2p_a6l_vQ.png\"\/><\/figure>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1OU440J_0HIm3tUdSfhdduA.png\"\/><\/figure>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1hxzZpBIC_iarxijRkeIPew.png\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"9025\">Start a Project<\/h2>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_12Ws3SXXGvmSGqWRm9ay5yA.png\"\/><\/figure>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_15neOSlDRRRDg90L60Jl7VQ.png\"\/><\/figure>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_19svGoM4Y9hO5mKzcvxe91A.png\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"c59d\">Add a New Application (app)<\/h2>\n<p class=\"wp-block-paragraph\" 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<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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1UqmHUptNhwHuhnfDfforJg.png\"\/><\/figure>\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<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1JzUgvaRT8A6UkmHeATGyHg.png\"\/><\/figure>\n<h4 class=\"wp-block-heading\" id=\"0f52\"><strong>Step 3.\u00a0Current structure of the project<\/strong><\/h4>\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<h2 class=\"wp-block-heading\" id=\"a0d1\">Conclusion<\/h2>\n<p class=\"wp-block-paragraph\" 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<h2 class=\"wp-block-heading\" id=\"14d9\">Extended Reading<\/h2>\n<ul class=\"wp-block-list\">\n<li><a class=\"ek-link\" href=\"\/en\/insight\/build-your-own-company-dashboard\/\">Build Your Own Company Dashboard<\/a><\/li>\n<li><a class=\"ek-link\" href=\"\/en\/insight\/xgboost-algorithm-predicts-returns-part-1\/\">XGBoost Algorithm Predicts Returns (Part 1)<\/a><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"2ad8\">Related Link<\/h2>\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<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<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\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 [\u2026]<\/p>\n","protected":false},"featured_media":2521,"template":"","tags":[70,65],"insight_category":[16],"class_list":["post-2531","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-tej-api","tag-python","insight_category-quant-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/2531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/2521"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=2531"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=2531"},{"taxonomy":"insight_category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight_category?post=2531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}