Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Des poneys avec des chapeaux ronds aka DjangoBreizh, les poneys envahissent la bretagne
Samedi 17 novembre c’était donc la première edition des DjangoBreizh, une rencontre django locale en bretagne organisé par Exirel (bon ok, je ne suis pas tout a fait breton et pourtant j’y étais mais j’étais une exception) Le programme se découpait ainsi : matin conférence début d’après midi LT reste de l’après midi barcamp ou atelier d’initiation Pour une première conf, et conf régionale qui plus est, je trouve que le public fut au rendez-vous. 27 personnes pour les conférences, c’est en effet une belle réussite. Pour l’occasion, la cantine numérique de Rennes avait prêté ses locaux toutes la journée, ce qui a permis de mettre en place les conférence du matin et l’atelier initiation du matin (les barcamps se passant à quelques dizaines de mettre à la maison des associations) Ce que je retiens de cette rencontre régionale (hormis le fait qu’à rennes, il pleut tout le temps) c’est : il peut être difficile d’avoir des conférenciers locaux, il suffit alors de les faire venir d’ailleurs (mais il y a eu un certain nombre de conférencier ‘du cru’ et ça fait plaisir) la partie barcamp est une partie toujours très intéressante et qui fonctionne vraiment bien l’atelier d’initiation était … -
Understanding decorators
Understanding decorators in Python ###We will divide this post into two topics 1. Functions are objects and they can be passed around. 2. Writing few decorators As usual, I will be trying out the code in ipython and I suggest you to do the same. ###Functions can be passed around similar to any other object in Python. If you are already familiar with this, you can skip to next section. Let's first write a class. >>> class A(object): ... def __init__(self, a): ... self.a = a ... Let's create an instance of this class. >>> obj = A(5) >>> print obj.a 5 #output Let's write a function that takes an object, increase the value of instance variable 'a' by 10 and return the object. >>> def func(some_obj): ... some_obj.a = some_obj.a + 10 ... return some_obj ... In function **func**, our assumption is that we will always pass it an object as argument and this object will have an instance variable 'a'. Let's pass the created object **obj** of class A to this function and take the return value of this function in a variable named obj2. >>> obj2 = func(obj) >>> print obj2.a 15 We wrote a function 'func' … -
Things I learned from looking at graphs
We use Graphite to see how the Firefox Marketplace and Add-ons sites are doing. But the sheer volume of traffic to Add-ons always gives some interesting graphs. A while back we were switching between different clusters for add-on version check as the hardware behind it changed. As we switched clusters, we also switched from a hot cache to a cold cache. This resulted in a spike in traffic: That’s almost 45,000 requests per second coming into version check and being processed by Python and MySQL. With hardly a blip on the hardware loads, we processed that quickly. We can see the affect as the cache picked up the slack, it falls down to the usual 8,000 requests per second. Crazy traffic. We get a large number of requests to version check for a small number of add-ons. Like Adblock Plus which, as of writing this post, has over 15 million users. That’s pretty awesome. Looking at the traffic to Add-ons site (excluding version checks), traffic is very consistent depending upon the time of day. So when are those times? Here’s a graph of today’s traffic that I’ve annotated. Our low point is as India wakes up. It goes up as … -
Using South for schema and data migrations in Django
South is a schema and data migrations for Django. In an easy way you may update your database tables after you change your models. It also keeps all migrations in the codebase allowing to migrate backward if needed. In this article I'll show some standard South usage cases. -
Continuous integration of Django projects with Jenkins
Jenkins is a tool for watching or managing jobs. Either external like cronjobs or executing "build and test" jobs of your Django projects. There is even more, but in this article I'll focus on a basic Jenkins setup - building and testing a Django project. For Django there is django-jenkins that allows an easy integration with Jenkins tools like nice visualization of code coverage, pep8/pylint/pyflakes code violations. In this article I'll setup a local Jenkins configuration that will look on a folder with the code. In real world Jenkins would watch a repository and execute a job when a new changeset shows up. -
Using South for schema and data migrations in Django
South is a schema and data migrations for Django. In an easy way you may update your database tables after you change your models. It also keeps all migrations in the codebase allowing to migrate backward if needed. In this article I'll show some standard South usage cases. -
Using memSQL and MariaDB in Django projects
memSQL is a new database engine offering high efficiency thanks to RAM oriented data storage design and query compilation (check the FAQ). It's not related to MySQL but it offers a MySQL compatible client - and that allows easy, quick way to check it. MariaDB is a MySQL fork, binary compatible with it. This database server can be used as a drop in replacement for MySQL. The difference is in some extra features and extra storage engines added to MariaDB. -
Making Django and Javascript work nicely together
Backend and frontend cooperation may not be an easy task. For example in javascript code you may need some URLs to views or to icons required for some widgets. You can hardcode it or cleverly pass required data from backend to frontend. Also AJAX requests often want batches of data in JSON format. There is a way to make it quickly and clean. In this article I'll show some Django applications and solutions for much easier backend - frontend cooperation. -
Temporary files in Django for tests and on the fly file manipulation
Sometimes you need to do some operations on files on the fly in the code and place the result for form validation or save it with a model instance. When you want to write forms tests files may also be needed. To avoid using extra static files for tests you can use some temporary files. All those (and more) can be done with in-memory / temporary file-like objects. On the web there are StringIO or ContentFile usage examples but they wont work always - or as good as Django InMemoryUploadedFile object would. Here is an example of InMemoryUploadedFile usage for tests and other similar cases. -
Continuous integration of Django projects with Jenkins
Jenkins is a tool for watching or managing jobs. Either external like cronjobs or executing "build and test" jobs of your Django projects. There is even more, but in this article I'll focus on a basic Jenkins setup - building and testing a Django project. For Django there is django-jenkins that allows an easy integration with Jenkins tools like nice visualization of code coverage, pep8/pylint/pyflakes code violations. In this article I'll setup a local Jenkins configuration that will look on a folder with the code. In real world Jenkins would watch a repository and execute a job when a new changeset shows up. -
Shops near you – geographic features of GeoDjango
Boom on mobile devices and widespread Internet access created a demand for applications aware of user geographic location. Nowadays using modern web frameworks with magical powers you can make such geo-enabled web applications easily. Django offers a special sub-framework called geodjango. There you will find an enormous amount of features of "geographic" nature. In this article I'll present a simple application that will use a part of GeoDjango to search and display shops closest to given address. -
Testing Django applications with Selenium
Selenium is a popular tool for browser automation. Main usage for Selenium are browser based tests of web applications. With a real browser and handy API you can test frontend behavior of an application (like JavaScript code). In Django 1.4 we got LiveServerTestCase - a TestCase that spawns a test server. This allowed much easier Selenium integration in Django tests. You can change a presentation on benlopatin.com. If you will find something different - check the date as it may describe older solutions for older Django versions. In this article I'll show some basic Selenium usage cases in tests - showcasing the api. -
Aiding tests with Ludibrio stubs and mocks
In tests we assume some input data and check if the output is equal to what we expect it to be. Sometimes is impossible to set the initial data as the code fetches some data from a third party API, or creates some data on its own (like random data). To aid testing of such code we can use ludibrio. It can mock or stub existing classes or functions making them work as we program it. -
REST API creation with django-tastypie
django-tastypie is probably the best at the moment tool for REST API creation in Django applications. The code is on github and documentation is on readthedocs.org. With tastypie it's easy to create REST API that will allow easy web access to data stored in models - get, update, edit or delete. In this article I'll show some basic usage of tastypie. -
Managing style sheets and JavaScript files with webassets
webassets is an application that manages (compress and join) static files like JavaScript or CSS (LESS, SASS too) files. It can work with various frameworks, including Django. Everything is described in the documentation. Compressed files have slightly smaller size and they load faster. One file made out of multiple CSS or JS files reduces the amount of HTTP requests needed to load the website. That also improves the load times. -
One Change Is Not Enough
Sometimes just doing one major infrastructure move at once isn't quite enough to whet my appetite. Last week, me and the rest of the Lanyrd team pulled off two major infrastructure changes in two hours - see our blog post on the move for some background information as well as an overview of the timeline. I'd like to take a closer look at the technical details of this move and show how exactly we pulled off changing our hosting provider, database vendor and operating system version all in one go. Hosting For many startups, there comes a time when the switch to dedicated hardware and a more 'traditional' hosting model makes sense, and Lanyrd is one of those - we're fortunate to be at least partially a content-based site, and have two distinct advantages: Most traffic spikes are to one or two conference pages, and are an easily cacheable pattern. Conferences are planned well in advance, so we get good notification of when to expect high-traffic periods for more interactive use. This means that we're not subject to a huge amount of daily variation or unpredicted traffic spikes, and even if we get some, we have enough overhead to deal … -
Einladung zur Django-UserGroup Hamburg am 14. November
Das nächste Treffen der Django-UserGroup Hamburg findet am Mittwoch, den 14.11.2012 um 19:30 statt. Dieses Mal treffen wir uns in den Räumen der intosite GmbH im Poßmoorweg 1 (3.OG) in 22301 Hamburg. Da wir in den Räumlichkeiten einen Beamer zur Verfügung haben hat jeder Teilnehmer die Möglichkeit einen kurzen Vortrag (Format: Lightning Talks oder etwas länger) zu halten. Konkrete Vorträge ergeben sich erfahrungsgemäß vor Ort. Eingeladen ist wie immer jeder der Interesse hat sich mit anderen Djangonauten auszutauschen. Eine Anmeldung ist nicht erforderlich, hilft aber bei der Planung. Weitere Informationen über die UserGroup gibt auf unserer Webseite www.dughh.de. -
Django 1.5, Python 3.3, and Virtual Environments
Today I wanted to tinker around with the experimental support for Python 3 in Django 1.5 (alpha). -
Managing style sheets and JavaScript files with webassets
webassets is an application that manages (compress and join) static files like JavaScript or CSS (LESS, SASS too) files. It can work with various frameworks, including Django. Everything is described in the documentation. Compressed files have slightly smaller size and they load faster. One file made out of multiple CSS or JS files reduces the amount of HTTP requests needed to load the website. That also improves the load times. -
SendGrid Events and Eldarion Open Source
Yesterday, I blogged about one of our new open source Django apps, django-sendgrid-events. It's a small app, in terms of lines of code and/or complexity, but I think it opens up a ton of potential in things you can do for users of your site.In addition, to making that post yesterday, we updated our Open Source page with half dozen or so new Django apps that we have released throughout 2012.In addition, we have been gettings tons of great feedback from a post published about a month ago, entitled 5 Reasons to Hire an Agency. If you are in the position of looking to hire new engineers either as full time employees or as contractors then give this post a read first. If you have any questions at all I welcome the opportunity to speak with you on the phone, take your emails, or respond publicly to comments on this post.Go check these things out! I know you'll find more than a couple things useful if you are setting out to build a new site today, or even updating an old favorite. -
Django Extensions 1.0.1
Minor version update Django-Extensions 1.0.1 is out. This release fixes the following problems: spelling typo in README tests: shebang line in run_tests.py logging: Fix compatibility with python 2.6 media: Fix media directory in packaging admin extensions: Do not $ in javascript to avoid conflicts and redefines. -
How to create a virtual environment that also uses global modules
Last weekend I upgraded my Mac to Mountain Lion. I installed Python 2.7 with PIL and MySQLdb and virtualenv using MacPorts. When I created and activated a virtual environment with cd myproject virtualenv . . bin/activate the PIL and MySQLdb modules were unrecognizible in that environment. What I needed was just different Django versions in my virtual environments, but MySQLdb and PIL libraries had to be shared. After a quick search I found an additional parameter for the creation of virtual environment: virtualenv --system-site-packages . With this parameter I could use my global modules within the virtual environment. -
Not exactly, not exactly tim the enchanter
I've been putting off writing about my experience with django form wizard for some time now. I came across this blog post by Kenneth Love which finally compelled me to write this down. About Django Form Wizard: Form Wizard can be handy when you have a huge form, and you want to make it less intimidating to the user by splitting it into multiple steps. If you have glued multiple forms together with sessions or whatnot and it turned out to be a mess, you now what I'm talking about :) Think surveys, checkouts, lengthy registrations etc. The class WizardView implements most of functionality while subclasses SessionWizardView, CookieWizardView etc. specify which backend to use. Typically, the view takes a list of forms and presents them one by one. After each step, the form is validated and the raw form data is saved in the backend (session or cookie for POST data and file_storage for files). After the last step, each form is filled with raw data from the backend and validated again. The list of fully-filled up form instances is then passed to the done handler where the forms can be processed. I guess the key bit of info here … -
Django Beginner Series - Introduction
Some Twitter followers could already know that I am working on a book. Just not what it is about. Big announcement: It will be about web application development using Django. It is supposed to be an easy entry in the world of Django and tries to cover as much as possible in a simple way to get started with the framework. If you do not care why I am doing this skip to "ideas and how this blog is involved" to get an idea what tutorials I will post in the course of the next weeks. Django is the best documented project I know. You can find nearly anything in the documentation and if you are not comfortable browsing it you can just read the code with comments. But there is something Django lacks. I know that not everyone agrees with me on this. But I also know how many people asked me basic things they could not figure out just from reading the tutorial. Django needs some basic introduction material. I do not think it would be wise to rewrite the whole documentation. If I want to know something about a model field, how a battery works or just … -
Not Exactly Tim the Enchanter
Django has always been hailed as having great, awesome documentation. And, for the most part, this distinction has been deserved. But every once in a while, you find an area that's just...lacking. An area that you know exists but you've never gone into because it didn't come up and no one else used it but then you finally got a reason to use it...and then you find out it's so lacking in documentation that you have to dive into the source code. This is one of those areas. Welcome to Django Form Wizard. What is Django Form Wizard? At it's most basic, Django's Form Wizard (DFW from now on, OK?) is a way to auto-generate a set of views w/ a single form in each view. Most of the time it uses one template but you can have a different template for each view. Most wizards have numbered steps but you can have named ones if you want. Also, most wizards deal with standard forms (highly recommended) but can, of course, use formsets and model forms. You've all used wizards before, I'm sure. A set of forms that you fill out in order and, at the end, something larger is …