Archive for November, 2011

28
Nov
11

django create superuser automatically on syncdb


Found the following information here. Here’s how you can automatically create a superuser when syncing your db:


python manage.py dumpdata auth > initial_data.json 
python manage.py syncdb

Make sure to modify the initial.json file, if you want to change the name/mail of the superuser.

Advertisements
24
Nov
11

data URI scheme


This ( Data URI scheme ) is very helpful for serving images without storing them on server side.

21
Nov
11

always specify fields for django’s ModelForm as a tuple


So, I had a model that had a FileField called path, for which I wanted a ModelForm. Do not do this:


class MyModelForm(ModelForm):
   class Meta:
      model = MyModel
      fields= ("path")

It led to a strange error, saying django.core.exceptions.FieldError: Unknown field(s) (a, p, t, h). Of course, the fix was to specify the fields like:


class MyModelForm(ModelForm):
   class Meta:
      model = MyModel
      fields= ("path",)

21
Nov
11

django FileField and random names


To ensure that an uploaded file will have a random name, use a custom storage object, like described here.

18
Nov
11

training 17.11.2011


Bench Press:5x5x60kg
Low Row:5x5x60kg
Knee extension:5x5x30kg
Adductor:5x10x25kg

18
Nov
11

watir and no such file to load — ffi_c


After installing Watir, I received this error:

no such file to load — ffi_c

The fix was to install version 1.0.9 of the ffi gem:


gem uninstall ffi
gem install ffi -v 1.0.9

After that, it worked ok.

08
Nov
11

gmail via ruby


require "net/smtp"

msg = "Subject:test\n\nJust a test"
smtp = Net::SMTP.new("smtp.gmail.com",587)
smtp.enable_starttls
smtp.start("smtp.gmail.com","your_username","your_password",:login) do
  smtp.send_message(msg,"from_address","to_address")
end




Blog Stats

  • 226,733 hits