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 :: how to make a window with tkinter 
Python :: preprocessing data in python 
Python :: list of list to numpy array 
Python :: python get colorscale 
Python :: expanding nebula foobar 
Python :: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at 
Python :: what are postcondition errors in python 
Python :: sample adaboost classifier algorithm 
Python :: Python __floordiv__ magic method 
Python :: python trace code execution 
Python :: python pop a element by index 
Python :: python json change line 
Python :: how i get url value in get_queryset function in drf 
Python :: #add,remove and clear all values on set in python 
Python :: getch backspace pytohn 
Python :: how to get index in python 
Python :: s=0 def sum(x,y): n=int(input("enter no. of terms") for i in range(n): l=int(input("enter no.")) s=s+l print(s) sum() 
Python :: how to python string up 
Python :: python find cells with na 
Python :: streamlit format_func example 
Python :: pandas select only columns with na 
Python :: how to stop python for some time in python 
Python :: numpy percentile 
Python :: what is an object in python 
Python :: enum python print all options 
Python :: rename last layer of keras model 
Python :: display column names as a dictionary pandas 
Python :: number length python 
Python :: python logging repeated messages 
Python :: color module python 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =