I was just thinking…

Entries categorized as ‘django’

Django 1.0 install on Mac OS X 10.5.5

November 4, 2008 · Leave a Comment

I initially used this guide, but made some changes:

1) Downloaded Django-1.0.tar.gz from here.

2) Created and extracted the contents of the tar.gz:

mkdir ~/sandbox
cd ~/sandbox
tar xzf ~/Downloads/Django-1.0.tar.gz

3) Make the following soft-links:

cd /Library/Python/2.5/site-packages/
ln -s ~/sandbox/Django-1.0/django django
cd /usr/local/bin/
sudo ln -s ~/sandbox/Django-1.0/django/bin/django-admin.py django-admin.py

Categories: Apple · Programming · Python · django
Tagged: , , ,

django + screen

January 15, 2008 · Leave a Comment

I was working on a website, and quite often I open shells (I use Konsole), often leveraging the tabs Konsole has built in. But I sometimes hate having to switch tabs to see something, compare, reference etc.

My best solution was to keep Konsole windows separate. In Django I would run a konsole window on my top LCD display to display the running application (you know the ./manage.py runserver). While in a konsole window on my laptop display I would run yet another Konsole window to write code, etc.

I often use screen, but similar to tabs with Konsole, I get tired switching screens. Well there are the multiple windows in screen you can set up with a few simple keystrokes, something which I even blogged about previously. Yeah, I know its a cheap shot to link to your own blog! But I assure you, I could care less about how many visitors I get. :)

My latest problem with screen has been … on my laptop I reboot often. In fact, I like the idea of being able to shut down, take my laptop with me and pop it back up in a coffee shop, at my skydiving dropzone or even the library. What happens when I reboot? Screen settings are lost, and I have to reset everything back up once I turn the “machine” back on. (more…)

Categories: Linux · Linux Programming · django

Django: Binding uploaded files to a form

October 6, 2007 · Leave a Comment

Something as trivial as uploading a file via a HTML form was recently changed. I know because a development branch update broke one of my websites.  That will teach me to test better! :)

The designers specify:

File data is handled separately to normal form data, so when your form contains a FileField and ImageField, you will need to specify a second argument when you bind your form.

An example:

f = ContactFormWithMugshot(request.POST, request.FILES)

This is a bit different from before when you would inject the FILES into the POST before passing it to the FileUploadForm.

Everything has to change a little bit to keep us on our toes.

Link here

Categories: Programming · Python · django

Debug=False & !404.html = 500.html

September 24, 2007 · Leave a Comment

I like the Django web framework.  No really, I do!   But I wish the maintainers handled getting out their strong beliefs a little bit better.

I rolled some code to a production web server.  The website itself was not yet in production (it was a beta version awaiting sign off by the customer), but I had turned off the debugging stuff in the settings.py file.

The problem that existed is in my settings.py file I had:

DEBUG = False

If you set this global variable (setting) off, and you do not have a 404.html or 500.html in one of your template paths, a server error (500) is thrown.  Great…try debugging that one, it wasn’t easy…honest.

Google found it with these keywords:  DEBUG flatpages

Which returned Ticket #3335 (Flatpages with DEBUG = False requires 404.html)

Good design practice to follow? Yes!

Better way to stress the message of why you should create your own 404 and 500? Absolutely!!

Categories: Linux · Linux Programming · Programming · Python · django

Django’s newforms

July 14, 2007 · Leave a Comment

I was working through a file upload form using Django’s newforms. I wanted a file upload field with a custom size attribute similar to:

<input id=”id_file” type=”file” name=”file” size=”45″ />

The problem was trying to figure out how to specify the “size” attribute. Finally after wasting enough time I googled and found Ben’s blog posting. It seems Ben also was frustrated in trying to figure out how this worked. This is very new stuff (newforms), but I hope the Django authors get the documentation fleshed out a bit more sooner than later. BTW…the documenation page on newforms is here.

Here is a sample of my file input form field with a size specified:

file = forms.Field(label=”Resume File”, required=True, widget=forms.FileInput({’size’: 45}) )

Categories: Programming · Python · django

block.super

July 2, 2007 · Leave a Comment

This ended up resolving a bug for on Satchmo, but I hadn’t been aware of it prior to this.

In Django you can allow one template to inherit another one, keeping the original content and appending new content in the child template (or sub-template).

{% block sidebar %}

{{ block.super }}

… new content …

{% endblock %}

Read more about template inheritance in Django here.

Categories: Linux · Linux Programming · Programming · Python · django

Passing callable objects instead of strings

August 25, 2006 · 1 Comment

Reviewing documentation, I noticed a very nice suggestion and change now supported in the django web framework, written in python. Callable objects used to resolve URL requests are now supported:

(more…)

Categories: Python · django