際際滷

際際滷Share a Scribd company logo
nedir, yenir mi?


      Cihan Okyay
cihan.okyay@linux.org.tr
        @cihann
* Open source

* Nesne Y旦nelimli

* Temiz s旦zdizimi

* renmesi kolay

* G端巽l端
Guido van Rossum
a = 10

if a > 5:
    print 'b端y端k'
else:
    print 'k端巽端k'



def factorial(x):
  if x == 0:
      return 1
  else:
      return x * factorial(x - 1)

factorial(5)
Django



  The Web framework
  for perfectionists with deadlines ...
... not a framework for
beginners with deadlines
Tarihi

2003: Kansas, USA

2005: BSD & 0.90

2008: 1.0

2011: 1.3
zellikler

  * D旦k端mantasyon

  * ORM

  * URL dispatcher

  * Templates

  * Interactive terminal

  * Admin Panel
* Authentication & Authorization

* i18n i L10n

* Cache

* Forms
Mimari


  MTV (Model, Template, View)
Model

from django.db import models class

class Poll(models.Model):
   question = models.CharField(max_length=200)
   pub_date = models.DateTimeField('date published')

class Choice(models.Model):
   poll = models.ForeignKey(Poll)
   choice = models.CharField(max_length=200)
   votes = models.IntegerField()
ORM

>>> from polls.models import Poll, Choice

>>> Poll.objects.all()
[]

>>> import datetime
>>> p = Poll(question="Naber?",
...   pub_date=datetime.datetime.now())

>>> p.save()

>>> p.id
1

>>> p.question
"Naber?"
orm devam

>>> Poll.objects.get(id=1)
<Poll: Naber?>

>>> Poll.objects.filter(question="Naber?")
[<Poll: Naber?>]

>>> Poll.objects.all().order_by("question")
[<Poll: Naber?>]

>>> Poll.objects.filter(question__startswith="Nab")
[<Poll: Naber?>]
>>> p = Poll.objects.get(question="Naber?")

>>> p.question = "Naber Django?"

>>> p.save()

>>> p.question
Admin Panel
Django nedir yenir mi?
Views


from django.http import HttpResponse

def hello(request):
  return HttpResponse("Hello World!")



from django.shortcuts import render_to_response
from polls.models import *

def index(request):
  latest_poll_list = Poll.objects.all().order_by('-pub_date')
  return render_to_response('index.html',
      {'latest_poll_list': latest_poll_list})
URLconfs


from django.conf.urls.defaults import *

urlpatterns = patterns(''",
   (r'^polls/$', 'polls.views.index'),
)


example.com/polls/
Templates
rnek uygulama




https://github.com/cihann/djangoistanbul

git@github.com:cihann/djangoistanbul.git
TEEKKRLER


 SORULAR?

More Related Content

Django nedir yenir mi?