Open command prompt in windows
then in command prompt type d:
and press enter .
and use following commands
To create folder myap -execute the following command:
D:\> mkdir myap
To go myap folder path -execute the following command:
D:\>cd myap
To create a virtual environment for your project, open a new command prompt, navigate to the myap folder where you want to create your project and then execute the following command:-
D:\myap>python -m venv env
In the command prompt, ensure your virtual environment is active, and execute the following command:
D:\myap>env\Scripts\activate
execute the following command to install django.
D:myap>pip install django
run the following command - This will create a myproject
directory in your current directory
D:\myap>django-admin startproject myproject
then go to myproject folder path type following command :-
D:\myap>cd myproejct
To create your app, make sure you’re in the your project directory & type this command:
D:\myap\myproejct>python manage.py startapp hello
That’ll create a directory hello app folder inside my_project folder:
after it open your myap folder inside it you will see my_project folder
D:\mywork\myproejct>python manage.py runserver.
Step 1:- urls.py file code in your app folder :-
from django.urls import path
from .import views
urlpatterns=[
path('',views.index,name='index'),
path('editemp/<int:id>', views.editemp, name='editemp'),
path('updateemp/<str:course>', views.updateemp, name='updateemp'),
]
Step 2:- views.py file code in your app folder:-
from django.shortcuts import render
def index(request):
return render(request, "home.html")
def editemp(request,id):
data={'id':id}
return render(request, "edit.html",data)
def updateemp(request,course):
data={'course':course}
return render(request, "update.html",data)
step 3 :- Create edit.html file in your templates fodler.
{{id}}
Step 4:-
Create update.html file in your templates fodler.
{{course}}
And then run py manage.py runserver in your command prompt or in terminal
And to check editemp url with id
Sign up here with your email
ConversionConversion EmoticonEmoticon