Django nedir

659 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
659
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Django nedir

  1. 1. Nedir ?
  2. 2. Framework Nedir ?
  3. 3. Neden Django ?• Open Source• Nesne yönelimli ( OOP )• Temiz kod• Öğrenmesi Kolay• Hızlı
  4. 4. Kimler Django Kullanıyor
  5. 5. Özellikleri• Dökümantasyon• Şık URL yapısı• Template Dizayn• Çoklu Dil Desteği• MTV mimarisi• Cache• Form
  6. 6. Yapıproje_adi/manage.pyproje_adi/__init__.pysettings.pyurls.pywsgi.pyapp/__init__.pymodels.pytests.pyviews.py
  7. 7. Bileşenler• Models - models.py• Templates - html dosyaları• Views - views.py• Url Patterns – urls.py
  8. 8. Models.pyfrom django.db import modelsclass Anket(models.Model):soru = models.CharField(max_length=200)tarih = models.DateTimeField(date published)class Secim(models.Model):anket = models.ForeignKey(Anket)secilen_yazi = models.CharField(max_length=200)puan = models.IntegerField(default=0)
  9. 9. ORM>>> from app.models import Anket, Secim>>> Anket.objects.all()[]>>> from django.utils import timezone>>> p = Anket(soru="Nasılsın?", tarih=timezone.now())>>> p.save()>>> p.id1>>> p.soru"Nasılsın?">>> p.tarihdatetime.datetime(2012, 2, 26, 13, 0, 0, 775217, tzinfo=<UTC>)>>> p.soru = "Nasıl Gidiyor?">>> p. save()
  10. 10. Urls.pyfrom django.conf.urls import patterns, include, urlurlpatterns = patterns(,url(r^$, ‘views.index’),url(r^anketler/$, ‘views.anketler’),)# example.com/# example.com/anketler/
  11. 11. Views.pyfrom django.shortcuts import renderfrom app.models import Anketdef index(request):x = Anket.objects.all().order_by(-tarih)[:5]degerler = {anketler: x}return render(request, index.html, degerler)
  12. 12. Templates<html><body>{% if anketler %}<ul>{% for anket in anketler %}<li>{{ anket.soru }} </li>{% endfor %}</ul>{% else %}<p>Anket Bulunamadı.</p>{% endif %}</body></html>
  13. 13. Yararlı Linkler• https://docs.djangoproject.com/• http://www.djangobook.com/• http://stackoverflow.com/• http://djangoforum.com/• http://freedjangohosting.com/

×