Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
On Fixtures and Factories
Click here to see this post in it's natural habitat and to watch and leave comments. We’ve made it a general rule to move away from relying on fixtures in our projects. The main reasons are: Fixtures are fragile. They often break when the schema changes or even worse they appear to work but introduce subtle bugs. Extra work is sometimes needed in order to make fixtures portable (for example defining natural keys). Processing large fixtures can be very slow, which slows down installation and testing cycles. Other smart people in the community are recommending the same approach. We look for good tools that are usually classified as either data generation or fixture factory. We’ve had some success with django-whatever and wanted to share a few tips. Some of the benefits of django-whatever: Generating one or many instances of a Model can be done in a line or two of code. Easy to handle things like non-standard primary keys or recursive relationships Using a random generator, you get fuzz testing for free. Like all powerful tools, it is easy to accidentally inflict pain. A few lessons we’ve learned: If you have tests that fail randomly, it may be caused by … -
Python Application Deployment with Native Packages
Speed, reproducibility, easy rollbacks, and predictability is what we strive for when deploying our diverse Python applications. And that’s what we achieved by leveraging virtual environments and Linux system packages. Preamble & Disclaimer To avoid excessive length, I’ll assume you’re somewhat experienced in DevOps/deployment matters and at least loosely familiar with Fabric to follow the examples. I also won’t be explaining configuration management like Ansible, Puppet, Chef or Salt. To reap all of the benefits, you’ll need to run a private debian repository server for your packages. That’s not hard, but it takes some effort. Fortunately, you can avoid running your own debian repository and still gain most of the advantages: a debian package (or a rpm package for that matter) can also be installed by hand using dpkg -i your-package.deb (rpm -Uhv your-package.rpm). If you want to go really light (or don’t have sufficient privileges on the production servers to install packages), you can employ most of the guidelines here except using vanilla tar balls instead of system packages and do the work of the package manager using custom tooling. The key point I’m trying to make is that the best way to have painless and reproducible deployments is … -
Using Travis-CI with Python and Django
I've been using Travis-CI for a while now. Both my personal projects, and even several of the libraries we maintain at DISQUS rely on it for Continuous Integration. I figured it was about time to confess my undenying love for Travis, and throw up some notes about the defaults we use in our projec... -
Working around Django's ORM to do interesting things with GFKs
In this post I want to discuss how to work around some of the shortcomings of djangos ORM when dealing with Generic Foreign Keys (GFKs). At the end of the post I'll show how to work around django's lack of correctly CAST-ing when the generic foreign key is of a different column type than the objects it may point to. A quick primer on content-types and GFKs If the Generic Foreign Key did not exist, it would be necessary to invent it Thanks to the content-types framework, part of django.contrib, we do not have to do any inventing, however. The content-types framework is an app that is responsible for mapping python models to the database layer -- a dirty job, but it makes a number of other things easier to implement. Content-types are used to provide granular permissions via the auth/permissions framework and, notably, they have been used to implement GFKs. A GFK is simply a foreign key to a content-type and an additional column to store a related primary key. It is not really a foreign key at all in the sense of it being an actual database constraint. Nor is it a foreign key in the same sense … -
Working around Django's ORM to do interesting things with GFKs
In this post I want to discuss how to work around some of the shortcomings of djangos ORM when dealing with Generic Foreign Keys (GFKs). At the end of the post I'll show how to work around django's lack of correctly CAST-ing when the generic foreign key is of a different column type than the objects it may point to. A quick primer on content-types and GFKs If the Generic Foreign Key did not exist, it would be necessary to invent it Thanks to the content-types framework, part of django.contrib, we do not have to do any inventing, however. The content-types framework is an app that is responsible for mapping python models to the database layer -- a dirty job, but it makes a number of other things easier to implement. Content-types are used to provide granular permissions via the auth/permissions framework and, notably, they have been used to implement GFKs. A GFK is simply a foreign key to a content-type and an additional column to store a related primary key. It is not really a foreign key at all in the sense of it being an actual database constraint. Nor is it a foreign key in the same sense … -
Working around Django's ORM to do interesting things with GFKs
In this post I want to discuss how to work around some of the shortcomings of djangos ORM when dealing with Generic Foreign Keys (GFKs). At the end of the post I'll show how to work around django's lack of correctly CAST-ing when the generic foreign key is of a different column type than the objects it may point to. A quick primer on content-types and GFKs If the Generic Foreign Key did not exist, it would be necessary to invent it Thanks to the content-types framework, part of django.contrib, we do not have to do any inventing, however. The content-types framework is an app that is responsible for mapping python models to the database layer -- a dirty job, but it makes a number of other things easier to implement. Content-types are used to provide granular permissions via the auth/permissions framework and, notably, they have been used to implement GFKs. A GFK is simply a foreign key to a content-type and an additional column to store a related primary key. It is not really a foreign key at all in the sense of it being an actual database constraint. Nor is it a foreign key in the same sense … -
Working around Django's ORM to do interesting things with GFKs
In this post I want to discuss how to work around some of the shortcomings of djangos ORM when dealing with Generic Foreign Keys (GFKs). At the end of the post I'll show how to work around django's lack of correctly CAST-ing when the generic foreign key is of a different column type than the objects it may point to. -
Working around Django's ORM to do interesting things with GFKs
In this post I want to discuss how to work around some of the shortcomings of djangos ORM when dealing with Generic Foreign Keys (GFKs). At the end of the post I'll show how to work around django's lack of correctly CAST-ing when the generic foreign key is of a different column type than the objects it may point to. A quick primer on content-types and GFKs If the Generic Foreign Key did not exist, it would be necessary to invent it Thanks to the content-types framework, part of django.contrib, we do not have to do any inventing, however. The content-types framework is an app that is responsible for mapping python models to the database layer -- a dirty job, but it makes a number of other things easier to implement. Content-types are used to provide granular permissions via the auth/permissions framework and, notably, they have been used to implement GFKs. A GFK is simply a foreign key to a content-type and an additional column to store a related primary key. It is not really a foreign key at all in the sense of it being an actual database constraint. Nor is it a foreign key in the same sense … -
Three things you should never put in your database
As I've said in a few talks, the best way to improve your systems is by first not doing "dumb things". I don't mean you or your development staff is "dumb", it's easy to overlook the implications of these types of decisions and not realize how bad they are for maintainability let alone scaling. As a consultant I see this stuff all of the time and I have yet to ever see it work out well for anyone. Images, files, and binary data Your database supports BLOBs so it must be a good idea to shove your files in there right? No it isn't! Hell it isn't even very convenient to use with many DB language bindings. There are a few of problems with storing files in your database: read/write to a DB is always slower than a filesystem your DB backups grow to be huge and more time consuming access to the files now requires going through your app and DB layers The last two are the real killers. Storing your thumbnail images in your database? Great now you can't use nginx or another lightweight web server to serve them up. Do yourself a favor and store a simple … -
Los Angeles Open Source Sprint on May 12th!
This is a day long coding event in Los Angeles for Open Source developers of all languages and skill levels to come and code like fiends. They'll be joined by dozens of either really smart coders or nice people like me. Sponsors are providing food, drinks, venue, and more! RSVP at http://www.meetup.com/LA-Hackathons/events/62796642/ before it fills up! It's free. I'll be there to: Organize the event with the assistance of the awesome Los Angeles technical community! Code like a fiend. I want to work on django-mongonaut and could use some GraphViz and JavaScript help. And now to open the floor to questions... Where and when? Where: Spire.io 7257 Beverly Blvd #210 Los Angeles, CA 90036 When: May 12, 2012 10 AM to 10 PM Is this like a Hackathon? Yup. See http://en.wikipedia.org/wiki/Hackathon#Sprints Will there be Wifi? Yes! I'm just starting as a developer, should I come? It depends. If you've never coded before, this isn't the right place. Instead, you might consider one of the local coding workshops or classes. In fact, here's a good bi-weekly hack night / study group for you. If you've done a tutorial or two, sprints can be a great way to learn new skills or … -
Los Angeles Open Source Sprint on May 12th!
This is a day long coding event in Los Angeles for Open Source developers of all languages and skill levels to come and code like fiends. They'll be joined by dozens of either really smart coders or nice people like me. Sponsors are providing food, drinks, venue, and more! RSVP at http://www.meetup.com/LA-Hackathons/events/62796642/ before it fills up! It's free. I'll be there to: Organize the event with the assistance of the awesome Los Angeles technical community! Code like a fiend. I want to work on django-mongonaut and could use some GraphViz and JavaScript help. And now to open the floor to questions... Where and when? Where: Spire.io 7257 Beverly Blvd #210 Los Angeles, CA 90036 When: May 12, 2012 10 AM to 10 PM Is this like a Hackathon? Yup. See http://en.wikipedia.org/wiki/Hackathon#Sprints Will there be Wifi? Yes! I'm just starting as a developer, should I come? It depends. If you've never coded before, this isn't the right place. Instead, you might consider one of the local coding workshops or classes. In fact, here's a good bi-weekly hack night / study group for you. If you've done a tutorial or two, sprints can be a great way to learn new skills or … -
Managing multiple SSH identities
Here at Imaginary we maintain our own git repositories internally with the help of the invaluable utility, Gitolite. This works well for us. However, in some cases, our clients have their own repositories that we must interact with. The problem arises when the client repositories reside on a third-party service ... -
Integration of Backbone.js with Tastypie
I recently started learning more about backbone.js as a way to create richer app-like experiences on the web without the kludge that results from creating DOM elements in jQuery. I bought all three PeepCodes on the topic and have watched them all now a few times (they are densely packed with good material). PeepCode Screencasts: backbone.js basics backbone.js interactivity backbone.js persistence We have been doing more and more of not only these richer app-like user interfaces on the web, but also API-backed iOS apps that extend the reach and functionality of the web application. Therefore, something like backbone.js just makes sense as we can share the API for both the web application as well as the iOS app. When I first got started, it became obvious to me pretty quickly that backbone.js shipped with a lot of default assumptions about how the REST API worked (predicted url paths, data structures, and so on). I am a big fan of Tastypie, in fact, all of us at Eldarion are. It's dead simple to extend and customize, enabling us to quickly and easily add APIs to sites. There were a couple of small things that didn't work out of the box with … -
Einladung zur Django-UserGroup Hamburg am 09. Mai
Das nächste Treffen der Django-UserGroup Hamburg findet am Mittwoch, den 09.05.2012 um 19:30 statt. Anders als bisher treffen wir uns diesmal 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. Ich werde ein CMS auf Django-Basis vorstellen. Weitere 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, aber hilfreich für die Planung: Doodle Kaldender. Weitere Informationen über die UserGroup gibt auf unserer Webseite www.dughh.de. -
Release 0.6.15
We just released LFS 0.6.15. This is a yet another bugfix release of the 0.6 branch. Changes Bugfix: fixed management of criteria Bugfix: fixed display of image for category sub-categories view Changed: added 100x100px box to search results to prevent content jumping from left to right when the page is loaded (naro) Changed: clean up display of package result Information You can find more information and help on following locations: Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org and github. Google Group lfsproject on Twitter IRC LFS on EuroPython 2012 We are sprinting on this year's EuroPython in Florence. Don't hesitate to join us, see https://ep2012.europython.eu/p3/sprints/ and LFS sprint topics for more. -
Integration Testing in Python
Hey folks! Here's a presentation I did for the Providence Royal Python Society meetup this winter. It covers some of the currently-available integration testing tools for Python, as well as my own project, easy-integration. Integration Testing in Python View more presentations from Panoptic Development, Inc. -
Django versus ajax or together with ajax?
-
Release 0.7.2
We just released LFS 0.7.2. This is a yet another bugfix release of the 0.7 branch. Changes Bugfix: update product view after images has beend changed; issue #200. Bugfix: fixed wrong label for e-mail field; issue #202. Bugfix: fixed pagination link. (Maciej Wi?niowski) Bugfix: fixed Product.get_product_tax method: added request to parameters; issue #199. Bugfix: fixed display of standard price within category products view. Bugfix: don't allow pages with same slug. Added: added CategoryProductPricesNetNode to lfs_tags. Added: added CategoryProductPricesNode to lfs_tags. Updated: cleaned up PriceCalculators. Information You can find more information and help on following locations: Documentation on PyPI Demo Releases on PyPI Source code on bitbucket.org and github. Google Group lfsproject on Twitter IRC LFS on EuroPython 2012 We are sprinting on this year's EuroPython in Florence. Don't hesitate to join us, see https://ep2012.europython.eu/p3/sprints/ and LFS sprint topics for more. -
Whiskers and buildout.sendpickedversions
Last year I participated in a deployment knowledge sharing session and I started implementing changes at my company pretty soon after. The result is that we are using Puppet for some parts of our server configuration. We also added Munin to our monitoring toolset (and I used Puppet to deploy Munin and manage its configuration). But an important piece that was still missing in our setup was an overview of which packages we use in the buildouts of our clients and more specifically which version each client uses. Apparently I was not the only one that wanted to have such an overview: Jukka Ojaniemi created Whiskers (PyPI, GitHub) and released version 0.1 in December 2011. Whiskers is a Pyramid application and it is intended to be used in combination with the buildout extension buildout.sendpickedversions (PyPI, GitHub). Setting up Whiskers is very simple (see the Whiskers README for details) and since the data is stored in an SQLite database there is little infrastructure needed. The buildout side is even less work, since you only have to add the following: [buildout] ... extensions += buildout.sendpickedversions buildoutname = <buildout-name> whiskers-url = <whisker-server-url>/buildouts/add And the result after modifying several buildout configurations is a nice … -
Asynchronous email delivery with Django, Amazon SES, Celery and Supervisord
A few weeks ago, I released a simple Django app to manage models for simple newsletters. The package itself is blatantly useless if we do not use it on a project that integrates with other parts, so I created a fully-equipped system that can create propaganda, assign it to subscribers and queue it ready to be sent whenever I need to. The architecture First, I have been using Amazon SES for a while to send newsletters to customers, both in-house and for clients and third-parties. It removes the hassle of maintaining SMTPs, email server management, network configuration, and meeting rigorous Internet Service Provider (ISP) standards for email content. So we will take profit of all those advantages, and make our life more simple and enjoyable. Second, we want a smooth and efficient delivery through concurrent background tasks, seamless for the user and detached from the front-end business logic. Whenever we press the "send" button we expect the system to return a confirmation response immediately — regardless of what's happening in the background — instead of getting the request frozen, waiting too much time for the email queue to be emptied and ending up with a web server timeout response. Celery … -
Gerbi CMS
Gerbi CMS (nee django-page-cms) is a multilingual content management system written in Python and based on the Django web framework. It's currently my favourite CMS software and use it for a number of web sites I administer. I'll be giving a talk about Gerbi CMS at the next OCLUG and OPAG meetings resembling this article. -
Sticking With Standards
More and more I’m seeing the “requirements.txt pattern” come up. This generally refers to projects (but not just), and seems to have started around the same time as Heroku adopting Python. I feel like this is something that matters in the Python world, and because I have an … -
Sticking With Standards
More and more I'm seeing the "requirements.txt pattern" come up. This generally refers to projects (but not just), and seems to have started around the same time as Heroku adopting Python. I feel like this is something that matters in the Python world, and because I have an opinion on everything,... -
Sticking With Standards
More and more I'm seeing the "requirements.txt pattern" come up. This generally refers to projects (but not just), and seems to have started around the same time as Heroku adopting Python. I feel like this is something that matters in the Python world, and because I have an opinion on everything,... -
Class Based Views Part 3: DetailView and template_name Shortcut
The DetailView is an important class based view since it allows us to show off details of our data instead of just bits here and there. It is also very simple to use and will save you time. In this video you are also going to see a nice little shortcut with your templates to save you from writing a couple of extra lines.Watch Now...