Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 ... -
Tạo môi trường làm việc ảo với virtualenv
Virtualenv là một công cụ để xây dựng môi trường độc lập khi phát triển với Python. Đó là một cách tuyệt vời để nhanh chóng kiểm tra các thư viện mới mà không làm lộn xộn các package có sẵn của bạn hoặc chạy nhiều dự án trên cùng một máy phụ thuộc vào một thư viện đặc biệt nhưng không phải cùng một phiên bản của thư viện đã có. Ví dụ bạn có thể cài đặt phiên bản X của thư viện trong một môi trường và phiên bản Z của cùng một thư viện trong môi trường khác, mà không gây ảnh hưởng đến cái khác. Mỗi môi trường cung cấp thực thi Python riêng của nó và thư mục của site-package (không được chia sẻ giữa các môi trường). Để cài đặt virtualenv, chỉ cần sử dụng easy_install với lệnh sau đây: easy_install virtualenv Một khi virtualenv được cài đặt, bạn có thể sử dụng lệnh virtualenv để tạo ra môi trường ảo. Các lệnh sau đây sẽ tạo ra một môi trường được gọi là "working": virtualenv working Bạn có thể kích hoạt các môi trường bằng cách chạy script kích hoạt nó, nằm … -
EmailInput HTML5 friendly for Django
Suppose you have a Django app with a login where people can only log in with their email address. Then use this widget on your login form: ## The input widget class class EmailInput(forms.widgets.Input): input_type = 'email' def render(self, name, value, attrs=None): if attrs is None: attrs = {} attrs.update(dict(autocorrect='off', autocapitalize='off', spellcheck='false')) return super(EmailInput, self).render(name, value, attrs=attrs) ## Example usage class AuthenticationForm(django.contrib.auth.forms.AuthenticationForm): """override the authentication form because we use the email address as the key to authentication.""" # allows for using email to log in username = forms.CharField(label="Username", max_length=75, widget=EmailInput()) rememberme = forms.BooleanField(label="Remember me", required=False) This input field does some cool stuff in the browser such as automatic validation in the browser as seen in this screenshot here. More importantly it fixes a very annoying problem when surfing on a smartphone or a tablet like the iPad. As I'm about to type "someusername@mozilla.com" it first wants to start capitalized and which might fail the login. Also if the email address contains a word that it wants to correct like ("mozilla" -> "Mozilla") you have to click the little correct tooltip to tell the input is correct in verbatim. Note to Djangonauts who want to use this and have a dual authentication backend that takes both usernames and email addresses, this form will make it impossible to log in as something called "admin" for example. -
EmailInput HTML5 friendly for Django
Suppose you have a Django app with a login where people can only log in with their email address. Then use this widget on your login form: ## The input widget class class EmailInput(forms.widgets.Input): input_type = 'email' def render(self, name, value, attrs=None): if attrs is None: attrs = {} attrs.update(dict(autocorrect='off', autocapitalize='off', spellcheck='false')) return super(EmailInput, self).render(name, value, attrs=attrs) ## Example usage class AuthenticationForm(django.contrib.auth.forms.AuthenticationForm): """override the authentication form because we use the email address as the key to authentication.""" # allows for using email to log in username = forms.CharField(label="Username", max_length=75, widget=EmailInput()) rememberme = forms.BooleanField(label="Remember me", required=False) This input field does some cool stuff in the browser such as automatic validation in the browser as seen in this screenshot here. More importantly it fixes a very annoying problem when surfing on a smartphone or a tablet like the iPad. As I'm about to type "someusername@mozilla.com" it first wants to start capitalized and which might fail the login. Also if the email address contains a word that it wants to correct like ("mozilla" -> "Mozilla") you have to click the little correct tooltip to tell the input is correct in verbatim. Note to Djangonauts who want to use this and have a dual authentication backend that takes both usernames and email addresses, this form will make it impossible to log in as something called "admin" for example. -
The Ultimate Django Tutorial Workshop
That is a big statement to make as a title of a class/workshop blog post. However, in this case I believe I'm fully justified because this is going to be awesome. Here's why:1. The teachers are beyond incredibleIn the course description it says I'm the teacher and I have lab assistants. In retrospect, what I should have said is, "Daniel Greenfeld is organizing a workshop taught by the people he respects and admires".Think I'm kidding? Look at just some of the names of people I've got lined up to participate:Jacob Kaplan-Moss, Benevolent Dictator For Life of DjangoRussell Keith-Magee, President of the Django Software FoundationAudrey RoyJacob BurchKatharine JarmulCorey BertramSandy StrongJonas ObristChristine CheungShimon RuraFollow those links to their bios or talks and you'll see that they are the people speaking at DjangoCon. The general idea is to get the people already speaking at DjangoCon or those who are extremely experienced in it to teach the class.2. The teacher to student ratio is going to be really smallThis is not going to be a room with a few instructors and umpteen students in it. If the class size gets big, I'm going to bring in more teachers. I'll cajole, plead, and do whatever I … -
Gevent, Long-Polling & You
Gevent, Long-Polling & You -
De la web al model
L'scrapping Ahir ja vàrem veure quin era el model de dades i el bé que va sorl per a manipular imatges, així com la utilització de la llibreria requests ens quedava veure una altra part important: com agafar el contingut de la web, parsejar-lo i obtenir-ne la informació que necessitam. Per fer això hi ha diverses utilitats, algunes molt especialitzades com scrappy, i amb més solera és BeautifulSoup. Aquesta llibreria té la qualitat de ser molt permisiva amb l'HTML i hi ha poques planes que no pugui tractar d'una manera o altra. La plana de Meneame té las notícies de portada dins un div anomenat news-summari, així que el primer que farem serà carregar la plana dins una instància de BeautifulSoup i cercar aquestes notícies. page = requests.get('http://www.meneame.net') if page.status_code != 200: print "Ups! pareix que hi ha un petit problema" return page.status_code soup = BeautifulSoup(page.content) noticies = soup.findAll('div', 'news-summary') amb això BS ens haurà donat tots els divs que tenen la classes 'news-summary' amb la qual cosa ja és sols cosa d'aplicar un tractament semblant per a obtenir la informació de cada notícia for noticia in noticies: titular = noticia.find('h1').text texto = noticia.find('p').text img = noticia.find('img', 'thumbnail') if img: … -
Impostor, aucun rapport avec le courrier, la poste ou les gens de petite taille
Avec énormément de retard (non monsieur Daks, je ne vais pas renommer ma rubrique la django app du mois dernier) voici donc la django app du mois de juin. Ce mois-ci, enfin le mois dernier, je vais vous présenter Impostor une application que j’ai découvert au détour d’un tweet (de dzen je crois ) 1- Où on le trouve, comment on l’installe, tout ça quoi (et la doc) ? Deux possibilité pour le trouver, sa page github ou sa page django packages. Pas de page pypi, enfin pas encore, espérons qu’elle arrive vite. Pour l’installer, pas le choix, il faut passer par github. Un petit git clone https://github.com/samastur/Impostor.git et c’est plié. Quand à la doc, Elle se limite au readme.rst. Mais cela suffit. Et puis le readme est bien clair. Il vous expliquera comment l’installer dans votre projet django et comment vous en servir (et puis si vous continuer à lire, je vous l’expliquerais aussi) 2- Mais au fait, à quoi ça sert ? Tout simplement à se déguiser lorsque l’on se logue. D’ailleurs c’est un des meilleurs noms d’app django que j’ai pu croiser. Décrivant à la fois bien la finalité de l’app tout en étant rigolo. … -
Imatges de la web al model Django
L'altra dia estava fent una aplicació web part de la qual consisteix en aprofitar els continguts de la web anterior, continguts als que no tenim accés directe. La part de text va ser senzilla, però obtenir una imatge de la web i associar-la a un model Django va resultar una mica més interessant del que suposava. Tant que vaig pensar que potser convenia posar-ho en forma d'apunt. Per posar-ho en context vaig començar a fer una aplicació Django, la qual tenia que obtenir la imatge i guardar-la, però ja que hi era, vaig voler fer quelcom més educatiu, així que l'aplicació es va anant transformant amb codi per a descarregar-se les fotografies associades a la plana principal de meneame. Si provau el codi mirau de canviar la url que ja que amablement Ricardo em va dir que no hi havia problema en fer algunes proves, tampoc és cosa que anem putejant la web. Així doncs, aquest apunt serà un poc mescladissa d'utilitats, d' screen scrapping, de thread, processos i altres herbes. Miraré d'anar a poc a poc, però ja us aviso que hi ha de tot i molt! Definim el model El més habitual quan hom tracta amb imatges és … -
Shivling : Avoiding boilerplate in views in Django
I have been unable to find time to continue my Shiv series, however, a chat with a friend(@arihersh) who has just started learning django reminded me of a small piece of code I had written sometime back. The chat went something like this Ari Hershowitz: I’d like to have html “widgets” that have certain actions, without having to create an artificial url + view to control the widget. Maybe that’s what your framework does? Yousuf Fauzan: gimme an example Ari Hershowitz: Ok… I’ll try to describe… I want to create a search bar that goes on any page. To do this in Django, I think I need to: (1) create a search form, (2) put it into a template, (3) include the template into any other template. I also need to create a view for the search bar, with its own url, right? Yousuf Fauzan: you need a search result view Ari Hershowitz: So if I have the search bar on page x, I’ll have to call the search bar’s url from page x. Yousuf Fauzan: i.e. the url that the searcdh form will post to Ari Hershowitz: Yes, actually that’s the issue: I found that on each page I … -
Postgres user gone after lion update
-
Cài đặt Django trên Dreamhost
Mình đang sử dụng dịch vụ hosting trên Dreamhost và thấy khá thú vị vì các tính năng mà nó support từ SVN, Unlimited Bandwidth và Unlimited Storage. Thú vị hơn là mình có thể cài Django trên đó để có thể thực hành được các ứng dụng nhỏ. Bài viết này sẽ cụ thể hóa cách cài đặt Django trên Dreamhost.Mặc định trên Dreamhost đã có cài Django, chúng ta có thể thấy được điều này nếu vào console python và gõ lệnh>> import django >> django.get_version()Kết quả trả về sẽ là version hiện tại của Django được cài trên host. Và mình có được version là 1.2.Hiện tại version mới nhất của Django là 1.3. Để cài đặt được version mới nhất ta làm theo các bước sau.Cài đặt Python virtualenv để có thể tự mình cài đặt các Python package. Kiểm tra trang virtualenv pypi để lấy bản mới nhất.wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.3.tar.gz tar xzf virtualenv-1.6.3.tar.gz python virtualenv-1.6.3/virtualenv.py $HOME/local rm -rf virtualenv* export PATH=$HOME/local/bin:$PATHBạn nên sửa lại ~/.bashrc như sauexport PATH=$HOME/local/bin:$PATHKiểm tra lại đường dẫn đến python bằng lệnh which python, kết quả trả về là /home/youruser/local/bin/python chứ không phải là /usr/bin/python.Giờ chúng ta có thể cài (cập nhật) … -
Opportunism and other approaches to action in Software Architecture
Venkatesh Rao's onthology of decision making can be a source of inspiration for software architectures. I discuss four approaches to action taking in web development. -
A taste of the Django on inside Mozilla, Sheriffs Duty
One of the many great things about working for Mozilla is that everything we do is Open Source. Even our wiki is open (however we have an internal wiki for corporation boring stuff such as meeting rooms, HR etc.) Last week I wrote an internal application for Mozilla's build engineers. Essentially it's a roster that lists one user per day and it's helped by being visualized as a calendar and as a vCal export. It's very unlikely that anybody outside Mozilla will find this particularly useful. But who knows, perhaps other companies have needs to take turns to sheriff build machines. Anyway, the project was easy to write because we have something called Playdoh. It's a set of nifty and useful settings and a folder structure and it comes with a submodule called "playdoh-lib" which is stuffed with lots of useful packages that you'll most likely want to use. If you browse Playdoh on Github it might look like a lot of stuff but after a second look you'll see that there's actually almost no code. So don't you dare to play the "bloat card"! :) What this app uses is TastyPie for the REST API which was awesome by … -
A taste of the Django on inside Mozilla, Sheriffs Duty
One of the many great things about working for Mozilla is that everything we do is Open Source. Even our wiki is open (however we have an internal wiki for corporation boring stuff such as meeting rooms, HR etc.) Last week I wrote an internal application for Mozilla's build engineers. Essentially it's a roster that lists one user per day and it's helped by being visualized as a calendar and as a vCal export. It's very unlikely that anybody outside Mozilla will find this particularly useful. But who knows, perhaps other companies have needs to take turns to sheriff build machines. Anyway, the project was easy to write because we have something called Playdoh. It's a set of nifty and useful settings and a folder structure and it comes with a submodule called "playdoh-lib" which is stuffed with lots of useful packages that you'll most likely want to use. If you browse Playdoh on Github it might look like a lot of stuff but after a second look you'll see that there's actually almost no code. So don't you dare to play the "bloat card"! :) What this app uses is TastyPie for the REST API which was awesome by …