In this tutorial im going to share how to create url and call the page in Django. I have mentioned in very easy way so follow this tutorial.
Go to inside project and create below folders
mkdir static
mkdir template
Next go to settings.py and put below code
'DIRS': [BASE_DIR,'template'],
Next to put belw code
STATICFILES_DIRS = [
BASE_DIR / "static",
"/var/www/static/",
]
Next go to template folder and put below file
base.html
Next go to views.py and put below code
def home(request):
# return HttpResponse("Hey I am a Developer")
return render(request,'base.html')
Next go to urls.py file and put below code
from django.contrib import admin
from django.urls import path
from myProject.myApp.views import home # Import the home view function
urlpatterns = [
path('', home, name="home"), # Map the root URL to the home view function
path('admin/', admin.site.urls),
]
Next run below code
python manage.py runserver