Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Don’t use string literals for sender values in Django’s signal dispatcher
TL; DR Don’t use a string literal as the value of the sender attribute when defining your own Django signals. I got bit by a nasty bug today using Django’s signal framework. I used the signal … More→ -
Django'da Url Taşıma
Bu yazıda, eski ziyaretçileri ve arama motorlarını küstürmeden, django'da nasıl url taşıyacağımıza değineceğiz.Örneğin, bir bloğunuz var (evet, örnek pek yaratıcı değil...) ve makale/14 (id'si 14 olan makalenin url'i) gibi urlleri topluca, yazi/14 gibi url'lere taşımak istiyorsunuz. Bunu Django'nun generic view'leri ile kolaylıkla yapabiliriz. Örneğin: from django.conf.urls.defaults import patterns urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$','blog.views.makale'), ) Şimdi de urlleri taşıdığımız haline bakalım: from django.conf.urls.defaults import patterns from django.views.generic.simple import redirect_to urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$',redirect_to,{'url': 'yazi/%(id)s/'}), (r'^yazi/(?P<id>\d+)/$','blog.views.makale') Bu çok basit bir örnekti. Eski bağlantımıza gelen kullanıcıları, yeni bağlantımıza yönlendirdik. Burada %(id)s kısmı, django'nun bizim için yaptığı sözlük biçiminde dizgi formatlaması (eng: dictionary-style string formatting). Böylece bize gelen url'deki id değerini, aynı şekilde yönlendirdiğimiz url içerisine koyuyoruz. Peki ama, ya sitemizin /makale/<id> olan url'ini makale/<slug> gibi bir url'e yönlerdirmek istiyorsak? Bunu yapabilmek için bir view yazıp, yönlendirmeyi orada yapmalıyız. Bunu herhangi bir modül içerisinde yapabiliriz. Ben uygulamanın kendi views modülü içerinde yapacağım. from django.http import HttpResponsePermanentRedirect from django.shortcuts import get_object_or_404 from blog.models import makale #makale modelinin orada olduğunu varsayıyorum. def makeMeSEO(request,makale_id): mkl = get_object_or_404(makale,pk=makale_id) return HttpResponsePermanentRedirect("/makale/%s/" % mkl.slug) """ Diğer fonksiyonlar burada devam ediyor. """ Burası da urls.py from django.conf.urls.defaults import patterns from django.views.generic.simple import redirect_to urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$','blog.views.makeMESEO'), (r'^makale/(?P<slug>[^/]+)/$),'blog.views.makale') Böylelikle, id'ye dayalı eski … -
Django'da Url Taşıma
Bu yazıda, eski ziyaretçileri ve arama motorlarını küstürmeden, django'da nasıl url taşıyacağımıza değineceğiz.Örneğin, bir bloğunuz var (evet, örnek pek yaratıcı değil...) ve makale/14 (id'si 14 olan makalenin url'i) gibi urlleri topluca, yazi/14 gibi url'lere taşımak istiyorsunuz. Bunu Django'nun generic view'leri ile kolaylıkla yapabiliriz. Örneğin: from django.conf.urls.defaults import patterns urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$','blog.views.makale'), ) Şimdi de urlleri taşıdığımız haline bakalım: from django.conf.urls.defaults import patterns from django.views.generic.simple import redirect_to urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$',redirect_to,{'url': 'yazi/%(id)s/'}), (r'^yazi/(?P<id>\d+)/$','blog.views.makale') Bu çok basit bir örnekti. Eski bağlantımıza gelen kullanıcıları, yeni bağlantımıza yönlendirdik. Burada %(id)s kısmı, django'nun bizim için yaptığı sözlük biçiminde dizgi formatlaması (eng: dictionary-style string formatting). Böylece bize gelen url'deki id değerini, aynı şekilde yönlendirdiğimiz url içerisine koyuyoruz. Peki ama, ya sitemizin /makale/<id> olan url'ini makale/<slug> gibi bir url'e yönlerdirmek istiyorsak? Bunu yapabilmek için bir view yazıp, yönlendirmeyi orada yapmalıyız. Bunu herhangi bir modül içerisinde yapabiliriz. Ben uygulamanın kendi views modülü içerinde yapacağım. from django.http import HttpResponsePermanentRedirect from django.shortcuts import get_object_or_404 from blog.models import makale #makale modelinin orada olduğunu varsayıyorum. def makeMeSEO(request,makale_id): mkl = get_object_or_404(makale,pk=makale_id) return HttpResponsePermanentRedirect("/makale/%s/" % mkl.slug) """ Diğer fonksiyonlar burada devam ediyor. """ Burası da urls.py from django.conf.urls.defaults import patterns from django.views.generic.simple import redirect_to urlpatterns = patterns('', (r'^makale/(?P<id>\d+)/$','blog.views.makeMESEO'), (r'^makale/(?P<slug>[^/]+)/$),'blog.views.makale') Böylelikle, id'ye dayalı eski … -
New: My Development Assumptions and Principles
New: My Development Assumptions and Principles -
New: My Development Assumptions and Principles
New: Since I started developing in Django in 2006, I've been lucky enough to meet and work with many talented people with a variety of experiences. Gradually, typically through failure or dire need, we developed a methodology and approach to development of projects. -
Django ile Blog Geliştirme - Url ve Görünüm
Geçtiğimiz derslerde, Django ile oluşturduğumuz proje içerisinde bir blog uygulamasına başlamış ve uygulamamızın modellerini yazmıştık. Bu dersimizde ise, blog uygulamamızın url yapılandırmasını yapacak ve tarayıcıya bazı statik ve dinamik yazılar göndereceğiz. Django'nun şablon sistemine ise bir sonraki dersimizde değineceğiz.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'nun url yapılandırması, herhangi bir python modülü içerisinde yapılabilir. Bununla birlikte, url yapılandırması yaptığımız modülün içerisine diğer uygulamaların da url yapılandırmasını dahil edebiliriz. Django projeleri geliştirirken tavsiye edilen yöntem, her uygulamanın kendi url yapılandırmasını yapması, ve bu yapılandırmaların kök dizindeki urls modülüne dahil edilmesidir. Böylece django uygulamalarının ayrıştırılması sağlanmış olur. Bu ayrıştırma sayesinde bir projede geliştirdiğimiz uygulamayı, istersek kolaylıkla dağıtabilir, istersek diğer projelerimize dahil edebiliriz. Yeni başladığımız projemizin kök dizininde bulunan urls modülünün sıradan bir python modülünden bir farkı yoktur. Sadece, urlpatterns isminde bir patterns objesi tanımlaması gerekir. Bunun için öncelikle, django.conf.urls.defaults içerisinde bulunan patterns'ı bu modüle dahil etmemiz gerekir. Yeni oluşturulan projemizde bu işlem django tarafından yapılmıştır. Bununla birlikte örnek bir urlpatterns objesi de tanımlanmıştır. Geçen dersimizde django'nun içerisinde gelen admin uygulamasında tanımlanan url'leri, buraya dahil etmiştik. Şimdi de blog projemize ait url yapılandırmasını buraya ekleyelim. from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', … -
Django ile Blog Geliştirme - Url ve Görünüm
Geçtiğimiz derslerde, Django ile oluşturduğumuz proje içerisinde bir blog uygulamasına başlamış ve uygulamamızın modellerini yazmıştık. Bu dersimizde ise, blog uygulamamızın url yapılandırmasını yapacak ve tarayıcıya bazı statik ve dinamik yazılar göndereceğiz. Django'nun şablon sistemine ise bir sonraki dersimizde değineceğiz.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'nun url yapılandırması, herhangi bir python modülü içerisinde yapılabilir. Bununla birlikte, url yapılandırması yaptığımız modülün içerisine diğer uygulamaların da url yapılandırmasını dahil edebiliriz. Django projeleri geliştirirken tavsiye edilen yöntem, her uygulamanın kendi url yapılandırmasını yapması, ve bu yapılandırmaların kök dizindeki urls modülüne dahil edilmesidir. Böylece django uygulamalarının ayrıştırılması sağlanmış olur. Bu ayrıştırma sayesinde bir projede geliştirdiğimiz uygulamayı, istersek kolaylıkla dağıtabilir, istersek diğer projelerimize dahil edebiliriz. Yeni başladığımız projemizin kök dizininde bulunan urls modülünün sıradan bir python modülünden bir farkı yoktur. Sadece, urlpatterns isminde bir patterns objesi tanımlaması gerekir. Bunun için öncelikle, django.conf.urls.defaults içerisinde bulunan patterns'ı bu modüle dahil etmemiz gerekir. Yeni oluşturulan projemizde bu işlem django tarafından yapılmıştır. Bununla birlikte örnek bir urlpatterns objesi de tanımlanmıştır. Geçen dersimizde django'nun içerisinde gelen admin uygulamasında tanımlanan url'leri, buraya dahil etmiştik. Şimdi de blog projemize ait url yapılandırmasını buraya ekleyelim. from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', … -
Django'da Abstract Modeller
Django'da abstract modellerin kullanımını merak edenlere yönelik, kısa ve öz bir yazı olacak bu.Django'da birbirine çok benzer modeller oluşturacağınız zaman, bir adet abstract model oluşturup, daha sonra o abstract modeli kullanarak asıl modellerinizi oluşturabilirsiniz. abstract (tr: soyut) modellerin kendileri veritabanında bir tablo oluşturmak için kullanılmazlar, bunun yerine diğer modeller için temel oluştururlar. Bir örnekle inceleyelim: class MotorluArac(models.Model): model = models.CharField(max_length=100) yas = models.PositiveIntegerField() plaka = models.IntegerField() class Meta: abstract = True class Araba(MotorluArac): abs_var_mi = models.BooleanField() Bu örneğimizde, MotorluArac abstract modelini kullanarak oluşturduğumuz Araba modelinin, model, yas, araba ve plaka olarak 4 farklı alanı olacak. MotorluArac abstract modelini kullanarak istediğimiz kadar yeni model üretebiliriz. Deneyimli python programcıları, Araba modelinde Meta sınıfının üstüne yazmadığımız için, bu modelin de bir abstract sınıf olacağını düşünebilirler, ancak Django bu problemi bizim için hallediyor. abstract model kullanarak oluşturduğumuz modellerin kendi Meta sınıflarını oluştururken, isterseniz abstract modelin Meta sınıfından kalıtım alabilirsiniz (eng: inherit, extend) class Araba(MotorluArac): abs_var_mi = models.BooleanField() class Meta(MotorluArac.Meta): db_table = "araba_tablosu" -
Django'da Abstract Modeller
Django'da abstract modellerin kullanımını merak edenlere yönelik, kısa ve öz bir yazı olacak bu.Django'da birbirine çok benzer modeller oluşturacağınız zaman, bir adet abstract model oluşturup, daha sonra o abstract modeli kullanarak asıl modellerinizi oluşturabilirsiniz. abstract (tr: soyut) modellerin kendileri veritabanında bir tablo oluşturmak için kullanılmazlar, bunun yerine diğer modeller için temel oluştururlar. Bir örnekle inceleyelim: class MotorluArac(models.Model): model = models.CharField(max_length=100) yas = models.PositiveIntegerField() plaka = models.IntegerField() class Meta: abstract = True class Araba(MotorluArac): abs_var_mi = models.BooleanField() Bu örneğimizde, MotorluArac abstract modelini kullanarak oluşturduğumuz Araba modelinin, model, yas, araba ve plaka olarak 4 farklı alanı olacak. MotorluArac abstract modelini kullanarak istediğimiz kadar yeni model üretebiliriz. Deneyimli python programcıları, Araba modelinde Meta sınıfının üstüne yazmadığımız için, bu modelin de bir abstract sınıf olacağını düşünebilirler, ancak Django bu problemi bizim için hallediyor. abstract model kullanarak oluşturduğumuz modellerin kendi Meta sınıflarını oluştururken, isterseniz abstract modelin Meta sınıfından kalıtım alabilirsiniz (eng: inherit, extend) class Araba(MotorluArac): abs_var_mi = models.BooleanField() class Meta(MotorluArac.Meta): db_table = "araba_tablosu" -
HTML5 and other Django updates on my sites
I'm not a front-end designer but I wanted to jump on the HTML5 boat a bit. Previously I had XHTML layout based on 960.gs grid. I've decided to changed few things a bit and also change the XHTML to HTML5 by using some new basic tags like "article", "aside", "figure", "footer", as well as roles or schema to mark the breadcrumbs (that as Google says is supported by few search engines, although Google got my breadcrumbs before too). And also as I use Google+ I've added the authorship link, and fb:admins meta tag for Facebook (to see if it will add something to the FB likes or other stuff). The current layout doesn't use CSS3 (yet?) nor newer CSS frameworks. I've sicked to 960.gs for simplicity. The design didn't changed much. Some boxes were reorganised and content model got few extra fields. I've used some inspiration from grey WP theme, and HTML5 tags in action were nicely shown in HTML5 template by jayj.dk. ToDo is to update the django-grappelli to the latest version, as well as add django-ajax-selects for the "related articles" multiple select widget. Will it improve content indexing by search engines or SERP position time will tell. To … -
Django ile Blog Geliştirme - Yönetici Paneli
Yazı dizimizin önceki bölümlerinde django projemizin içerisinde bir uygulama oluşturup, bu uygulamanın modellerini yazmıştık. Bu yazımızda ise, uygulamamızı django'nun yönetici paneline kaydedeceğiz.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'nun belki de en güzel özelliklerinden biri bizi yönetici paneli yapmaktan kurtarmasıdır. Django kendi içerisinde bir admin sitesi uygulamasıyla gelir, ve bu uygulamayı kolaylıkla projemize dahil edebiliriz. Eğer halen aktifleştirmediyseniz, settings modülü içerisindeki django.contrib.admin uygulamasını şimdi aktifleştirebilirsiniz. settings modülü içerisindenki INSTALLED_APPS listesinde zaten varsa, django.contrib.admin'in başındaki # işaretini kaldırın, eğer yoksa bunu listeye kendiniz ekleyin. Django'nun yönetici sitesinin bağımlılıkları yeni bir django projesinin içerisinde kendiliğinden sağlanmış olarak gelirler. Ancak, bu bağımlıkları yanlışlıkla sildiğinizi düşünüyorsanız, şunları kontrol edin: Yüklü uygulamalarınız içerisinde şunlar var mı: django.contrib.auth, django.contrib.contenttypes, django.contrib.messages MIDDLEWARE_CLASSES içerisinde MessageMiddleware var mı? TEMPLATE_CONTEXT_PROCESSORS içerisinde django.contrib.messages.context_processors.messages var mı? Eğer bunların hepsi varsa, admin sitesi kullanıma hazır demektir. Eğer admin sitesini yeni aktifleştirdiyseniz, şu komutu vererek veritabanında admin sitesi için gerekli olan tabloları oluşturun: python manage.py syncdb Bu komut eğer daha önce bir yönetici hesabı oluşturmadıysanız, bir yönetici hesabı oluşturmanızı isteyecek. Gerekli bilgileri girerek yönetici hesabınızı oluşturun. Admin sitesi uygulamasını yüklemiş olmamıza rağmen, henüz bu siteye hangi link üzerinden ulaşılacağını django'ya bildirmedik. URL tanımlaması yapması konusuna daha sonra değineceğiz. Şimdilik, proje … -
Django ile Blog Geliştirme - Yönetici Paneli
Yazı dizimizin önceki bölümlerinde django projemizin içerisinde bir uygulama oluşturup, bu uygulamanın modellerini yazmıştık. Bu yazımızda ise, uygulamamızı django'nun yönetici paneline kaydedeceğiz.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'nun belki de en güzel özelliklerinden biri bizi yönetici paneli yapmaktan kurtarmasıdır. Django kendi içerisinde bir admin sitesi uygulamasıyla gelir, ve bu uygulamayı kolaylıkla projemize dahil edebiliriz. Eğer halen aktifleştirmediyseniz, settings modülü içerisindeki django.contrib.admin uygulamasını şimdi aktifleştirebilirsiniz. settings modülü içerisindenki INSTALLED_APPS listesinde zaten varsa, django.contrib.admin'in başındaki # işaretini kaldırın, eğer yoksa bunu listeye kendiniz ekleyin. Django'nun yönetici sitesinin bağımlılıkları yeni bir django projesinin içerisinde kendiliğinden sağlanmış olarak gelirler. Ancak, bu bağımlıkları yanlışlıkla sildiğinizi düşünüyorsanız, şunları kontrol edin: Yüklü uygulamalarınız içerisinde şunlar var mı: django.contrib.auth, django.contrib.contenttypes, django.contrib.messages MIDDLEWARE_CLASSES içerisinde MessageMiddleware var mı? TEMPLATE_CONTEXT_PROCESSORS içerisinde django.contrib.messages.context_processors.messages var mı? Eğer bunların hepsi varsa, admin sitesi kullanıma hazır demektir. Eğer admin sitesini yeni aktifleştirdiyseniz, şu komutu vererek veritabanında admin sitesi için gerekli olan tabloları oluşturun: python manage.py syncdb Bu komut eğer daha önce bir yönetici hesabı oluşturmadıysanız, bir yönetici hesabı oluşturmanızı isteyecek. Gerekli bilgileri girerek yönetici hesabınızı oluşturun. Admin sitesi uygulamasını yüklemiş olmamıza rağmen, henüz bu siteye hangi link üzerinden ulaşılacağını django'ya bildirmedik. URL tanımlaması yapması konusuna daha sonra değineceğiz. Şimdilik, proje … -
Django ile Blog Geliştirme - Modeller
0'dan Blog'a Django yazı dizisinin ikinci bölümünde yazı dizisinin ilk bölümünde başlayıp, basit ayarlarını yaptığımız projemizin içinde blog uygulamasına başlayacağız ve uygulamamızın modellerini yazacağız.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'da yeni bir uygulamaya başlamak için, komut satırından başlamış olduğumuz projenin ana dizininin içindeyken python manage.py startapp blog komutunu vererek, projemizin içinde blog isminde yeni bir uygulamaya başlayabiliriz. Her django projesi bir veya birden fazla uygulamadan oluşur. Aynı zamanda bir proje'de geliştirdiğiniz uygulamayı kolaylıkla başka projelerinizde de kullanabilirsiniz. Aynı şekilde başkalarının geliştirdiği uygulamaları da kendi projenize çok rahatlıkla dahil edebilirsiniz. Bu özellik, django'nun en önemli özelliklerinden biridir. Bir kez yaptığınız bir işi, tekrar yapmanızı engeller. Yeni başladığımız uygulama, blog isimli bir klasörün içerisinde bulunan 4 adet py uzantılı dosyadan oluşuyor. __init__.py Boş bir dosyadır. Bu dosyayla neredeyse hiç bir işiniz olmayacak. Bu dizinin bir python paketi olduğu belirtmek için oradadır. models.py Bu sıradan bir python modülüdür. Bu modülün içerisinde veri yapılarımızı, yani modellerimizi, tanımlayacağız. Bu dosyanın detaylarına daha sonra değineceğiz. views.py Bu dosyanın içerisinde verilerimizi nasıl sunacağımıza karar verecek olan sınıfları tanımlayacağız. Yazı dizisinin ilerleyen bölümlerinde zaman zaman bu dosyayla ilgili detaylara değineceğiz. tests.py Bu modülün içerisinde ünite testi yapmak için gerekli sınıflar bulunur. Bu testler … -
Django ile Blog Geliştirme - Modeller
0'dan Blog'a Django yazı dizisinin ikinci bölümünde yazı dizisinin ilk bölümünde başlayıp, basit ayarlarını yaptığımız projemizin içinde blog uygulamasına başlayacağız ve uygulamamızın modellerini yazacağız.Bu yazı dizisinde bahsedilen blog uygulamasının son haline github deposundan ulaşabilirsiniz. Django'da yeni bir uygulamaya başlamak için, komut satırından başlamış olduğumuz projenin ana dizininin içindeyken python manage.py startapp blog komutunu vererek, projemizin içinde blog isminde yeni bir uygulamaya başlayabiliriz. Her django projesi bir veya birden fazla uygulamadan oluşur. Aynı zamanda bir proje'de geliştirdiğiniz uygulamayı kolaylıkla başka projelerinizde de kullanabilirsiniz. Aynı şekilde başkalarının geliştirdiği uygulamaları da kendi projenize çok rahatlıkla dahil edebilirsiniz. Bu özellik, django'nun en önemli özelliklerinden biridir. Bir kez yaptığınız bir işi, tekrar yapmanızı engeller. Yeni başladığımız uygulama, blog isimli bir klasörün içerisinde bulunan 4 adet py uzantılı dosyadan oluşuyor. __init__.py Boş bir dosyadır. Bu dosyayla neredeyse hiç bir işiniz olmayacak. Bu dizinin bir python paketi olduğu belirtmek için oradadır. models.py Bu sıradan bir python modülüdür. Bu modülün içerisinde veri yapılarımızı, yani modellerimizi, tanımlayacağız. Bu dosyanın detaylarına daha sonra değineceğiz. views.py Bu dosyanın içerisinde verilerimizi nasıl sunacağımıza karar verecek olan sınıfları tanımlayacağız. Yazı dizisinin ilerleyen bölümlerinde zaman zaman bu dosyayla ilgili detaylara değineceğiz. tests.py Bu modülün içerisinde ünite testi yapmak için gerekli sınıflar bulunur. Bu testler … -
Django MongoDB Engine
Tweet Estou testando o módulo Django MongoDB Engine, um backend para Django bastante completo. O grande diferencial desse módulo é permitir uma integração total e transparente do Django com o MongoDB, inclusive trabalhando no models da mesma forma que em um banco relacional. Além disso, o módulo também permite utilizar GridFS, Map Reduce, Agregadores e Atomic Updates em apps do Django, mantendo total compatibilidade com Admin, Sessões e Autenticação padrão do Django. Como ainda não existe uma solução oficial para trabalhar com NoSQL no Django, esse módulo — até agora — é o mais completo e parece bastante estável. Ainda não instalei em aplicações em produção, mas ao realizar testes em laboratório, o módulo promete ter um grande potencial. Instalação A recomendação inicial é utilizar virtualenv, pelo fato do módulo ser recente e estar em constante desenvolvimento. É necessário instalar algumas dependências, como Django-Nonrel e Djangotoolbox. Fiz a instalação seguindo o próprio manual do módulo, que sugere pegar esses módulos diretamente de seus repositórios, mas acredito que também funciona utilizando o pip install. Com o ambiente virtualenv já criado e o Django já instalado, o primeiro passo é instalar o Django-Nonrel direto do repositório Mercurial: $ hg clone http://bitbucket.org/wkornewald/django-nonrel $ … -
Django şablonlarında php
django_php paketiyle django uygulamalarınızın web şablonlarında php kullanmanız mümkün. Bunu neden yapmak isteyeceğiniz ise tamamen bir muamma...djang_php'yi easy_install django_php veya pip install django_php komutlarıyla kurabilirsiniz. Tabi ki bu komutları vermek için gerekli python paketlerinin yüklü olmasını gerektiğini unutmamak gerek. Daha sonra django_php'yi settings modülü içerisindeki INSTALLED_APPS listesine ekleyerek kullanmaya başlayabilirsiniz. INSTALLED_APPS = ( 'django_php', ) django_php'yi kullanmadan önce php_cgi'in sisteminizde yüklü olduğundan emin olun. Eğer php_cgi'in yerini belirtmeniz gerekiyorsa, settings modülü içerisinde PHP_CGI = '/usr/local/bin/php-cgi' şeklinde belirtebilirsiniz. Çoğu zaman bu ayarı yapmanıza gerek yoktur. Şablonlarınızın içine php'yi dahil etmek için de, şablon dosyalarınızın içinde: {% load php %} {% php echo 9; %} şeklinde kullanabilirsiniz. Daha fazla örnek kaynak kodlarının içinde mevcut. İlgili Linkler: Proje anasayfası PyPi Sayfası Kodlar -
Django şablonlarında php
django_php paketiyle django uygulamalarınızın web şablonlarında php kullanmanız mümkün. Bunu neden yapmak isteyeceğiniz ise tamamen bir muamma...djang_php'yi easy_install django_php veya pip install django_php komutlarıyla kurabilirsiniz. Tabi ki bu komutları vermek için gerekli python paketlerinin yüklü olmasını gerektiğini unutmamak gerek. Daha sonra django_php'yi settings modülü içerisindeki INSTALLED_APPS listesine ekleyerek kullanmaya başlayabilirsiniz. INSTALLED_APPS = ( 'django_php', ) django_php'yi kullanmadan önce php_cgi'in sisteminizde yüklü olduğundan emin olun. Eğer php_cgi'in yerini belirtmeniz gerekiyorsa, settings modülü içerisinde PHP_CGI = '/usr/local/bin/php-cgi' şeklinde belirtebilirsiniz. Çoğu zaman bu ayarı yapmanıza gerek yoktur. Şablonlarınızın içine php'yi dahil etmek için de, şablon dosyalarınızın içinde: {% load php %} {% php echo 9; %} şeklinde kullanabilirsiniz. Daha fazla örnek kaynak kodlarının içinde mevcut. İlgili Linkler: Proje anasayfası PyPi Sayfası Kodlar -
django CMS 2.2 beta 1 available
django CMS 2.2 beta 1 available -
Redis vs Memcached [en]
With some help of our friend "Google Translate" :) As we all know that if you want a web application goes faster there is a secret cache as much as you can. Avoid to generate the page each time and search for the content in the database. To archieve this the today standard is Memcached. Memcached allows us to scale our application a simple way. We can think it as a big hash table, written in C, very fast and with libraries to access to it in almost any language. But thre is e a new competitor in this kind of applications: Redis, and I've already talked about it in the Celery post. Memcached is an application aimed at dealing with cache, Redis is a noSQL general purpose key-value database in a similar way as Memcached, but with possibilities that go far beyond a cache. Let's see a few differences: We can not see the keys we have in Memcached. With Redis can do a search for keys, or see all the command KEYS * Redis has persitence. Memcached is limited to memory you allocate, Redis can also swapt to disk and just put the keys in memory. In Memcached … -
Integrating Django with Nose at DISQUS
About a month ago we decided to make the transition off of Django’s test suite over to the Nose runners. Our main selling point was the extensibility, and the existing ecosystem of plugins. Four weeks later I’m happy to say we’re running (basically) Nose with some minor extensions … -
We're hiring a Front End Web Developer
I'm excited to announce that Caktus is actively seeking a Front End Web Developer. The position would entail creating wireframes and mock ups of proposed designs and user stories, performing front end jQuery and Javascript development, converting PSD's into standards compliant HTML and CSS, and also cloning repositories and running Django sites locally for development. ... -
Redis vs Memcached
Com tots sabem si un vol que una aplicació web vagi ràpida hi ha un secret: posar en caché tot el que puguem. Evitar tenir que fer càlculs i anar a la base de dades a cercar la informació. Per fer això l'estàndard avui en dia és Memcached. Memcached ens permet escalar la nostra aplicació d'una manera molt senzilla. És una gran taula hash, del tipus clau valor, escrita en C, molt ràpida i amb llibreries d'accés en pràcticament qualsevol llenguatge. Però en els darrers temps ha sortit un nou competidor dins les bases de dades de tipus hash, aquest competidor reb el nom de Redis, i ja us n'he parlat quan tractàvem el tema de Celery. Així com Memcached és una aplicació orientada a tractar amb caché, Redis és una base de dades noSQL de propòsit general, amb format clau-valor com Memcached, però amb unes possibilitats que van molt més enllà de un simple magatzem de memòria. Anem a veure un parell de diferències: No podem veure les claus que tenim dins Memcached. Amb redis podem fer una cerca per claus, o veure-les totes amb la comanda KEYS * Podem configurar Redis per a que sigui persistent. Memcached està … -
Why conferences need a code of conduct
As usual, what I write here is my opinion and I don’t speak for anyone else. In particular, this isn’t any sort of official PyCon anything. Recently, tech conferences have started publishing a new kind of document: a code of conduct or anti-harassment policy [1]. Attendees are being explicitly told that they’re expected to follow these policies. To some, this sounds patronizing; or like tools for group-think and censorship; or like a bad episode of The Morality Police. -
Django vs. PostgreSQL IN operations
Here’s another cautionary performance tale, wherein I thought I was clever but was not. A table (“Vital”) holds widget information. Another table (“Furball”) holds other information, with an M:M relationship to Vital. We want to do inferential computations on filtered Furball rows. So we generate a pk list from a Vital QuerySet, and call this function: def _get_top(vitals): from django.db.models import Count TOP_NUMBER = 5 vitalids = [x.id for x in vitals] top_balls = Furball.objects.filter(vital__id__in=vitalids)\ .annotate(count=Count('id'))\ .order_by('-count')[:TOP_NUMBER] top_list = [(x.name, x.count)for x in top_balls] return top_list I coded this using an __in operation for a couple of reasons, which won’t be apparent from this simplified code fragment. My point is, I didn’t think this approach would be a performance problem. Look at the top_balls assignment, which filters the Furball rows referenced by the Vital rows. Goof #1: The vitalids list could be really big. Really big. How big? It could have up to 15 K entries. I didn’t expect this when I coded this function. That’s a huge amount of data to send with a db request. Goof #2: Although there’s a relationship between these tables, I had thought an __in field lookup, which asks Postgres to search for pks … -
Looking for the right Djangonaut
Right off the bat I'll admit bias. I think Imaginary Landscape is a great place to work. We've been around since 1995 and programming in Python since 1999. We are a 4-time sponsor of PyCon and a 3-time sponsor of DjangoCon. We hosted the first ChiPy meeting and ...