Creating feeds in Django is freaking simple. I’ll start with an example of just updating a feed with the newest objects (for instace, newest blog posts). Similar to the forms.py way of handling our different forms, I’ve created a feeds.py to handle the feeds.
from django.contrib.syndication.feeds import Feed from colddirt.dirty.models import Dirt class LatestDirts(Feed): title = "Cold Dirt" link = "/" description = "When you have dirt, you've got dirt. Right..." copyright = 'All Rights Unreserved' def items(self): return Dirt.objects.all()[:50] What this will do is query our Dirt DB and return an obj. The fields here are pretty well documented in the Django docs, …
Read Django Syndication with ColddirtI hear many complaints and questions about newforms, but I’ve personally found it rather easy and logical to use. There are numerous ways for you to use do forms in Django, and most likely the best way to see them all is to read the docs. On the Colddirt demo site, this is how I used newforms. I’ll take the index page as an example.
I’ve accessed the newforms module like so:
Read Django Newforms Usage in ColddirtSo, the Django developers, in my opinion, are freaking smart. Instead of bundling Django with a particular library, they have added XML and JSON serialization; us humble users can choose whatever AJAX library we want. Prototype 1.5.1 has been pretty fun to work with, so I’ll kick off this demo with a really simple example.
How simple? The intended goal is to have the total number of ‘dirts’ update without user intervention. Laaaammmeee. If you are a visual type of person, take a look on the Colddirt huh page. That number automatically increases without user intervention. And this is how.
The process (some pseudocode) will go like this:
Read Simple Ajax with DjangoNote: Colddirt’s source code is run from Django SVN, check out on May 10th-ish. If you are using a newer branch, some things have changed. i.e. clean_data has been renamed cleaned_data. Remember to check the BackwardsIncompatible page in the wiki.
Part 1: Simple AJAX with Django
Part 2: Django Newforms Usage
Part 3: Search with Django
Part 4: Django’s Syndication Framework (simple)
Part 5: Django’s Syndication Framework (little more complex)
Feel free to see the source code from Github.
Read Colddirt Information