Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
One of the Biggest Mistakes Django Developers Make When Using Lettuce
This post is the first in a series of posts about best practices when using Lettuce, a testing framework for Django. When I first released Lettuce, a framework for writting automated tests in Django with user stories, I had no idea that it would have become so widely used. It’s been truly amazing to have seen it expand from Brazil to the United States to China and many other countries. It’s even been translated into 15 languages. However, over the last 6 months, I’ve observed a common usage that, for the reasons below, developers should avoid. Steps from Step Definition Like Cucumber, Lettuce supports calling other steps from a step definition. This can be a very handy functionality, but can easily become a source of code that is hard to maintain. So why is this functionality available? Although Lettuce is a testing tool, step.behave_as was a patch that was incorporated in the codebase without complete test coverage. step.behave_as causes a step to call many others by parsing the text and calling them synchronously and sequentially. Some people like to use this functionality in order to make their scenario look leaner, which is fine. The actual problem is that this workflow … -
Starter fabfile and scripts for a Django project on Webfaction
A quickstart for deploying a Django project to a shared hosting system like WebFaction. -
New Year’s Python Meme
I love these blog memes, so I give you my version of Tarek Ziade's New Year's Python Meme.1. What’s the coolest Python application, framework or library you have discovered in 2011?For python libraries, that would have to be Kenneth Reitz' python-requests library. I've used it for an amazing amount of stuff and blogged about it. It took the grunge out of doing HTTP actions with Python. The API is clean and elegant, getting out of your way. It embodies the State of the art for API design, which closely matches the Zen of Python.For applications, djangolint.com is awesome. It has helped me out so much on several projects. I would love to see something like this implemented and maintained for modern Python.All the Python friendly PaaS efforts that have emerged are changing the landscape for those of us who want to launch projects but don't want to become full time system administrators in the process. Heroku, DjangoZoom, DotCloud, ep.io, gondor.io, and others are making it possible for developers to focus on development not server tooling. Google App Engine paved the way and it is wonderful to see the rest of the universe catch up with material that more closely follow … -
django-statsd
A while ago Jeff Balogh and James Socol got statsd and graphite running for web development projects at Mozilla. They wrote some great code including pystatsd and commonware. This allows us at a glance to see what's going on in AMO and SUMO and whole host of other projects. Since then graphite has become a key part of our process. I can't imagine running a large site without it. I started playing around with some tighter integration between Django and pystatsd a while back. That resulted in a pull request to pystatsd which James didn't want, he wanted to keep pystatsd Python only. Made sense, so then I wrote django-statsd which provides some optional deeper integration between Django and statsd. To install add in INSTALLED_APPS: django_statsd You can now choose your client by configuring settings.py. By default statsd will send UDP packets on your development box. To turn that off use a null client, for example: STATSD_CLIENT = 'django_statsd.clients.null' You'd use django_statsd.clients.normal on your production boxes, or anything you want to measure. This library includes a few useful ways of sending timings. I pulled the middleware out of the afore mentioned commonware (credit to James and Jeff for that) so … -
Function caching decorator
Every once in a while, you have to create a function in one of your models, that does a lot of queries. If you use that function a couple of times, you might find it a wise thing to 'cache' the function. A 'cached' function will look like this: def get_important_data(self): if not hasattr(self, _important_data): self._important_data = self.get_result_of_lots_of_queries() return self._important_dataIf you call this function once on an object, it will run a lot of queries, but will store the result in self._important_data. The next time you call the function on this exact same object, the attribute self._important_data will still be set and the huge load of queries do not have to be executed again.In some projects you have to create such a function more than once, for whatever reason. A colleague got sick and tired of writing the same code over and over again and came up with an idea to tackle this concurrency. So he asked me if, when I had little to do, I could write a decorator that does exactly the same kind of 'caching' as the function above. I however have little to no experience in writing decorators, so I copy/pasted something together from the interwebz, … -
IP Street will consider more than three Django developers
My Senior Developer job description had an embarrassing mistake. It asked for 7+ years experience in Python and Django, which, as a commenter noted, limited the candidate pool to about three people on the entire planet. I’ve fixed my goof. We’re nominally looking for at least seven years of Python experience, and at least three years of Django experience, for this slot. Tagged: Django, jobs -
Django powered Christmas Card
Merry Christmas -
Forms Part 1: Raw Forms
Forms are generally a pain to deal with when doing sites. This is the first video in a series to help make forms in django easier to do and understand. We start with doing raw forms and not using any of the django helpers so we can understand what the helpers are doing in the future.Watch Now... -
Forms Part 1: Raw Forms
Forms are generally a pain to deal with when doing sites. This is the first video in a series to help make forms in django easier to do and understand. We start with doing raw forms and not using any of the django helpers so we can understand what the helpers are doing in the future.Watch Now... -
Using Django and Celery with Amazon SQS
Amazon's Simple Queue Service (SQS) is a relatively new offering in the family of Amazon Web Services (AWS). It's also an appealing one, because it proposes to quickly and easily replace a common component of the stack in a typical web application, thereby obviating the need to run a separate queue server like RabbitMQ. While ... -
Using Django and Celery with Amazon SQS
Amazon's Simple Queue Service (SQS) is a relatively new offering in the family of Amazon Web Services (AWS). It's also an appealing one, because it proposes to quickly and easily replace a common component of the stack in a typical web application, thereby obviating the need to run a separate queue server like RabbitMQ. While ... -
Using Django and Celery with Amazon SQS
Amazon's Simple Queue Service (SQS) is a relatively new offering in the family of Amazon Web Services (AWS). It's also an appealing one, because it proposes to quickly and easily replace a common component of the stack in a typical web application, thereby obviating the need to run a separate queue server like RabbitMQ. While ... -
IP Street is looking for a Senior Developer
We’re looking to hire two lucky people who desire fame and fortune. Here’s the Senior Developer opening: Founded in 2009, IP Street develops and markets software to help corporations, law firms, financial research firms, and government agencies better analyze patent-related information. Our goal is to make IP data easy to get, use, and understand, so everyone can have access to high quality and transparent information. We’re seeking a great Python developer with experience in: Automated workflows that process millions of objects; data quality metrics and repairs; search, particularly with Solr or Lucene; and/or general data mining. Our stack, and development & production environments, are almost all open-source. The key technologies are Python, Django, Celery, Solr, and PostgreSQL. You’ll be joining us at a great time! Revenue is coming in, we’ve done two Angel funding rounds at increasing valuations, and have $ in the bank. If you want more responsibility and authority, no problem, you can have as much as you want! Key Responsibilities. Enhance and extend existing code base to add new features to the product Extend Solr engine to provide more statistics and meaningful analytics to the product Design or co-design new product features, including designing the client and … -
Redux: Extending the Django User model with inheritance
I just packaged up and released a small bit of code last night. Mostly because I wanted to extract it from my project to reuse later, but also because I thought it was cool enough to share. It really is small. Just a few lines of code, as it’s basically just a clever use of the InheritanceQuerySet provided by django-model-utils. I suppose I could have copied that bit of code into my app, but django-model-utils is small and has some great stuff that I’ve started using in all of my projects. So, allow me to share why I thought this bit of code is useful. I have a project that I’m working on that requires several different classes of authenticated users. Each user class has its own required fields and foreign keys and such. It was all complicated enough that a single user profile model wasn’t going to cut it. So I tried using a generic foreign key on the user profile that could be used to point to the “real” profile. Wow, was that a mess. Another requirement of my project is that all the users belong to a hierarchy. When a given user logs in, they need to … -
The Usage of the only() Method
Recently I found the only() method of a queryset which can significantly improve the loading speed of forms with ModelChoiceField or ModelMultipleChoiceField. Let's say we have a big Event model with thousands of instances: class Event(models.Model): title = models.CharField(_("Title"), max_length=200) # ... lots of other fields ... def __unicode__(self): return self.title Then we have a form with ModelMultipleChoiceField: class EventForm(forms.Form): related_events = forms.ModelMultipleChoiceField( queryset=Event.objects.all().only("id", "title"), label=_("Related Events"), required=False, ) # ... other fields of the form ... The used only() method loads only the primary key and the title for the selection widget. -
Announcing Consumer Notebook!
Need a Python programming language book? Want to see a comparison of the ones I own and use? Check out my Must-Have Python Programming Books comparison grid. Let's drill down and take a closer look at one of the items on the page, in this case Doug Hellmann's amazing The Python Standard Library by Example. The product detail pages include the ability to add pros and cons and attach said products to comparison grids and specialized lists like 'my wishlist' and 'my possessions'.Speaking of wishlists, check out my own:In order to add items, like footy pajamas, I click on the 'add' button and paste the Amazon (or BestBuy) URL into the form:At this time we just handle Amazon USA and BestBuy USA. In the future we plan on adding more affiliate providers, including non-USA providers to support our non-USA friends.There's a lot more than that...In addition to weekly infographics, comparison grids, lists, and products, Consumer Notebook also awards points, coins, badges, and a growing privilege set to participating users. We even implemented an energy bar which regenerates over time, designed to match the pace of human users and serve as one of the brakes on scripts and bots. TechnologyI built this with … -
Release 0.6.1
We just released LFS 0.6.1. This is a bugfix release. Following bugs have been fixed: fixed category management; issue #123 fixed adding of payment method: added csrf_token fixed german address form: removed "Area" field, made fields required fixed set/reset of product filters within management UI fixed amount of products per price filter step added translatable label for country field Additionaly the italian and dutch translations have been updated. Thanks to pippo64 and bastichelaar! Information You can find more information and help on following locations: Official page Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org Google Group lfsproject on Twitter IRC Support We also have added a new page about professional support for LFS. Watch it out! -
OpenBlock Geocoder, Part 2: Text Parsing and Entity Extraction
This is the second post in our OpenRural series reviewing OpenBlock and it's geocoder. OpenBlock Geocoder, Part 1: Data Model and Geocoding covers the internals of the OpenBlock geocoder and it's geocoding capabilities. As this posts builds upon topics covered there, you may wish to read Part 1 before proceeding. In this post we step ... -
OpenBlock Geocoder, Part 2: Text Parsing and Entity Extraction
This is the second post in our OpenRural series reviewing OpenBlock and it's geocoder. OpenBlock Geocoder, Part 1: Data Model and Geocoding covers the internals of the OpenBlock geocoder and it's geocoding capabilities. As this posts builds upon topics covered there, you may wish to read Part 1 before proceeding. In this post we step ... -
OpenBlock Geocoder, Part 2: Text Parsing and Entity Extraction
This is the second post in our OpenRural series reviewing OpenBlock and it's geocoder. OpenBlock Geocoder, Part 1: Data Model and Geocoding covers the internals of the OpenBlock geocoder and it's geocoding capabilities. As this posts builds upon topics covered there, you may wish to read Part 1 before proceeding. In this post we step ... -
Redux: Extending the Django User model with inheritance
I just packaged up and released a small bit of code last night. Mostly because I wanted to extract it from my project to reuse later, but also because I thought it was cool enough to share. It really is small. Just a few lines of code, as it's basically just a clever use of the InheritanceQuerySet provided by django-model-utils. I suppose I could have copied that bit of code into my app, but django-model-utils is small and has some great stuff that I've started using in all of my projects. So, allow me to share why I thought this bit of code is useful. I have a project that I'm working on that requires several different classes of authenticated users. Each user class has its own required fields and foreign keys and such. It was all complicated enough that a single user profile model wasn't going to cut it. So I tried using a generic foreign key on the user profile that could be used to point to the "real" profile. Wow, was that a mess. Another requirement of my project is that all the users belong to a hierarchy. When a given user logs in, they need to … -
Redux: Extending the Django User model with inheritance
I just packaged up and released a small bit of code last night. Mostly because I wanted to extract it from my project to reuse later, but also because I thought it was cool enough to share. It really is small. Just a few lines of code, as it’s basically just a clever use of the InheritanceQuerySet provided by django-model-utils. I suppose I could have copied that bit of code into my app, but django-model-utils is small and has some great stuff that I’ve started using in all of my projects. So, allow me to share why I thought this bit of code is useful. I have a project that I’m working on that requires several different classes of authenticated users. Each user class has its own required fields and foreign keys and such. It was all complicated enough that a single user profile model wasn’t going to cut it. So I tried using a generic foreign key on the user profile that could be used to point to the “real” profile. Wow, was that a mess. Another requirement of my project is that all the users belong to a hierarchy. When a given user logs in, they need to … -
Accept Credit Cards in Django with Authorize.Net
Accepting credit cards in your Django applications using the Authorize.Net payment gateway is easier than you might think. -
Authorize.Net Credit Card Form in Django
A Django form which submits a payment to Authorize.Net during form validation. -
Auto-Detecting Anomalies in Your Key Metrics
As your web application grows, so does the importance of monitoring. With more cogs in the machine, more things can go wrong. At Yipit, we want to find and fix application level errors in a timely fashion. While our test suite catches most bugs, some inevitably seep through. Whereas many tools such as Ylastic, AWS, Chartbeat, Munin, and Ganglia help mitigate the monitoring headache on the machine and network level, they don’t do as great a job at the application level. Where we envision Xenia Monitoring of Application Level Metrics at Yipit At Yipit, our application metrics consist mostly of user actions, or events. We log everything from opening our daily email and browsing the web interface to making an API call and using our mobile app. Up until now, we’ve relied on human monitoring, user complaints, and automated custom scripts to detect worrisome trends in our application metrics. However, our recent growth forced us to look into more scalable solutions to this problem. As such, we have begun developing an automated anomaly detection system for monitoring application level metrics more intelligently, code-named Xenia. Xena - the Warrior Princess Xenia (Not the Warrior Princess) The main purpose of Xenia is …