// author archive

Joost

Joost has written 19 posts for Django Days

WYSIWYG editor in Django Admin

As awesome as the standard Django admin might be, sometimes you want the textfields to have a little bit more functionality. This is quite simple to achieve. We’ll use WYMeditor in this case, but it should be equally easy with TinyMCE, FCKeditor or any other WYSIWYG editor out there.

First download jQuery and put it in [...]

Django foreign key default value example

Here’s an example of how to set a default value for a models.ForeignKey field:
class Foo(models.Model):
    a = models.CharField(max_length=10)
def get_foo():
    return Foo.objects.get(id=1)
class Bar(models.Model):
    b = models.CharField(max_length=10)
    a = models.ForeignKey(Foo, default=get_foo)
Hope this helps someone (I’ve been looking for this quite some time…). If anyone know a better/neater way, please let us know in the comments!!

GeoDjango: getting a random point within a multipolygon

While fooling around with the awesome GeoDjango framework, I was looking for a way to generate a random point within a multipolygon.
Justin Bronn (djangopeople.net/jbronn/), the lead developer of GeoDjango was kind enough to point me in the right direction. I thought I share the concept here as it might be helpful to someone:
Define the function:

def [...]

Great speech by Clay Shirky on Love, Internet Style

Here’s a great speech by Clay Shirky on community support for software development versus corporate/commercial support:

Using non-ascii in Django templates

I hope some reader can help me uit here…
We were trying to use non Ascii characters (like ♥ for example) in the Django templates, but couldn’t get it to work.
We worked around this by using a template variable ( {{ nonAsciiHeart }} for example) and then put the following in the view:
nonAsciiHeart = ‘\xe2\x99\xa5′
return render(’example_template.html’, [...]

Update: New Django app: FutureTweets.com

At SolidFlux we’ve been working on a fun new Django project called FutureTweets. It’s a basic Twitter application that allows Twitter users to schedule their updates.
By using FutureTweets, you’ll always have an alibi! You can also schedule reccuring updates daily, weekly, monthly or yearly (handy for sending birthday Tweets ). Please use the comments [...]

Change site layout by user preference

I found a nice Django pluggable app: Django userskins by Will Larson of http://lethain.com.
Similar to Twitter, it provides functionality that allows your users to set preferences about how your site looks to them. Quite handy if you ask me!
Read all about it here.

More on debugging Django

The other day, I read about another interesting way of debugging Django Apps:
If you use the following statement in you code:
import pdb; pdb.set_trace()
You can debug you app by running the server with the python command
manage.py runserver -p 8888
Then, after you visit the page where the set_trace() function is called, the server will break the code [...]

restrict access to Django site from all IP’s on Webfaction

For this one project I wanted to deny all access to the site except for a certain IP address. I knew it could be done by using the mod_authz_host Apache Module (more info here), but I couldn’t get it to work on a Webfaction shared hosting account.
After exchanging some mails with the Webfaction support team [...]

Python 2.6 released!

Awesome news: Python released new production ready version 2.6 yesterday!
Check out: http://www.python.org/download/releases/2.6/
We’ll keep you posted on what the consequences are for Django!

Categories

  • No categories

Django Hosting:

DjangoDays recommends the following Django hosting provider: