Anand Reddy Pandikunta
Overview of Django
CRUD Operations
Basics Of Python
Basics Of Web development
Basics Of Databases
Feel free to interrupt & ask during the session.
# Create New Virtualenv python3 -m venv bmanager-venv --without-pip source bmanager-venv/bin/activate curl https://bootstrap.pypa.io/get-pip.py | python deactivate source bmanager-venv/bin/activate # Install Django pip install django==1.7
django-admin startproject bmanager python manage.py runserver
# views.py from django.shortcuts import HttpResponse def hello(request): return HttpResponse('Hello World') # urls.py url(r'^hello', hello, name='hello')
import datetime from django.shortcuts import render def hello(request): time = str(datetime.datetime.now()) return render(request, 'hello.html', {'time': time})
python3 manage.py startapp bookmarks
from django.db import models class Bookmark(models.Model): name = models.CharField(max_length=20) url = models.URLField()
from django.contrib import admin from bookmarks.models import Bookmark admin.site.register(Bookmark)
>>> from bookmarks.models import Bookmark >>> Bookmark.objects.all() [<Bookmark: python>, <Bookmark: django>] >>> Bookmark.objects.get(pk=1) <Bookmark: python> >>> Bookmark.objects.filter(name__startswith='p') [<Bookmark: python>, <Bookmark: python>]
Create View
Create Form
Create Template
List Bookmarks
Edit Bookmarks
Delete Bookmarks
class Folder(models.Model): folder = models.CharField(max_length=20) class Bookmark(models.Model): folder = models.ForeignKey(Folder, null=True)