veni vidi Scripsi

Installing Gettext on Mac OS X Lion

Just now I tried to use django-admin.py makemes­sages to create a language file and got the following error: /bin/sh: xgettext: command not found. After a search on my system it turns out I don't have gettext installed.

I did some searching and found mac-ports solutions, but I'm not a big fan of them. I tried compiling myself and got the following errors:

stpncpy.c:34: error: expected declaration specifiers or ‘…’ before numeric constant
stpncpy.c:34: error:    expected ‘)’ before ‘!=’ token

stpncpy.c:34: error: expected ‘)’ before ‘?’ token

make[3]: *** [stpncpy.lo] Error 1

make[2]: *** [install] Error 2

make[1]: *** [install-recursive] Error 1

make: *** [install-recursive] Error 1

I continue.

Oh no! I've Forgotten my Django Admin Password!

And here's how to reset it if you can still reach the in­stal­la­tion via SSH or similar.

Start a Django shell:

python manage.py shell

Use the following code to change the password:

from django.contrib.auth.models import User
u = User.objects.get(username__exact='[username]')
u.set_password('[fill in new password here]')
u.save()
exit()

That's all!

Sources

TinyMCE in one of multiple Textarea fields in Admin

When I was working with Django the other day I had a model which contained 3 textareas (models.TextField()). I only wanted 2 of the 3 to use TinyMCE for mark-up in the Admin. I worked out how to achieve this and here’s a quick guide.

  1. Install TinyMCE as explained in an earlier post.

  2. Make sure the tiny_mce folder, the one you downloaded from tinymce.moxiecode.com, is also in your site-media javascript folder (/[site­me­di­a]/js/tiny_mce/) or change TINYM­CE_JS_URL in your settings.py to the correct folder.

  3. In your settings.py define what you want the default tinymce to look like, for example:

    TINYMCE_DEFAULT_CONFIG = {
         
    continue.

TinyMCE in Django

A while ago when I was working with Django I had a really hard time trying to figure out how to get TinyMCE to work in Django. Now it isn't difficult, you just have to know how to do it. So I've written a quick guide on how to make it all work.