Tags / django

Ghetto Facebook Registration with Django

Monday, October 8, 2012

I’m going to quickly walk you through how to build a server-side Facebook registration flow with Django. This is really basic and doesn’t rely on special libraries aside from httplib2 and urlib which are pretty standard. First you need to create an app. I set my App Domain to localhost and Site URL to http://localhost:8000 for development purposes. You’ll probably need to do the same if you’re using Django’s built in development server.

Continue reading →

Save RAM with mobile middleware

Wednesday, October 7, 2009

A while back I wrote an article on how to set up a mobile site with Django ../going-mobile. Currently I have a Slicehost account which includes 256MB of RAM. My resources are tight and I really dislike having another set of unnecessary Apache processes for a mobile site that, aside from different templates, is using the same code base. The solution is quite simple, write a middleware. The following code checks the incoming request for ’m' or ‘mobile’ in the domain name.

Continue reading →

Working with Python and RabbitMQ

Wednesday, May 20, 2009

I recently installed RabbitMQ to handle some message queuing needs at Readernaut and thought I’d share how everything came together. If you’d like to learn more about RabbitMQ please read this. To use RabbitMQ with python you need py-amqplib because Rabbit uses the AMQP standard. To make amqplib a little easier to use I needed a simple script that did three things: Easy way to connect to RabbitMQ. Easy way to pull stuff out of the queue.

Continue reading →

Capturing content in Django templates

Saturday, February 28, 2009

As a template designer there are times when you have structural code surrounding a block which is waiting on content from a child template. It may look something like: <div class="content_title"> {% block content_title %}{% endblock %} </div> Sometimes this block is never filled so ideally I want the DIV element in this case gone. This isn’t easy because there’s no way to know whether content is headed towards the block so one solution that I’ve used is:

Continue reading →

Creating a basic API with Django

Monday, August 11, 2008

Creating a simple public API for your site is a lot easier than you may think with Django. You’re basically just creating another view and serving it as XML or JSON instead of HTML. What’s public? Decide what you want to be public. The best answer is the stuff you’re already displaying in your HTML templates. Then you need to create an entry in your url conf. url(r'^api/v1/(?P<username>[-\w]+)/notes/?$', 'readernaut.api.views.user_notes'), Create the view In the case for Readernaut I wanted to provide an XML feed for users notes.

Continue reading →