Both before and after upgrading byteflow to use django 1.2, one thing that wasn’t working is postimage. The most recent problem was the link to post an image (in the admin page for creating or editing a blog post) was completely missing (whereas before it was present but malfunctioned).

The reason it was missing was that the javascript to create that link, in static/js/postimage.js, failed on line 42, in the showLinkFor function. It failed on


I fixed it by inserting the link before the blog text instead of after the previous node’s contents:

    //  showLinkFor: function(elem) {
    //      elem.previousSibling.appendChild(document.createElement('br'));
    //      elem.previousSibling.appendChild(this.getLink(;
    //  },

    showLinkFor: function(elem) {
        var parent = elem.parentNode;
        var mybr = document.createElement('br');
        var myid = this.getLink(;
        parent.insertBefore (myid, elem);
        parent.insertBefore (mybr, elem);

I have a non-standard URL_PREFIX of bjb/ and postimage didn’t play nice with that. I hard-coded my URL_PREFIX into the postimage.js file:

    getLink: function(id) {
        var link = document.createElement('a');
        link.setAttribute('href', '/bjb/admin/postimage/attach/?for=' + id);

Not elegant, but it got me past that problem. The next problem was that the list of files was empty. I set the POSTIMAGE_ROOT to point to a directory on the server machine with pictures in it, and then the list was not empty.

But it wasn’t full of all the pictures in that hierarchy either … that was just a file permission problem (web server couldn’t read some of them).

So now I can use postimage. It doesn’t do quite what I expected. What it does is allow you to choose among pictures on your server for inclusion into your blog. It doesn’t let you preview them. All it does is give you a list of files, and then put a link to the most recently chosen file in your blog text. You can call it over and over and it will add more image links. It looks like it can take the render method into account — there is a choice of markdown, html, rst. But, that choice was in the source code … not sure if it will detect your render method automatically.

I expected to be able to upload pictures to the blog … oh well. I guess the way postimage works is safer. It doesn’t put files up there for you — it assumes you have put them up already — into a “POSTIMAGE_ROOT” directory — and just accesses what is already there.