Archive

Archive for September 2nd, 2008

Format Python Decimal

September 2nd, 2008 No comments

This shows you how to take a Python Deciaml type number and format it so that it shows up with two places after the decimal place (like dollar values).

>>> num = Decimal("5")
>>> num.quantize(decimal.Decimal('.01'))

Categories: Python Tags:

Initial DB data

September 2nd, 2008 No comments

Within your application on the same level as your models place a folder named “fixtures”

In my current setup that means “app/models/fixtures/”, but in a normal setup that would be “app/fixtures/”

Within that file all you need to do is add a file with the extension “xml” or “json”. The syntax looks a lot nicer for “json”:

[
{
"model": "app_name.model_name",
"pk": 1,
"fields": {
"name": "A",
"value": 5
}
},
{
"model": "app_name.model_name",
"pk": 3,
"fields": {
"name": "C",
"value": 15
}
}
]

When you’re all set with your data all you need to do is run “python manage.py loaddata json_filename” (leaving off the “json” extension)

Categories: Django Tags:

Set default font in Emacs

September 2nd, 2008 1 comment

Within emacs select “options” from the menu bar: then “Customize emacs” –> “Specific Face…”

Type “default” (, or “def”) then press enter.

Then you can mess with all the settings. I have “misc-fixed” set for my “Font-family”

When you’re done just save the file as you would any file in Emacs: c-x c-s

Categories: Emacs Tags: