Django Query using value from another field in same table

I came across a query that seemed like it should be pretty easy, but it wasn’t. Suppose you have the following Model Class. # pseudo code. class Person(models.Model): first_name = models.CharField() last_name = models.CharField() I would like the query to return all Person’s who have the same first_name and last_name My first guess was to do the following. person_list = Person.objects.filter(first_name=last_name) but that doesn’t work because it wants to have last_name as a variable.

Read more

Share

Managing Django settings across multiple environments

I don’t know about you, but when I typically work on a Django application I have at least two environments (Local and Production), and a lot of times I am working on these projects with at least one other person. The way that django currently supports project settings is to have all settings in a settings.py file. This works fine if you are working by yourself in one environment, but once you add something else, it makes managing the settings a pain.

Read more

Share

django common commands

I keep forgetting all of the different django commands so I am creating this cheat sheet for myself. # start a new project >>> django-admin.py startproject $mysite # create a new site inside of a project >>> python manage.py startapp $siteName # start dev server >>> python manage.py runserver # sync the database with recent model changes. >>> python manage.py syncdb

Read more

Share

iText HTMLWorker Style guide

iText provides a way to convert HTML snippets to PDF using the HTMLWorker class. Unfortunately there isn’t much documentation on what you can do for styles. In order to figure this out I went through the source code. I’m putting it here so that I won’t have to do that again, and so that others will be able to gain something from my pain. This is from iText 2.0.8 HTMLWorker supported tags “ol ul li a pre font span br p div body table td th tr i b u sub sup em strong s strike h1 h2 h3 h4 h5 h6 img”

Read more

Share

New version of CampRate.com is now Available

I just released a new version of CampRate.com and here are some of the new features / changes. I am about 90% finished with the new image uploader, it uses AJAX to make it look cool.. This just needs to be tested some more, and will be released when we finish with the new add/edit campground flow.95% finished with the PayPal upgrade. Just need to do some more testing. When complete, people can upgrade their listings to add new features using paypal.

Read more

Share

AJAX Struts File Upload Progress Meter

** This Post is a work in progress, and is still being worked on, it hasn’t been edited yet, and may contain errors, use at your own risk ** Over the course of the last year or so I have been hearing a lot about AJAX, and how cool it is, and what neat stuff you can do with it. At first I wasn’t too impressed, mostly because I have heard it all before.

Read more

Share

Debian Package management

Debian Package management apt-get update Run this after changing /etc/apt/sources.list or /etc/apt/preferences. (this debianhelp.org page is helpful); run it periodically anyway, to make sure your source list is up-to-date. apt-get install packagename installs a new package: rpm -i package.rpm apt-cache search string Searches for string in the list of known packages: like using rpmfind. dpkg -l package-name-pattern List packages matching pattern: rpm -q pattern or rpm -qa | grep pattern.

Read more

Share

CampRate.com online campground directory with reviews

Last summer a bunch of friends and I decided we would go camping. I have been camping before, when I was a kid, so I knew what I was getting myself into. First off I had to find out if I had all of the proper equipment. I found my Tent, sleeping bag, propane grill and some big blue tarps. Once I gathered all of my stuff and dusted it off, I needed to check with my friends to see if they had everything they needed as well.

Read more

Share

Getting WinCVS out of flat mode

If you accidentally browse up to the root directory or some other level that is too large for WinCVS to initially deal with and you have the flat mode browser view toggle button of WinCVS on, WinCVS will freeze indefinitely. If killing it in Task Manager and restarting doesn’t fix your problem, you need to hack the registry. Launch regedit (Start -> Run “regedit”) and browse to: HKEY_CURRENT_USER/Software/WinCvs/wincvs/CVS settings In CVS settings, find the variable P_DisplayRecursive in the right hand window.

Read more

Share

Commands I use, but often forget

Importing (Restoring) Many MySQLDump Text Files:~ from a user (paraphrased): “If we have 100+ mysqldump .txt files, how can we easily import them all, in order to restore a database, without typing each file name in by hand? (i.e. from the shell prompt, piped to the mysql monitor: mysql mydb <>). Wouldn’t it be better for the script to write all the tables to one text sql file?” => I suppose the script could be rewritten, but it’s more flexible the way it is, considering that one can use the Linux shell prompt to do the same thing.

Read more

Share