django-admin startproject mysite
python manage.py runserver
python manage.py runserver 8080
python manage.py runserver 0:8000
python manage.py startapp polls
from django.http import HttpResponse`
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('user.urls')),
path('admin/', admin.site.urls),
]
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=100)
pub_date= models.DateTimeField('date published')
class Choice(models.Model):
question= models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
vote = models.IntegerField(default=0)
python manage.py makemigrations polls
python manage.py sqlmigrate polls 0001
python manage.py createsuperuser
create a directory under the applcation with the name templates, and then create another directory which similar to the application. The templete html files goes in this directory.
polls/templates/polls/index.html