Diamanda back in SVN
Diamanda code is back in SVN, but it's still far from being done so expect a lot of changes. Currently the code was cleaned up a bit, I've removed my site specific code and made it work on latest Django-SVN (required).
Django, Comet and IRC client
How to make a simple web IRC client using comet - orbited
Upgrading Diamanda to Django-SVN
In the last few days I have been updating code of my sites to be more Django-SVN compatible, and to clean few things. Things that have been done:
- Removed auto_now and auto_now_add as they will be gone (read here about it).
- Renamed maxlength to max_length in models and oldforms forms
- migrating from oldforms to newforms – boxcomments for now only :) newforms are much "bigger" than oldforms and "how to make this in newforms" takes some time.
- Added |safe in templates where it's needed to show HTML
- Some time ago – make it work after UTF branch merged :)
Google GData Authentication decorator
Google GData API can be used to retreive data from Google services... It can also be implemented on other sites (which I have on my ToDo list at my current job) helping in creation of backed applications. "Read" to see a simple view with custom decorator that authenticate user agains a GData provider (Google in this case). You can also read the auth docs.
Django and Comet
Creating real time event driven components in your Django applications using Orbited Comet server.
Django-SVN site upgrade
I've upgraded my sites to be Django-SVN compatible, and to fix/add some components. Comments can now be added by anonymous. As for 0.96 -> SVN code upgrade I had to solve a lot of unicode errors (as I use non ASCII Polish language). Sad thing is that I didn't noticed any new features that I can use. I have pyif template tag waiting as Django if tag can't compare < > so I'm unable to check if there are new posts in forums for current user. Yes, Django templates ARE limited, and Django developers should make them more flexible, even if they don't like logic in templates ( “ifequal” is good but if “a < b” is not?). There is a lot of Django components out there, and some of them should go into core django as add-on modules etc...
Cool djangosnippets
First snippet is a SQL Query logger middleware which logs and display all queries. The second one is a view profiler middleware which allows profiling of views with hotshot. Read more to see example results.
Migrating data to Django (from PHP)
I've wrote an article about data migration - from punBB (PHP) to my MyghtyBoard Forum (Django)
In other news - TurboGears 2 will be based on Pylons. AFAIK plans for Django 2.0 haven't been made yet ;)
Custom models fields?
I was wondering how to make a ForeignKey on a model and limit the choices in some way (for example allow adding subcategories only to root categories). So why not make a new class, that inherits models.ForeignKey and overwrite method that return the choices? My test code that works (it probably can be done a bit better...):
class FK(models.ForeignKey):
def __init__(self, to, to_field=None, **kwargs):
models.ForeignKey.__init__(self, to, to_field=None, **kwargs)
def get_choices(self, include_blank=True):
c = Category.objects.filter(id__gt=2)
returnList = []
for cc in c:
returnList.append([cc.id, cc.cat_name])
return returnList
class Category(models.Model):
cat_name = models.CharField(maxlength=255, verbose_name=_("Category Name"))
cat_order = models.PositiveSmallIntegerField(default=0, verbose_name=_("Order"))
cat_foo = FK('self', verbose_name=_("test"), blank=True, null=True)
OpenID in Django the easy way
Simon Willson has published his project - django-openid, which adds OpenID support to Django projects in a easy and nice way :grin: I've tested it and it works without any problems. Time to add OpenID support to my sites :)