create website with django !

 


1)pip3 install Django==2.2.12

2)python3 manage.py migrate

3)python3 manage.py {command}

4) python3 manage.py runserver 

5)python3 manage.py createsuperuser

6)IP:8000/admin  

create an app (directory) : 

1)python manage.py startapp polls

    2)in views.py :
 
 
    from django.http import HttpResponse

    
    def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")
    3)create urls.py : 
    from django.urls import path

    from . import views

    urlpatterns = [
    path('', views.index, name='index'),
    ]
 
    4)edit urls.py in websiteproject : 
  
    from django.contrib import admin     from django.urls import include, path     urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls),     ]

    5)/polls is added congrats !!!!

 

 


 

Commentaires

Articles les plus consultés