How to save with a newform into the DB with missing parameters

As django auto forms seem to not do anything except ‘many to many’ relationships yet (yeck) and, with foreign keys you probably don’t want the visitor just setting those anyway, you are left to use an autoform but ‘fill in’ bits and pieces of this ‘partial’ autoform for the user before saving it.

One way to do it is this (uses ‘editable=false’) to not display certain (necessary) things for the user

class ResponseToEvaluation(models.Model):
originating_evaluation = models.ForeignKey(Evaluation,editable=False) # lodo umm...foreginkey then just doesn't work with these things?
personal_comments = models.CharField(maxlength=2000)
pub_date = models.DateTimeField(editable=False)

ResponseToEvaluationAutoForm = form_for_model(ResponseToEvaluation)

Then in the view thus:

from django.newforms.models import * # save_instance
def comment_reply_view(request, id):
        if request.method == 'POST':
            form = ResponseToEvaluationAutoForm(request.POST)
            rNew = ResponseToEvaluation()
            rNew.originating_evaluation_id = id # muhaha
            rNew.pub_date = # we want that one, too
            if form.is_valid():
                save_instance(form, rNew) # stolen from modeltests/model_forms/ yeck
                return returnUserHomePage(request, extraHash = {'display_message': 'Response written'})
                return returnUserHomePage(request, extraHash = {'error_message': 'Trouble writing response'})
            form = ResponseToEvaluationAutoForm()
        originalEvaluation = Evaluation.objects.get(pk=id)
        repliesToIt = originalEvaluation.responsetoevaluation_set.order_by('pub_date')
        return render_to_response('user/comment_reply_to.html', {'form': form, 'originalEvaluation': originalEvaluation, 'replies': repliesToIt})

django fixtures

say you have a directory “main” (an app), with containing “class Evaluation”
you can create a fixture thus:

        "pk": "1",
        "model": "main.Evaluation",
        "fields": {
            "user_who_made_it": "1",
            "user_they_evaluated": "2",
            "personal_comments": "first evaluation from 1 to 2",
            "is_positive": "0",
            "pub_date": "2006-06-16 12:00:00"


And put it in the main directory and voila. Works.

django duplicate field weirdness

So in django if you duplicate field names in a model declaration “weird” things happen, like
ValueError at /admin/

invalid literal for int() with base 10: ‘False’

Request Method: POST
Request URL: http://localhost:8000/admin/
Exception Type: ValueError
Exception Value: invalid literal for int() with base 10: ‘False’
Exception Location: c:\Python25\lib\site-packages\django\db\backends\ in typecast_date, line 46

Go figure 🙂

how to download files in Ruby

# the ruby way to download files 🙂 — useful if you haven’t got wget on the system…
require ‘open-uri’
writeOut = open(whereItGoes, “wb”)
puts “downloaded” + urlToGet + “\n”

Of course, this reads in the whole file before writing it (I bet), so be careful.

setting up scgi

As a note on

Note: you may not need to edit the .htaccess file at all.  Don’t be afraid if you do it and find an error messsage in apache/logs/error that the rewrite engine on directive is not recognized.  This means that mod_rewrite is not installed but it may not be necessary for SCGI anyway.  Apparently not necessary these days.

svn purge

svn purge is used to ‘delete’ all traces of a file (“it never existed”) from a repository.  One idea (since as of 2005 purge wasn’t implemented) is to keep some backups of the svn repostiory directory so you can ‘step back’ by reerting to a saved repository. not pretty but do-able.

ruby compilation overcome

it appears that if you compile ruby and get a "warning clock skew detected" that it
 may be due to your machine having a clock set for a certain time, and an nfs server being set 
for (say) one hour difference or not. Synchronize them and you're good 🙂
Thanks for all those information.


BTW I am using a intel box having 8 processors, each one 2-way hyperthreaded. And yes, the File system id      NFS.

Hemayet Hossain

Dan Gibson wrote:

This happens when you're compiling on a virtual machine, and your host machine supports dynamic frequency modulation. There is a fix to the issue... you can find it on google.

Mike Marty wrote:
While Make is doing its timestamp-based dependency check, the timestamps
on some of your files appeared to be in the future...hence the clock skew
detected message

It is not a GEMS thing.  Sounds like an issue on your host system.


Hi All,
I was compiling ruby (gems 1.3) in simics 3.0.14. At the end of
compilation I am getting the following warning. (ruby seems working
fine). Does anybody know why is that coming or is there any potential
problem for that warning?
Template closure done
Made module
make[1]: warning:  Clock skew detected.  Your build may be incomplete.
make[1]: Leaving directory `/home/vax2/u2/hossain/G3S364/ruby'
Ruby: Linking simics module
cd ../simics; make ruby
make[1]: Entering directory `/home/vax2/u2/hossain/G3S364/workspace'
=== Building module "ruby" ===
make[2]: Entering directory
make[2]: Warning: File
has modification time 51 s in the future
Using the Simics 3.0 API for ruby module
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
make[2]: Leaving directory
make[1]: Leaving directory `/home/vax2/u2/hossain/G3S364/workspace'
Ruby: Moving simics module
make BUILD_FLAGS=-DSIMICS movemodule
make[1]: Entering directory `/home/vax2/u2/hossain/G3S364/ruby'
../scripts/ ../simics/home/MOSI_SMP_bcast amd64-linux
make[1]: Leaving directory `/home/vax2/u2/hossain/G3S364/ruby'
Ruby: my work is done here...


installing subversion with mod_dav_svn

So if you install subversion (and want SSL) and get errors listed here or below…

(if installed with ./configure –without-apache) or what not

run the following from the subversion directory

./configure –with-ssl –without-apache
make && sudo make install
it errs
go to Makefile (I believe) and take out the reference (dependency on) install_mods_shared (line 324 for me)

and run sudo make install again.

I believe this overcomes the following problems, as well.

chmod 755 /usr/lib/apache2/
apxs:Error: Config file /etc/apache2/httpd2-prefork.conf not found.
make: *** [install-mods-shared] Error 1
svn: error while loading shared libraries: /usr/local/lib/ undefined symbol: SSL_shutdown

cd subversion/mod_dav_svn ; /usr/bin/install -c -d “/usr/lib/apache2″ ; /usr/sbin/apxs2 -i -S LIBEXECDIR=”/usr/lib/apache2” -a -n dav_svn
/usr/share/apache2/build/ SH_LIBTOOL=’/usr/share/apache2/build/libtool’ /usr/lib/apache2
/usr/share/apache2/build/libtool –mode=install cp /usr/lib/apache2/
libtool: install: error: cannot install `’ to a directory not ending in /usr/local/apache2/modules
apxs:Error: Command failed with rc=65536

Here is the gross output.. 🙂

/usr/bin/install -c -m 644 ./subversion/svnversion/svnversion.1 /usr/local/man/man1/svnversion.1
cd subversion/mod_dav_svn ; /usr/bin/install -c -d “/usr/lib/apache2″ ; /usr/sbin/apxs2 -i -S LIBEXECDIR=”/usr/lib/apache2” -a -n dav_svn
/usr/share/apache2/build/ SH_LIBTOOL=’/usr/share/apache2/build/libtool’ /usr/lib/apache2
/usr/share/apache2/build/libtool –mode=install cp /usr/lib/apache2/
libtool: install: warning: relinking `’
(cd /home/rpack/downloads/subversion-1.4.3/subversion/mod_dav_svn; /bin/sh /home/rpack/downloads/subversion-1.4.3/libtool  –tag=CC –silent –mode=relink gcc -g -O2 -g -O2 -pthread -D_LARGEFILE64_SOURCE -DNE_LFS -rpath /usr/lib/apache2 -avoid-version -module -o activity.lo deadprops.lo file_revs.lo liveprops.lo lock.lo log.lo merge.lo mod_dav_svn.lo replay.lo repos.lo update.lo util.lo version.lo ../../subversion/libsvn_repos/libsvn_repos- ../../subversion/libsvn_fs/libsvn_fs- ../../subversion/libsvn_delta/libsvn_delta- ../../subversion/libsvn_subr/ -lz )
libtool: link: warning: `/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../..//’ seems to be moved
libtool: link: warning: `/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../..//’ seems to be moved
libtool: link: warning: `/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../..//’ seems to be moved
libtool: link: warning: `/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../..//’ seems to be moved
cp .libs/mod_dav_svn.soT /usr/lib/apache2/
cp .libs/mod_dav_svn.lai /usr/lib/apache2/
cp .libs/mod_dav_svn.a /usr/lib/apache2/mod_dav_svn.a
ranlib /usr/lib/apache2/mod_dav_svn.a
chmod 644 /usr/lib/apache2/mod_dav_svn.a
PATH=”$PATH:/sbin” ldconfig -n /usr/lib/apache2
Libraries have been installed in:

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.
chmod 755 /usr/lib/apache2/
apxs:Error: Config file /etc/apache2/httpd2- prefork.conf not found.
make: *** [install-mods-shared] Error 1

-Roger Pack
“Men are that they might have joy.” (2 ne 2:25)

How to display the version of python in django

assuming you have an app called “mysite”

add this to


(r’^system/$’, ‘mysite.polls.views.system_list’),

now create the system_list function in

def system_list(request):
t = loader.get_template(‘polls/system.html’)
c = Context({
‘sys_version’: sys.version,
‘sys_executable’ : sys.executable
return HttpResponse(t.render(c))
and then create the system.html file (somewhere within your template paths)

[{{ sys_version }}] [{{ sys_executable }}]

And voila you may see it 🙂

Roger's meanderings, notes to himself, bug reports, and other things