CREATING A DJANGO PROJECT

CREATING A DJANGO PROJECT:
LINk:https://www.youtube.com/watch?v=bAMKZALIkHk
env_mysite\scripts\activate for creating django directory
Now we’ll run our Django server to see our project running!
python manage.py runserver
Now we’ll create our crawler inside of our TechCrawler project:
python manage.py startapp crawler
The First View We’re Going to Create
A view is simply a Python function that takes in a web request and returns a web response
VIEWS.PY:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse('<h1>subscribe my channel!</h1>')
URLS.PY:
from django.conf.urls import include, url
from django.contrib import admin
from crawler import views
#We need to import our app's views to call our index view

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
# localhost:8000 will go here
url(r'^',include('crawler.urls')),
]
#index into the url now save

Comments

Popular Posts