Distance across a LineString in GeoDjango

2009-10-10 Thread HARRY POTTRER
I have a model which represents a route. I can use the `make_line()` geoqueryset method to create a LineString like so: >>> r = Route.objects.get(pk=33) >>> # a route from Seattle to New York to Miami, a total distance >>> # of about 3043.8 nautical miles >>> r >>> # a collection of the airports

Re: Django Developer Position in New York City, Urgent Stuff

2009-10-14 Thread HARRY POTTRER
LOL @ everyone getting trolled by four letters On Oct 11, 8:05 pm, Wayne Koorts wrote: > >> Please refrain from posting messages with this tone to the Django mailing > >> lists. > > > I wholeheartedly agree. > > The Django community has a good reputation. > > Don't screw it up with your foul ver

Colored HTTP status codes

2009-10-27 Thread HARRY POTTRER
I was looking around the trac for the django project and came across this ticket: http://code.djangoproject.com/ticket/6385 It seemed like a pretty cool idea, and I hoped it would get to be added to the 1.2 release. Then I saw it was created over 2 years ago. I applied the patch to my cope of 1

mixing annotations and extra()

2009-11-16 Thread HARRY POTTRER
If you had a model called Flight which has two fields, one called "total_time", and the other called "distance", you could create a "speed" field like so: Flight.objects.extra(select={'speed': 'distance / time'}) Each object will now have a 'speed' field. What if one of those fields is a result o

Re: Multiple icontains using OR - Is it possible?

2009-12-15 Thread HARRY POTTRER
you're going to need the Q object, it seems. from django.db.models import Q MyModel.objects.filter(Q(summary__icontains=q) | Q (title__icontains=q)) On Dec 15, 10:32 pm, tm wrote: > Hello Django Users, > > I'm trying to use icontains to check 2 fields in the same table for a > keyword entered in

caching querysets between requests

2010-04-17 Thread HARRY POTTRER
I have a page that needs to get a few values via the aggregate function of querysets. There are about 15 of them, and they all look like this: SELECT SUM(some_column_name) FROM ... and they each take a few hundred milliseconds each. That makes the page take a lot longer to render than I'd like. I

surveys

2010-05-11 Thread HARRY POTTRER
I have a project that I'm working on that works like this: the user enters some points on a map which are then stored in a database as a LineString object (via geodjango). Along with the geographic data, the user is given a survey to fill out consisting of simple questions like "how fun was this",

select multiple without using foreignkey

2010-06-01 Thread HARRY POTTRER
I have a models that represents an event. I want it to have a field that represents the days of the week that the event occurs. This is easy if all you need to be able to do is be able to select one day, but if you want to select multiple, the right way seems to be to create a DayOfWeek object, cr

how should reusable apps handle url namespace?

2010-06-03 Thread HARRY POTTRER
I'm writing a forum app that I want to be reusable. All of my urls I have named. Some of them are named like "index" and "thread" which are generic and will likely collide with existing project's urls. I don't want to do something like name all my urls "forum_index" and "forum_thread" either. I th

Re: how should reusable apps handle url namespace?

2010-06-12 Thread HARRY POTTRER
On Jun 4, 4:10 am, Daniel Roseman wrote: > On Jun 4, 5:06 am, HARRY POTTRER wrote: > > > I'm writing a forum app that I want to be reusable. All of my urls I > > have named. Some of them are named like "index" and "thread" which are > > generi

Re: select multiple without using foreignkey

2010-06-18 Thread HARRY POTTRER
> Ages ago I wrote asnippetwith a model field and form field to deal > with this. It should still work. See:http://djangosnippets.org/snippets/1200/ > -- > DR. I'm using this snippet like so: MONTHS = [ (1, "January"), (2, "February"), (3, "March"),

adding custom variables to the Meta class

2010-01-04 Thread HARRY POTTRER
I have an class that I created which takes a queryset, and a field on the model that the queryset represents. Like this: mc = MyClass(queryset=MyModel.objects.all(), lat_lng_field='lat_lng') The class basically filters the queryset based on some geographical values, but in order to do that, it ne

fintering a queryset based on time

2010-02-02 Thread HARRY POTTRER
I have a table that has a bunch of rows, each with a datetime field. These rows are created every three hours (midnight, 03:00, 06:00, 09:00, etc). I want to filter the queryset to only grab the objects where the datetime field is midnight. Is there an easy way to do this? Something like: Model.ob

Re: fintering a queryset based on time

2010-02-02 Thread HARRY POTTRER
nevermind, i figured it out. .extra(where=['EXTRACT (HOUR FROM datetime) = 0']) add that to the queryset. Works in Postgres, don't know about the others On Feb 2, 10:47 pm, HARRY POTTRER wrote: > I have a table that has a bunch of rows, each with a datetime field. > T

django-debug-toolbar with runserver not running on localhost

2010-02-04 Thread HARRY POTTRER
I've noticed that if I run the django dev server on localhost, debug- toolbar works, but if I try to run he server like this: ./manage.py runserver 192.168.1.145:8000 the site will work, but the toolbar won't show up. Is there a work- around for this? -- You received this message because you ar

Re: django-debug-toolbar with runserver not running on localhost

2010-02-04 Thread HARRY POTTRER
gah you're correct, I can't believe I missed that setting. thanks On Feb 4, 4:48 pm, rebus_ wrote: > On 4 February 2010 22:06, HARRY POTTRER wrote: > > > I've noticed that if I run the django dev server on localhost, debug- > > toolbar works, but if

Expiring view caches

2010-02-11 Thread HARRY POTTRER
Is there any way to manually expire per-view caches? I have a view that executes between 100 and 200 database queries to render the page. The page basically renders a stats page for each user on my site. It only takes a few hundred milliseconds, but none the less I want some kind of cache sitting

Re: Expiring view caches

2010-02-11 Thread HARRY POTTRER
; On Thu, Feb 11, 2010 at 4:18 PM, HARRY POTTRER wrote: > > Is there any way to manually expire per-view caches? > > > I have a view that executes between 100 and 200 database queries to > > render the page. The page basically renders a stats page for each user > > on

Re: Expiring view caches

2010-02-11 Thread HARRY POTTRER
posting this here is the next best thing On Feb 11, 4:28 pm, HARRY POTTRER wrote: > Oh I see, the key is an entire request object. Thanks, that worked! > > On Feb 11, 4:22 pm, David Zhou wrote: > > > Check out this snippet: > > >http://www.djangosnippets.org/snippe

managers or classmethods?

2010-02-24 Thread HARRY POTTRER
Why not something like this: class Person(models.Model): @classmethod def male(cls): return cls.objects.filter(gender='M') @classmethod def female(cls): return cls.objects.filter(gender='F') name = models.CharField(maxlength=20) gender = models.CharField(m

entering text+images into a textfield

2010-03-10 Thread HARRY POTTRER
I have a project where I'm taking a bunch of articles originally written for a on a tripod page, and putting them into a database so they can be served up by django. Right now I have it all set up and working, but theres one problem. A lot of these articles are very image heave. Each one has an av

Re: if statement with url

2010-03-10 Thread HARRY POTTRER
maybe try request.path? On Mar 10, 1:51 pm, Daxal wrote: > Hey, > > I wanted to use a if statement with a url like ... > > if you are on "/cm/add/" > .. > endif > . > option 1: > I was wondering if anyone knows how to code that statement. if can > compare string variables like {% ifequal some

deepcopying form classes and thread safety

2010-03-29 Thread HARRY POTTRER
I have a model form in my project that has a field that is swapped out for another field based on user preferences. Some users want a select the value from a dropdown box, other people want to just type the value into a textbox. Before I had it like this: def proper_flight_form(profile): """

Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread HARRY POTTRER
On Mar 30, 12:08 pm, Sven Richter wrote: > > So if somebody could provide some working code, or a hint to > repository or an application with some working code, i'd really > appreciate that. > > Greetings > Sven You can look through my code: http://github.com/nbv4/flightloggin/blob/master/pdf/pd