Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Petit resum d'estiu
Fa un grapat de setmanes que no escric res a aquest blog, tenc moltes coses pendents, però entre unes coses i altres el temps va passant i fins avui no he trobat una estona per a tornar-hi. Han estat unes setmanes molt estranyes: problemes personals, alguns bons, com les noces de la germana i altres no tan bons, molta feina i com no, el començament de l'escola dels menuts i la festa de la Vermada que ja és aquí. En el terreny de la feina tenc dues bones notícies: hem posat ja en producció un projecte que em fa una especial il·lusió txerpa i una web presencial fiscontrol. txerpa és un projecte que hem desenvolupat per a una coneguda gestoria/assessoria de l'illa. Integra una web, un backoffice per a la gestió d'empreses via OpenERP i la integració amb el mateix OpenERP de manera que es poden crear molt fàcilment instàncies personalitzades per a poder dur una comptabilitat i gestió. El projecte des del punt de vista tècnic ha estat molt engrescador. És un projecte amb un llarg recorregut en el qual esperam poder-hi afegint millores i nova funcionalitat. L'interessant, però, és veure que des d'aquestes illes nostres iniciatives com aquestes … -
Geo Django Quickstart
GeoDjango is a very powerful tool for storing and manipulating geographic data using the Django ORM. It provides a simple API to determine distances between two points on a map, find areas of polygons, locate the points within a polygon, and much more. GeoDjango is fairly well documented on the ... -
BestBuy Fantasy Footaball Launches
Launched back before NFL week 1. But, that was DjangoCon 2011, so the post happens today. Best Buy's site is operating for the third year in a row. Originally it was open to the public, but now it is employee only. You play by selecting a line-up every week and play against your co-workers and against the CEO. Makes for really fun team building. It uses a fantasy games framework originally developed by Rudy Menendez and myself back in 2008 for Grupo RBS's first fantasy football game ever. It's evolved quite a bit over 3 years and it's now a mature fantasy games framework that can easily handle over 1000 sign-ups an hour before you need to start rain dances for your cloud server. It's built on top of Django 1.3, PostgreSQL 9 and standard LAMP stack within Linode.com. If you would like your own fantasy game running on your site, Inquire within. -
Load Testing with JMeter: Part 1 - Getting Started
Last week, Yann Malet and I gave a talk at DjangoCon about using performance analysis to spot bottlenecks in your application. Because of the somewhat broad scope of the talk, we were only able to briefly introduce the tools we use and how we use them. Over the next several weeks, we plan to dive a little deeper into some of those tools here on our blog. To start off, I’m going to go over our JMeter setup in much more detail. It is a very powerful tool capable of complex load tests, but it is very unfriendly to new users and the documentation is not ideal. I’ll go over the basics and cover a couple of tricky things like how to authenticate, and simulating Ajax requests. This information is presented with Django in mind, but should apply to any framework you’re working with. -
Django on the high seas!
Django on the high seas! -
A tip for speakers
A tip for speakers -
This is not how to be lazy
This is not how to be lazy -
Bulk inserts in Django
I recently found a way to speed up a large data import far more than I expected.The task was to read data from a text file and create data records in Django, and the naive implementation was managing to import about 55 records per second, which was going to take far too long given the ... -
Running Django on Windows (with performance tests)
Django is a trendy Python-based framework for web applications. Its ever-growing popularity owes to availability of quick development tools, inbuilt administrative interface and high operation speed. Unfortunately, until now there was no easy tried-and-true way to deploy and run Django-apps on Microsoft IIS web-servers. Here we introduce Helicon Zoo – a solution to run popular web-frameworks and applications with Microsoft IIS. It bases on Microsoft Web Platform Installer (WebPI) technology to deploy apps. WebPI also handles different dependencies and takes care of installation of necessary components, such as Python, IIS, various database drivers and modules. And, of course, Helicon Zoo itself which sticks it all to Microsoft IIS 7+. Development environment configuration Web development process implies use of two relatively independent environments – development and production. Helicon Zoo may be used in production as well as on developer’s machine, or in both places. In either case the sequence of actions might be: To start, you need to download Web Platform Installer from Microsoft website (http://www.microsoft.com/web/downloads/platform.aspx) and install it. WebPI already includes wide range of frameworks and applications for IIS like PHP, ASP.NET, WordPress, Drupal, phpBB. To launch Helicon Zoo add new feed to WebPI: Run WebPI and click Options. In … -
Widgets, Form Fields and Model Fields Explained
In any web application user data must be translated from HTML form data to native types and database types, and back again. Django web applcations are no different. The "right way" to handle custom types is to extend Django's widgets, form fields and model fields. However, understanding exactly how these types perform each step of the conversion can be confusing. This post will attempt to explain how the data is converted at each stage and offer some advice about creating custom widgets, form fields and model fields. This article is based on Django 1.3 and assumes the reader has experience creating and using Django forms, models and validation. -
django-radius
I've been working on a little Django app for a while now, which solves a problem I often come across in Django projects. django-radius allows a developer to use a 3rd party RADIUS server to provide authentication in their Django application. Not only this, though, it also allows the use of multiple RADIUS servers, which can be specified in whichever way makes sense. This might sound a little contrived, so I'll give an example. Imagine a web service, such as a helpdesk management system, whose users are organised into groups. Each user belongs to an organisation, which buys into the service on their behalf. Basecamp and Zendesk operate this model, to name just two. To login, a user must visit a particular URL - so that the system may determine which organisation that user belongs to (http://yourcompany.zendesk.com for example). Now imagine that this service wishes to provide external authentication to its customer's systems, using RADIUS. This means that there's no need for users to have yet another password on yet another system, and is generally a Good Thing™. In this scenario, the developers would have to find some way of validating the user's credentials using the correct RADIUS server, based … -
Improving select fields in Djago with django-ajax-selects
django-ajax-selects is a handy Django application that allows substituting select fields with ajax autocompleate fields. That can be done for example for Django admin panel and ForeignKey, ManyToMany fields. It solves the problems with select fields containing a lot of values. -
A prayer to the programming gods
O gods of software development and operations, I have sinned. Your anger falls on me, and I feel your wrath... -
Django-uni-form 0.9.0 is out [security fix]
Version 0.9.0 is out and you should update because of security reasons. An XSS bug has been fixed, thanks to Charlie Denton for reporting it. If you are using django-uni-form and a form field that renders the input of a field as part of the error message without sanitizing it, such as ChoiceField, you are vulnerable to it. This is because errors are rendered using |safe filter. This has been addressed as fast as possible. Fixes for previous versions might come in the soon future. PyPi package has been update so you can do: pip install --upgrade django-uni-form This is the commit that introduced the security bug, as you can see it affects version 0.7.0 and forward versions. I want to thank every contributor and user that has made this version rock even more than previous ones. Bug fixes It’s got support for show_hidden_initial, Fieldset’s legends internationalization, error_css_class and required_css_class. MultiField layout object has fixed markup and has been optimized. Performance boost The project has seen several performance tune ups, related to templates handling, that make it run blazing fast. You can run now django-uni-form without template caching only one second slower than the cached version. Customizable templates All layout … -
Django-uni-form 0.9.0 is out [security fix]
Version 0.9.0 is out and you should update because of security reasons. An XSS bug has been fixed, thanks to Charlie Denton for reporting it. If you are using django-uni-form and a form field that renders the input of a field as part of the error message without sanitizing it, such as ChoiceField, you are vulnerable to it. This is because errors are rendered using |safe filter. This has been addressed as fast as possible. Fixes for previous versions might come in the soon future. PyPi package has been update so you can do: pip install --upgrade django-uni-form This is the commit that introduced the security bug, as you can see it affects version 0.7.0 and forward versions. I want to thank every contributor and user that has made this version rock even more than previous ones. Bug fixes It’s got support for show_hidden_initial, Fieldset’s legends internationalization, error_css_class and required_css_class. MultiField layout object has fixed markup and has been optimized. Performance boost The project has seen several performance tune ups, related to templates handling, that make it run blazing fast. You can run now django-uni-form without template caching only one second slower than the cached version. Customizable templates All layout … -
Django class-based generic views
Antes do Django 1.3, as generic views eram apenas métodos, essa versão do Django traz um novo estilo de uso, baseado em classes. Generic views foram criadas para evitar a repetição de padrões, por exemplo, sempre que você faz um formulário você terá uma ação caso o formulário seja válido, outra caso contrário. Existem muitos casos onde nos repetiremos. Um exemplo de listagem, sem o uso de uma generic view: from django.shortcuts import render def list_posts(request): posts = Posts.objects.all() render(request, 'posts/list_posts.html') Essa view é bem simples, mas poderia ser ainda mais simples com o uso de uma generic view, veja: form django.views.generic import ListView class PostLists(ListView): model = Post template_name = 'posts/posts_list.html' Se você não precisa customizar nada na sua view, pode simplesmente usar a view padrão do Django em seu urls.py: #... from django.views.generic import ListView urlpatterns = patterns('', (r'^posts/', ListView.as_view(model=Post)), ) O código anterior dispensa uma view explícita no arquivo views.py. As generic views baseadas em classe tem uma estrutura básica padrão: Todas elas herdam em sua base, da classe View e de alguns outros mixings, veja a definição da classe ListView e das classes da qual ela herda: # django/views/generic/list.py class ListView(MultipleObjectTemplateResponseMixin, BaseListView): ... class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): ... … -
Google+ API and Django Authentication Backend
The Google+ developers API was released a couple of days back, I was really excited to try it out. I saw that the initial release comes with a starter project in Python for Google App Engine only. Now, when trying it out, I decided why not create a Django pluggable app for it. So, I decided to create a django app to provide a fully integrated Django style authentication backend for Google+. And thus, it comes as the newest addition to the django-custom-auths project of mine. Check the project in GitHub for details. I guess this is the first application which aims at integrating Google+ API with Django. Plese feel free to try it out. Any comments, criticism and suggestions are most welcome. Find it here: https://github.com/subhranath/django-custom-auths -
Google+ API and Django Authentication Backend
The Google+ developers API was released a couple of days back, I was really excited to try it out. I saw that the initial release comes with a starter project in Python for Google App Engine only. Now, when trying it out, I decided why not create a Django pluggable app for it. So, I decided to create a django app to provide a fully integrated Django style authentication backend for Google+. And thus, it comes as the newest addition to the django-custom-auths project of mine. Check the project in GitHub for details. I guess this is the first application which aims at integrating Google+ API with Django. Plese feel free to try it out. Any comments, criticism and suggestions are most welcome. Find it here: https://github.com/subhranath/django-custom-auths -
Stopforumspam Django Middleware
I have created a new Django app for keeping out spammers on the basis of data collected by stopforumspam.com. Read all about it here » It’s free, open source, and I hope people will make it better on github. -
Hosting Django under different locations with Nginx and gunicorn
Do you know how Django uses SCRIPT_NAME? It's not often I host different instances of Django under different locations on the same domain. One legacy install has been setup that way for over a year with Apache2 and mod_wsgi (with Nginx infront). Almost all of my new deployments use virtual hosts with different subdomains for each service. If you are using virtual hosts with Nginx it looks like this: server { listen 80; server_name service.albertoconnor.ca; # other settings location / { try_files $uri/index.html $uri.html $uri @cluster; } location @cluster { proxy_pass http://service.albertoconnor.ca; } } Assuming you have defined an upstream server cluster called "service.albertoconnor.ca". If you are doing something by location on the same domain it might look something more like this: server { listen 80; server_name _; # other settings... location /a/ { proxy_pass http://127.0.0.1:8001/; } location / { proxy_pass http://127.0.0.1:8080/; proxy_redirect off; } } The idea is that something else, let's say Apache2, is running on 127.0.0.1:8080, and Django being served by gunicorn is running on 127.0.0.1:8001. So under /a/ the pages will be generated by Django; anywhere else Apache2 takes over. If you try this though, things will go horribly wrong. Besides redirects not working because you … -
Hosting Django under different locations with Nginx and gunicorn
Do you know how Django uses SCRIPT_NAME? It's not often I host different instances of Django under different locations on the same domain. One legacy install has been setup that way for over a year with Apache2 and mod_wsgi (with Nginx infront). Almost all of my new deployments use virtual hosts with different subdomains for each service. If you are using virtual hosts with Nginx it looks like this: server { listen 80; server_name service.albertoconnor.ca; # other settings location / { try_files $uri/index.html $uri.html $uri @cluster; } location @cluster { proxy_pass http://service.albertoconnor.ca; } } Assuming you have defined an upstream server cluster called "service.albertoconnor.ca". If you are doing something by location on the same domain it might look something more like this: server { listen 80; server_name _; # other settings... location /a/ { proxy_pass http://127.0.0.1:8001/; } location / { proxy_pass http://127.0.0.1:8080/; proxy_redirect off; } } The idea is that something else, let's say Apache2, is running on 127.0.0.1:8080, and Django being served by gunicorn is running on 127.0.0.1:8001. So under /a/ the pages will be generated by Django; anywhere else Apache2 takes over. If you try this though, things will go horribly wrong. Besides redirects not working because you … -
Working with the Django admin and legacy databases, pt.3
Working with the Django admin and legacy databases, pt.3 -
Working with the Django admin and legacy databases, pt.2
Working with the Django admin and legacy databases, pt.2 -
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally
Contributing to Django Documentation, Part 1: Generating and Editing Documentation Locally -
Image resizing on file uploads. Doing it the easy way.
Image resizing on file uploads. Doing it the easy way.