Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Create Simple Interest Program in Django:-


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'))


 ]


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post