Friday, November 20, 2009

Django properties for

I wanted to externalize all of the properties in for obvious reasons. I found a couple of suggestions.

What I did was create to files, and Working locally I imported, "import properties_local as properties"
# Django settings for [project name] project.
import properties_local as properties

and then set the variables accordingly:
I only have to change the import setting. I should figure out a way around that soon though.

Thursday, November 19, 2009

Django template does not exist

I got a really annoying error while putting up a new Django site:

at /flatpage/
Request Method: GET
Request URL: http://[site url]/flatpage/
Exception Type: TemplateDoesNotExist
Exception Value:
Exception Location: /usr/lib/python2.4/site-packages/django/template/ in find_template_source, line 74
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/[python path]', '/usr/lib/', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages']
Server time: Thu, 19 Nov 2009 22:39:37 -0500
Of course I had templates in Apache's directory. The Template-loader postmortem (great name) showed that Django was looking for the wrong directory (in italics below.)

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/[development path]/flatpages/default.html (File does not exist)
Using loader django.template.loaders.app_directories.load_template_source:
/usr/lib/python2.4/site-packages/django/contrib/admin/templates/flatpages/default.html (File does not exist)
I know these things should be put into properties. I was being lazy.

I restarted the server to clear out whatever had cashed the older directory entry. Everything was fine.


Infoq Interview with Gavin King about Weld anc CDI

Infoq has a nice interview with Gavin King about Weld and CDI.

Seam is an excellent framework. Hopefully having its' model implemented as part of the JEE spec will push adoption!

Tuesday, November 10, 2009

Django flatpages, templatetags and dynamic menus

One thing that Django's flatpages app is missing is a dynamic menu.

Coming from a Java background I am used to a huge user base and lots of open source code. The Django user base continues to meet my expectations.

I found this post detailing the creation of such a menu tag. I hadn't explored custom tags before anyway so I looked forward to trying it out.

I followed the instructions and got the following error :

TemplateSyntaxError at /menu/
'flatpage_menu' is not a valid tag library: Could not load template library from django.templatetags.flatpage_menu, No module named flatpage_menu
Request Method: GET
Request URL:
Exception Type: TemplateSyntaxError
Exception Value:
'flatpage_menu' is not a valid tag library: Could not load template library from django.templatetags.flatpage_menu, No module named flatpage_menu
Exception Location: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/template/ in load, line 927
Python Executable: /Library/Frameworks/Python.framework/Versions/2.6/Resources/
Python Version: 2.6.4
Python Path: ['/Users/jdavis/Documents/django_workspace/cantina76', '/Library/Frameworks/Python.framework/Versions/2.6/lib/', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']

The post was from last year. I was using the Django 1.1.1. I figured something had changed since his post.

I found a couple of references in Google Groups to this same example, but their suggestions didn't work for me.

The solution was to add my own app to INSTALLED_APPS and "from django import template" to the "" file.

It worked fine after that.