Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Class-based views in Django 1.3
Django class-based views Introduction Django 1.3 added class-based views, but neglected to provide documentation to explain what they were or how to use them. So here's a basic introduction. Example of a very basic class-based view Let's start with an example of a very basic class-based view. urls.py: ... url(r'^/$', MyViewClass.as_view(), name='myview'), ... views.py: from ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
OpenBlock Geocoder, Part 3: External Geocoders
The OpenBlock geocoder is powerful and robust. It uses PostGIS for spacial queries, can extract addresses from bodies of text, and can understand block and intersection notation. We've run into a few issues with it, however, including a low geocoding success rate. This is a tough problem to solve and depends on a lot of ... -
Quick Optional Model Fields Trick
This is just something I do now. It’s DRY, saves a few keystrokes, helps stay under pep8’s 79 character limit, and improves readability in my opinion. http://gist.github.com/1526444 -
Django Caching in the Real World: Part 1
When you develop a sizable content heavy web site you quickly learn, hopefully not the hard way, that caching is a very important piece of your infrastructure. The database servers are the typical bottleneck in high volume website. In this series, we’ll explore the a caching strategy we recently implemented. -
Resum del 2011
Ara que ja estam a punt d'acabar el 2011 faré el que toca fer per aquestes dates no és més que fer un resum de l'any que acaba i fer un poc d'avançament del que esper en el 2012. Com bé sabeu, darrerament per mi parlar d'informàtica i feina és parlar d'APSL, el projecte que iniciàrem fa uns anys amb un grapat de socis, parlar de Python, de Django i de GNU-Linux. APSL El febrer de 2012 ja farà tres any de la posada en marxa del projecte APSL, que per qui no ho sap és l'acrònim d'Advanced Programming Solutions SL. El nom el pensarem a un dinar entre en Bernat, en Xus i jo mateix, a partir d'un domini de quatre lletres que vaig poder comprar gairebé de casualitat. Primer va ser el domini i després va ser el nom. Ara no record ben bé qui va proposar la versió final, però record clarament que en parlàvem amb Xus. Sigui com sigui enguany ha suposat passar dels 2 membre amb que iniciàrem el 2010 a passar a quatre i tenir que canviar d'oficina, passant de la incubadora del Parc Bit a un despatx compartit a l'edifici NTIC del mateix … -
Release 0.6.2
We just released LFS 0.6.2. This is a bugfix release. Following bugs have been fixed: fixed issue with utf-8 support for MySQL; issue #126 fixed product filtering; issue #124 LFS goes Github We have setup a Github mirror of LFS. So if you feel more comfortable with Github then check it out. 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 and github. Google Group lfsproject on Twitter IRC -
My Django 1.4 Project Template
Django supports custom project templates as of 1.4. This is a feature i’ve been dreaming for and since have created what I consider - and hope - is an improved project template for most. https://github.com/amccloud/django-project-skel/ Changes and additions Global templates, static, and fixtures directory. Collects static and media into public/{static,media} respectively. Django admin activated by default. Django timezone setting changed to UTC for sanity. HTML 5 base template with simple 404 and 500 error templates. Discourages storing credentials and secrets in the repository. Encourages the use of local_settings.py and accompanying __local_settings.py template. Encourages the use of virtualenv and virtualenvwrapper. Encourages the use of pip and requirements.txt. Encourages the use of git. Includes a .gitignore for the usual junk. Automatically builds a README with installation notes. How to use django-admin.py startproject --template https://github.com/amccloud/django-project-skel/zipball/master --extension py,md yourprojectname Contribute on GitHub -
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 …