Generate Your Tests
When testing your application, you’ll often come across the need to test that your application behaves correct across a range of inputs or conditions. Instead of repetitively defining the same test scaffolding, let’s use some meta-programming to build our tests methods from a list of parameters. Nose has support for Generator Tests, but they don’t work with python’s unittest framework. Let’s walk-through how to build our own test generator that does.
Django Model Descriptors
How we can use Python Descriptors to create enhanced Django model fields that better encapsulate their functionality. This will help keep our code more modular and reusable and well as cleaner and more maintainable.
ElasticSearch Bliss with ElasticUtils
While Django Haystack remains the go to recommendation for adding simple search indexing to your Django sites, you can quickly outgrow the simplified “bag of text” data model that haystack attempts to unify the various supported indexing engines. Depending on your use case, you eventually need to customize the tokenizers, scoring, spell correct, autocomplete, etc. These more advanced use cases no longer work commonly across backends forcing you to leave the comfort of Haystack for native APIs for your chosen indexer. ElasticUtils is a newer project from the fine folks at Mozilla that exposes much of the rich capabilities of ElasticSearch in a more elegant, pythonic interface. Much like an ORM can simplify the process of generating SQL for your databsae queries, ElasticUtils provides a streamlined interface for generating search queries for the ElasticSearch Query DSL.
Getting Started with Django Rest Framework and AngularJS
A ReSTful API is becoming a standard component of any modern web application. The Django Rest Framework is powerful framework for developing ReST endpoints for your Django based project. AngularJS is modern javascript framework for creating complex web applications within the browser. It focuses on strong separation of concerns (MVC) and dependency injection to encourage creating maintainable (and testable) modules that can be integrated to develop rich client side functionality.
Batteries Included Django
A key benefit to using Python and/or Django for your next project, is the wealth of high quality 3rd party libraries that can help accelerate your development. Python has a rich ecosystem of 3rd party libraries including often offical bindings for an external service. This offers you significant tools to building rich, complex systems based on the available open source solutions. Django's popularity and architecture provides the opportuntiy to find many existing solutions to common problems. For education and discussion, I thought it would be helpful to enumerate the many libraries we currently use on Subblime to leverage the power of of the Python/Django ecosystem. A what's in our toolbox sort of post.
Django Model Behaviors
How do we manage the growing complexity of our Django models? Leverage the behavior pattern to keep them compartmentalized into discrete reusable functionality.