Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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... -
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... -
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... -
Mozilla Webdev’s Beer and Tell: April 16, 2012
In case you missed last month’s blog post, a Beer and Tell is a monthly Mozilla Webdev gettogether involving cool hacks and malted beverages. We try to structure it like a series of lightning talks and — because all work and no play makes web developers go crazy — some of us have a beer during. Some of the East Coast folks drink scotch instead, but it’s OK because it’s after 5pm in Toronto by then. We didn’t record this Beer and Tell (my bad!), but I thought I’d share what was presented. It was pretty gaming-focused and quite cool. Django Stats Admin Created by Michael Kelly, this nifty little app allows you to visualize any of your Django models with datetime fields in the Django Admin. It uses the flot JS library to create pretty charts and lets you specify date ranges. Michael’s currently working on abstracting the app out into a library that can be used with any Django app. Lisp -> DCPU-16 Compiler James Long, our resident Lisp champion, started off by telling us about 0x10c and the DCPU-16 assembly language in the game. It’s pretty cool stuff for gamers who are language geeks too. Of course, … -
Yet another tutorial for building a blog using Python and Django - part 5
In this instalment I’ll be showing you how we can make our blogging engine a little nicer to look at by adding some CSS and images, as well as expanding on Django’s templating system. First of all, let’s add some CSS to our blog. When developing a web app with Django, you should place static files such as stylesheets and images in a folder inside your app (not project) folder called static. My project is called DjangoBlog, and my app is called blogengine, so all my static content should go in DjangoBlog/blogengine/static/. Here’s the stylesheet, which I’ve saved as style.css: body { background-color: #f0f0f0; font-family: Arial, Helvetica, sans-serif; } #main { width: 800px; height: 100%; margin: 50px auto; } ul#pageList { margin: 0px; padding: 10px 0px 10px 0px; } ul#pageList li { display: inline; margin-right: 10px; font-size: 18px; } .post, .page { width: 600px; padding: 20px; margin-bottom: 20px; background-color: #ffffff; } In the same folder, I have a PNG icon for an RSS feed, and if you had some JavaScript files you wanted to use (such as a copy of jQuery), you would put them here too. Note that there’s nothing to stop you creating subfolders within /static, and in … -
Ginger Tech Stack
-
Ginger Tech Stack
Click here to see this post in it's natural habitat and to watch and leave comments. For our latest product, Ginger, we wanted to marry the real-time functionality we needed with the traditional Django stack we know and love. After some false starts and falling on our faces in the beginning, we ended with a stack we’re happy with and think will serve us well moving forward. Back-end This is our bread-and-butter. It’s Django and PostgreSQL running with Gunicorn behind Nginx. The biggest difference between this and your typical Django site is that it mainly serves as a REST API consumed by the front-end. We are using traditional Django views in a few places like login, logout, and user profiles, but the rest of the views are handled by the front-end. Using Django, we were able to quickly build the nuts-and-bolts parts of our site that didn’t require any special real-time functionality. A few of the important libraries we’re using: tastypie for building the REST API haystack backed by solr for search celery backed by Redis for task queueing misaka and pygments for text formatting easy-thumbnails and PIL for image thumbnailing Front-end Our front-end uses Backbone.js to handle most of … -
Django 1.4 admin image issues with S3 backed static files
This is going to be kind of obscure, but hopefully it helps someone. My current default setup for using S3 backed static files for Django broke when I upgraded to 1.4. The affect was that the admin media paths had been URL encoded so "/" was replaced with "%2F". https://s3.amazonaws.com/bucket_name/admin%2Fcss%2Fbase.css This caused images referenced in the css to fail because relative paths were interpreted (in Chrome at least) as being relative to the last unescaped slash instead of to /css. This also caused horizontal filters to fail as well. The Source The problem was exposed by a change in Django 1.4. Since Django no longer uses ADMIN_MEDIA_PREFIX, the storage system gets involved in creating the urls for the admin site media. I had been using a combination of the S3 Python library and django-storages. Django storages is basically doing the right thing, though it does have an opportunity to unescape the paths it gets from S3. The escaping itself is contained S3 library for Python, but I elected to take a different route to work around it. Solution My solution was to bypass the problem and switch S3Boto backend for django-storages. I have been using Boto for SES based email …