Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 … -
Introduction to Django Selenium Testing
If you’ve never heard of Selenium, put simply, it’s a tool that allows you to create tests that are run in the browser and interact with your UI in the same way as if you were manually testing your website or app. It’s the de-facto standard to test complex Web UI interactions that usually involve a heavy use of JavaScript, and that’s probably the main use-case for it. Other than that, we also use it sometimes as a helper tool for cross-browser design (CSS) testing by running Selenium tests through different browsers and taking screenshots or recording videos. Selenium’s been around for a long time now, and is available in various programming languages, but up until Django 1.4 came along you couldn’t have your Selenium tests (easily) integrated with your Django test suite. Since then, a new class named LiveServerTestCase, that your Selenium test classes can inherit from, was introduced. This class will automatically run a test server in the background and your Selenium tests will be run against that server. It not only simplifies the process, but it also means your tests can be setup the same way your Django tests are, and so both can be run together … -
Introduction to Django Selenium Testing
If you’ve never heard of Selenium, put simply, it’s a tool that allows you to create tests that are run in the browser and interact with your UI in the same way as if you were manually testing your website or app. It’s the de-facto standard to test complex Web UI interactions that usually involve a heavy use of JavaScript, and that’s probably the main use-case for it. Other than that, we also use it sometimes as a helper tool for cross-browser design (CSS) testing by running Selenium tests through different browsers and taking screenshots or recording videos. Selenium’s been around for a long time now, and is available in various programming languages, but up until Django 1.4 came along you couldn’t have your Selenium tests (easily) integrated with your Django test suite. Since then, a new class named LiveServerTestCase, that your Selenium test classes can inherit from, was introduced. This class will automatically run a test server in the background and your Selenium tests will be run against that server. It not only simplifies the process, but it also means your tests can be setup the same way your Django tests are, and so both can be run together … -
The missing documentation for django.utils.datastructures
Note django.utils.datastructures is intentionally not documented by the django core devs because it is an internal API and is liable to change without any notice. This file is not governed by django's lenient backwards-compatible policy. You have been sufficiently warned! With the note out of the way, let's look at the interesting datastructures in this file. You may ask why we should learn about those when we shouldn't be using them? Reading code is the best way of learning and this file has some beautiful code. MergeDict is the first of the datastructures in the file. It provides a dictionary like interface but can look up from multiple dictionaries provided during the initialization. Here's an example: >>> md = MergeDict({"foo": "bar", "moo": "cow"}, {"abc": "def"}) >>> md["foo"] 'bar' >>> md["abc"] 'def' >>> md.get("abc") 'def' >>> md["xyz"] KeyError: >>> md.items() [('foo', 'bar'), ('moo', 'cow'), ('abc', 'def')] >>> md.keys() ['foo', 'moo', 'abc'] >>> md.values() ['bar', 'cow', 'def'] The MergeDict is used within django in attaching values with a form widget and in request.REQUEST. The built-in dictionary does not maintain the order of the items but the SortedDict is a subclass of the built-in dictionary that maintains the keys in exactly the same … -
django-scribbler, a lightweight front-end interface for Django template editing
django-scribbler is a new open-source project published by the team at Caktus. Its goal is to create a seamless way for authorized end users to make edits to specific blocks of content in their Django template. The original project idea came from a conversation Mark and I had about a front end editor Mark was working on. His original idea included a toggled area on the page where users could preview the changes to the content. I suggested it would be even better by showing the user their changes as they were making them. That inspiration came from Bret Victor's talk on “Inventing on Principle”. In his talk, he explains that creators need and “immediate connection to what they create.” To create this effect of seeing your edits as they happen, the developer defines blocks in the template that can be edited by the end user on the front end. Once logged in, that user is able to hover over those blocks and edit as they see fit. The user immediately can see their changes. When they are ready, they can save changes to the database or even save as a draft. During Caktus's Inaugural ShipIt Day, Mark and I …