Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Adding Route In Django

urls.py
from django.urls import path
from . import views
urlpatterns = [
    path('', views.index, name='index'),
    path("second", views.second, name="index")
] 


views.py
def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")
def second(request):
    return HttpResponse("Second line of code that I added")
Comment

Routes In Django

#this is in the urls.py file. The "default" one is locaed in yourprojectname/yourprojectname/urls.py
#for example, djangosite/djangosite/urls.py
#remember you will have more than one of these urls.py files in different folders

from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
]
Comment

PREVIOUS NEXT
Code Example
Python :: models django 
Python :: count pairs with given sum python 
Python :: python functools 
Python :: Yield Expressions in python 
Python :: python 2 
Python :: run python on android 
Python :: windows task scheduler python script 
Python :: dictionary with list as values 
Python :: django for beginners 
Python :: how to run other python files in python 
Python :: how to remove a string in python 
Python :: remove item in dict 
Python :: python nested object to dict 
Python :: python pandas sum of series 
Python :: sum python 
Python :: python numpy delete column 
Python :: Send Axios With Post 
Python :: problem solving with python 
Python :: how do variables work in python 
Python :: floor python 
Python :: setup vs code for python 
Python :: .pop python 
Python :: Python - How To Convert String to ASCII Value 
Python :: Python, variables, Print() advanced, Input(), Variables ,INT, STR, FLOAT, BOOL, Casting 
Python :: input list in function and display column in dataframe python 
Python :: for x in range(1, 10, 3): print(x) 
Python :: transpose([[1],[2],[3]]) 
Python :: d2h recharge plan list 2022 telugu 
Python :: python regex get start end indices for searching word 
Python :: expand array to a certain size python 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =