A couple updates
Today marks two releases, both numbered 0.4, of django-registration and template_utils.
The new release of django-registration is largely a matter of policy; there’s no new functionality or features, but there is one backwards-incompatible change: the validation of passwords (verifying that the same password is entered in both fields) has been moved to the clean() method of RegistrationForm, which means that the error message from a password mismatch is now accessed via form.non_field_errors() instead of form.errors[‘password2’]. It’s a relatively easy change to make in your templates, but because it’s backwards-incompatible I’m pushing the version number up by one.
Also included in the 0.4 release of django-registration are two new translations: Greek and Russian, courtesy of Panos Laganakos and Ilya Filippov.
Updates to template_utils
This one is a bit larger in scope. First off, the Subversion trunk of template_utils has been Unicode-ready for quite some time now, but I’d never gotten around to rolling a release from that. Also, the apply_markup template filter has been updated to handle Django’s template autoescaping — the result of apply_markup is now marked as “safe” so that autoescaping won’t try to mess with the generated HTML. And in one final update to accomodate changes in Django trunk, where applicable the tags it provides have been updated to use the new Variable class for template variable resolution.
There’s also been a bit of internal rearrangement. The GenericContentNode class introduced in the previous release now lives in template_utils.nodes along with another useful Node subclass: ContextUpdatingNode, which simplifies the process of returning values into a template context. The general idea is that subclasses of ContextUpdatingNode define a method called get_content(), which returns a dictionary; the dictionary will then be used to update the template context.
Finally, there’s a new tag library included, which has two tags designed to simplify including RSS or Atom feeds in a Django template: include_feed and parse_feed. Both require the Universal Feed Parser library, and they differ only in how they return the results:
-
include_feeduses a second template to render the feed’s items for eventual display. -
parse_feedsimply drops the parsed feed object into your context.
The result is that you can do things like this (this example would fetch the feed of latest entries from this blog, and display the title of each along with a link):
{% load cache %} {% load feeds %} {% cache 3600 parsed_b_list_feed %} {% parse_feed "http://www.b-list.org/feeds/entries/" as b_list_feed %} <ul> {% for entry in b_list_feed.entries %} <li><a href="{{ entry.link }}">{{ entry.title }}</a></li> {% endfor %} </ul> {% endcache %}
If you use these tags, do not even consider doing so without also using Django’s template fragment caching to cache the results from using these tags; pounding away on somebody’s feed with every single page view to your own site will get you in trouble.
The code in template_utils is based on a similar tag posted to djangosnippets, though it has a few more features and implements parse_feed as a ContextUpdatingNode.
As always
Report bugs through the Google Code issue trackers. I’ve done some tests locally, but haven’t yet had time to work up a full unit-test suite so there may well be problems. I’ll do my best to respond to them in a timely fashion.
December 10, 2007
#
Just noticed a small typo on the feed parser template snippet - you’ve got the wrong { at the end of endcache.
Looking forward to trying the RSS aggregation templatetag.
December 10, 2007
#
Sorry, just tested it and noticed that you need to have the feed url in quotes:
{{{ {% parse_feed ‘http://www.b-list.org/feeds/entries/’ as b_list_feed %} }}}
Seems to be working very well though - nice work James.
December 10, 2007
#
Yeah, I just fixed the snippet. It’s done properly in the
template_utilsdocs, though, so I should have just copy/pasted from there ;)December 10, 2007
#
excellant stuff james. mucho gracias!
December 10, 2007
#
Interested in helping out with PyCon-Tech?
I wrote almost the exact same feedparser tag setup for the PyCon site (only mine does a bit more, and is poorly written). I hate to see suplication of effort, and I am having a VERY hard time getting people to even find PyCon-Tech. I need more developers!
(end of begging)
http://us.pycon.org/2008/ https://pycon.coderanger.net/ http://www.dougma.com/archives/49
I have a full featured wiki 80% completed. (It’s currently driving the PyCon 2008 website). There are screencasts and everything on it…
December 10, 2007
#
Wow, very cool stuff. Nice work James.
December 11, 2007
#
Hello.
I have used template_utils since it came out, and it’s great!
I tried to update my svn checkout 5 min ago, but I get a Template Error when I try to use the script with {% load generic_content %} :
‘generic_content’ is not a valid tag library: Could not load template library from django.templatetags.generic_content, No module named template_utils.nodes
Do you have any idea what could be wrong?
December 11, 2007
#
No clue. The module provided is named
template_utils, and it includes a file namednodes.py, and it works for me. Double-check that you’ve got it installed properly.December 11, 2007
#
My old checkout was inside my project dir and I used ‘myproject.template_utils’, in settings.py.
I checked out a new version outside ‘myproject’ dir, and now everything works when I use ‘template_utils’, in settings.py .
Thank you for the great “app” :D
December 11, 2007
#
Sounds intersting. Does parse_feed also accept context variables? Something like {% parse_feed user.profile.blog_url as user_feed %}
December 15, 2007
#
First, django-registration is an excellent app!
What I need is a different, equally common registration workflow though: 1. user registers 1. Django sends an email with activation url to site administrator 1. admin clicks on the url and is taken to a page where she can 1. accept or deny registration 1. customize the new user’s profile (a separate entity from RegistrationProfile) 1. user is notified of acceptance or denial by email
I’m just starting to extend your code to this workflow. Have you any plans for implementing a similar workflow? Any hints if not?
December 15, 2007
#
Sorry, the Markdown numbered list didn’t work.
Testing (feel free to remove the comment): 1. Bird 1. McHale 1. Parish
December 27, 2007
#
django-registration is great, really appreciate your work!
What I’m missing is a feature to allow users to update their e-mail addresses. This would require an e-mail validation step, and the app would need to store the new e-mail address temporarily until it is validated. Is this in the pipeline?
Thanks!
December 27, 2007
#
Nope. The registration app is for signing users up, period. Anything that isn’t part of signing users up is out of scope, and that includes later going back to edit users.
January 2, 2008
#
I’ve installed template_utils in my site_packages directory. But when I try and put {% load generic_content %} in my template I get an error:
invalid syntax (generic_content.py, line 11)
Any idea what I’m doing wrong? This is on my live server, running python2.5, mod_python, apache.
Thanks.