0
Django (and all that jazz)‏
Overview <ul><li>Python framework </li></ul><ul><li>MTV (MVC)‏ </li></ul><ul><li>Loosely coupled </li></ul><ul><li>Nice UR...
Python <ul><li>Readable </li></ul><ul><li>Pythonic (“import this”)‏ </li></ul><ul><li>Batteries included (contrib)‏ </li><...
Basics (making it work)‏ <ul><li>django-admin.py / manage.py </li></ul><ul><li>projects </li></ul><ul><li>applications </l...
File Structure <ul><li>manage.py startapp appname </li></ul><ul><li>settings.py </li></ul><ul><li>urls.py </li></ul><ul><l...
Configuring (settings.py)‏ <ul><li>Dynamic - configured in programmatic Python </li></ul><ul><li>Uses Python's native data...
Models
Models (sorry)‏ <ul><li>Each class inherits from models.Model </li></ul><ul><li>To pull in from another table: </li></ul><...
How do we see that content? <ul><li>admin app: “It’s not just scaffolding — it’s the whole house” </li></ul><ul><li>pre-in...
Hooking it up (urls.py)‏ <ul><li>URL routing achieved through regex </li></ul><ul><li>backreferences used to identify para...
Upcoming SlideShare
Loading in...5
×

Django (and all that jazz)

1,607

Published on

Django for beginners

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,607
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
41
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Django (and all that jazz)"

  1. 1. Django (and all that jazz)‏
  2. 2. Overview <ul><li>Python framework </li></ul><ul><li>MTV (MVC)‏ </li></ul><ul><li>Loosely coupled </li></ul><ul><li>Nice URLs </li></ul><ul><li>Friendly / powerful templating </li></ul>
  3. 3. Python <ul><li>Readable </li></ul><ul><li>Pythonic (“import this”)‏ </li></ul><ul><li>Batteries included (contrib)‏ </li></ul><ul><li>Simple / Powerful data structures </li></ul><ul><li>Interactive shell </li></ul>
  4. 4. Basics (making it work)‏ <ul><li>django-admin.py / manage.py </li></ul><ul><li>projects </li></ul><ul><li>applications </li></ul><ul><li>django-admin.py startproject <stuff> </li></ul><ul><li>manage.py runserver </li></ul><ul><li>http://localhost:8000 </li></ul>
  5. 5. File Structure <ul><li>manage.py startapp appname </li></ul><ul><li>settings.py </li></ul><ul><li>urls.py </li></ul><ul><li>appname/models.py </li></ul><ul><li>appname/views.py </li></ul>
  6. 6. Configuring (settings.py)‏ <ul><li>Dynamic - configured in programmatic Python </li></ul><ul><li>Uses Python's native data structures </li></ul><ul><li>Setup globals (eurgh etc)‏ </li></ul><ul><li>Configure databases (MySQL, PostGre, SQLite)‏ </li></ul><ul><li>Installed apps (admin, auth, appname)‏ </li></ul>
  7. 7. Models
  8. 8. Models (sorry)‏ <ul><li>Each class inherits from models.Model </li></ul><ul><li>To pull in from another table: </li></ul><ul><ul><li>user = models.ForeignKey(User, unique=True)‏ </li></ul></ul><ul><li>Each field maps directly to a class member: </li></ul><ul><ul><li>days_remaining = models.IntegerField()‏ </li></ul></ul><ul><li>Mapped with syncdb admin command </li></ul>
  9. 9. How do we see that content? <ul><li>admin app: “It’s not just scaffolding — it’s the whole house” </li></ul><ul><li>pre-installed as django.contrib.admin </li></ul><ul><li>add to installed_apps in settings.py </li></ul><ul><li>syncdb once more </li></ul><ul><li>Then there's one more step... </li></ul>
  10. 10. Hooking it up (urls.py)‏ <ul><li>URL routing achieved through regex </li></ul><ul><li>backreferences used to identify parameters </li></ul><ul><li>Very loosely decoupled </li></ul><ul><li>include app-specific url routers: </li></ul><ul><ul><li>(r'^admin/', include(django.contrib.admin.urls'))‏ </li></ul></ul><ul><ul><li>http://localhost:8000/admin </li></ul></ul><ul><li>make the string look nicer </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×