1) Create New App For Si
python manage.py startapp siapp
2) Create urls.py under app:-
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
3) Create templates folder under app and subfolder using appname and create .html
design form element using Html
<form action="silogic" method="get">
...
</form>
4) edit app url and define logic method
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('silogic', views.silogic, name='silogic'),
]
5 define views.py two method first for load and second for action
def index(request):
return render(request,"appname/htmlfilename")
def silogic(request):
var= request.GET["nameoftextfield"]
return Httpresponse(output)
6 go on project settings.py and write installed_apps section appname (siapp)
7 edit project urls.py and define app
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('add/',include('addapp.urls')),
path('admin/', admin.site.urls),
path('siapp/',include(siapp.urls'))
]
Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
ReplyDeleteMean stack Classes in Chennai
React JS Training Institute in Chennai