An example of combining Django with pyecharts
Go to the sibling directory of manage.py and run:
py manage.py startapp NLP  
   sitting.py Application:
 
   
# Application definition
# Django 
INSTALLED_APPS = [
    'polls.apps.PollsConfig',# polls 
    'NLP'
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
  
   、 
 
   NLP , views.py, , index 
 
   
from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, world. You're at the NLP index.")
  
   、 URLconf
 
  1、 index URL , urls.py , :
 
   
from django.urls import path
from . import views
urlpatterns = [
    path('', views.index, name='index'),
]
  
   path() :
 
  route( )
 
  route is a criterion for matching URLs (regular expression-like). When Django responds to a request, it starts with the first item in urlpatterns and matches the items in the list in order until it finds a match.
  view (required)
  When Django finds a matching criterion, it calls that particular view function, passing in an HttpRequest object as the first argument, and the "captured"arguments are passed in as keyword arguments.
  name (optional)
  Naming a URL allows you to uniquely refer to it anywhere in Django, especially in templates. This useful feature allows you to change a URL pattern globally by changing only one file.
  kwargs (optional)
  Any number of keyword arguments can be passed to the target view function as a dictionary.
  2. Create the newly created NLP urls module in the root URLconf, open mysit/urls.py, and insert an include() in its urlpatterns module:
   
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
	path('admin/', admin.site.urls),
        path('NLP',include('NLP.urls')),# app NLP url
]
  
    inclde()  URLconfs。  Django   :func:~django.urls.include  ,  URL  ,  URLconf  。
 
   、 
 
   , :
 
   
py manage.py runserver
  
    
 
   
 
   
 
                             
                        
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Django 라우팅 계층 URLconf 작용 및 원리 해석URL 구성(URLconf)은 Django가 지원하는 웹 사이트의 디렉토리와 같습니다.그것의 본질은 URL과 이 URL을 호출할 보기 함수 사이의 맵표입니다. 위의 예제에서는 URL의 값을 캡처하고 위치 매개 변수로...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.