In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to quickly deploy Django projects under Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to quickly deploy Django projects under Linux" this article.
Django is an open source Web application framework written by Python. Using Django, Python programmers can easily complete most of the content needed by a formal website with very little code, and further develop a full-function Web service Django itself based on MVC model, that is, Model (model) + View (view) + Controller (controller) design pattern. MVC pattern simplifies subsequent modifications and extensions of the program, and makes it possible to reuse a certain part of the program.
Create Django module pip3 install-I https://pypi.tuna.tsinghua.edu.cn/simple django==2.2.8 upgrade pip tool pip3 install-I https://pypi.tuna.tsinghua.edu.cn/simple-- upgrade pip on the linux platform, use the command to create a Django project django-admin startproject Client to create an app01django-admin startapp app015) write a view function, hello view, modify app01
5.1) modify setting configuration file
Vim / data/pythonProJect/Client/Client/settings.py....# write a * to allow all hosts to access ALLOWED_HOSTS = ["*"] INSTALLED_APPS = ['django.contrib.admin',' django.contrib.auth', 'django.contrib.contenttypes',' django.contrib.sessions', 'django.contrib.messages',' django.contrib.staticfiles', 'app01',] MIDDLEWARE = [' django.middleware.security.SecurityMiddleware' 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', #' django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',' django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',]
5.2) modify the urls.py file of Django configuration
Vim / data/pythonProJect/Client01/Client01/urls.py.from django.contrib import adminfrom django.urls import pathfrom app01 import viewsurlpatterns = [path ('admin/', admin.site.urls), path (' hello/', views.hello),]
5.3) write tests
Cat / data/pythonProJect/Client/app01/views.py.from django.shortcuts import render,HttpResponsedef hello (requests): return HttpResponse (Hello) # Create your views here.
5.4) execute the Django project
Python3 manage.py runserver 0.0.0.0 Django 9000 and above are all the contents of this article entitled "how to quickly deploy Django projects under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.