0% found this document useful (0 votes)
4 views3 pages

Virtual Environment Set Up

Coding

Uploaded by

Ginzil Haman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Virtual Environment Set Up

Coding

Uploaded by

Ginzil Haman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Virtual Environment set Up

Python3 –m venv myvenv

./myvenv/Scripts/activate

Installing Django
pip install django

Starting a project
django-admin startproject project

Starting app inside project


python manage.py startapp app

Creating a Template folder inside project

--Inside settings.py ---- Add app and templates respectively..

- inside urls.py and add the path include. First import include then add Path(‘ ‘, include(‘app.urls’))

from django.contrib import admin


from django.urls import path,include

urlpatterns = [

path('admin/',admin.site.urls),
path('',include('app.urls')),
]

-In app add urls.py file

from django.urls import path


from app import views

urlpatterns = [

path('',views.index,name='index')
]
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
</head>
<body>
<center><h1>WELCOME TO DJANGO WEBSITE</h1></center>
<div class="container">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</div>
</body>
</html>

Adding Path of about and contact in the app. Urls.py

from django.urls import path


from app import views

urlpatterns = [

path('',views.index,name='index'),
path('about',views.about,name='about'),
]

Writing views.

from django.shortcuts import render

# Create your views here.


def index(request):

return render(request, 'index.html')

def about(request):

return render(request, 'about.html')

def contact(request):

return render(request, 'contact.html')


From here I can start playing around with Bootstrap in index.html.. getbootrap.com- navbar and all
that

You might also like