120 likes | 315 Views
Dj(T)ango with Python. Ritika Virmani. What is Django?. It’s not a Hawaiian dance Developed by Adrian Holovaty and Simon Willison Rapid Web Development for Perfectionists with Deadlines Named after Django Reinhardt, a gypsy jazz guitarist Open Source. It’s all about music.
E N D
Dj(T)ango with Python Ritika Virmani
What is Django? • It’s not a Hawaiian dance • Developed by Adrian Holovaty and Simon Willison • Rapid Web Development for Perfectionists with Deadlines • Named after Django Reinhardt, a gypsy jazz guitarist • Open Source
It’s all about music • MVC MTV : • Model – Class maps to tables • Template - HTML • View - Pages
more about Django • Make web development stupidly fast • Ease the creation of complex, database-driven websites • Reusability and "pluggability" of components • DRY
Cool stuff • Dynamic administrative interface • Lightweight, standalone web server for development and testing • Tools for generating cool things like RSS and Atom feeds, Google Sitemaps
Get started… and done! • To create your project, simply run django-admin.py startproject <yourProject> • __init__.py — Blank module to initialize the package • manage.py — command-line utility that lets you interact with this Django project • settings.py — Django settings for your project • urls.py — URL mappings to views
Get started … and done! [2] 1. At the Command Prompt type: python manage.py startapp blogs 2. Add this to settings.py under INSTALLED_APPS DjangoPrimer.blogs 3. Add to models.py: from django.db import models class Post(models.Model): author = models.CharField(maxlength=20) date = models.DateTimeField() title = models.CharField(maxlength=50) post = models.TextField() def __str__(self): return self.title class Admin: list_display = ('author', 'date') search_fields = ('title', 'post')
Get started … and done! [3] 4. At the Command Prompt type: python manage.py sql blogs 5. At the Command Prompt type: python manage.py syncdb 6. At the Command Prompt type: python manage.py runserver