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"),
(4, "April"),
(5, "May"),
(6, "June"),
(7, "July"),
(8, "August"),
(9, "September"),
(10, "October"),
(11, "November"),
(12, "December"),
]

class MyModel(models.Model):
months = MultiSelectField(max_length=30, choices=MONTHS,
help_text="What months of the year do you travel this route?")

And it works fine except for when I do MyModel.get_months_display() it
returns "1,2,3,4,5" instead of "January, Februrary, March, ..." Is
this by design, or am I using the snippet wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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
> > 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 think the best way is to use the newnamespacefeature, but I'm not
> > quite sure how to do it for reusuable apps. The docs make it seem like
> > the only purpose ofnamespaceurls is when you have two or more
> > instances of an app.
>
> You don't need to do anything with it. You don't define thenamespace
> in the application's urlconf, the end developer does it when they
> include your application's urlconf in their project-level one. See the
> docs on defining 
> namespaces:http://docs.djangoproject.com/en/1.2/topics/http/urls/#defining-url-n...
> --
> DR.

but how do I handle get_absolute_url? I don't see how I'm supposed to
resolve any urls if I don't supply it with a namespace...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 think the best way is to use the new namespace feature, but I'm not
quite sure how to do it for reusuable apps. The docs make it seem like
the only purpose of namespace urls is when you have two or more
instances of an app.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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, create 7 instances in
your db, the use ManyToMany relations. To me that just seems wrong.
I'd rather store it as a string like "WFS" or "MWF". Is there an easy
way to do this in django?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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", "how old are you", and "was
the parking sufficient", etc. There will be a pool of roughly 100
questions, and the survey will be constructed based on the locale of
the user. Different locales results in different sets of questions.
There are 40-50 locales for this project.

My question is how should I set up the surveys. I don't really want to
hard code each survey per locale. I'd prefer to have the questions and
choices defined in the database.

There is a reusable app called "django-survey" but as far as I can
tell the project is completely undocumented. I have it installed, but
I can't figure out how to use it. Is this app the kind of thing that I
can use, or is it meant for something else completely?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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'm thinking of
refactoring so it gets those values after the page renders via an Ajax
call.

Also, instead of having each one call it's own query, I'm thinking of
having each ajax call call one query like so:

SELECT SUM(column1), SUM(column2), ...

and take advantage of the fact that the above query is going to be
quicker than doing each one individually in database terms. Also,
doesn't django cache querysets? Does it cache them between requests?
Will the cache expire once the response is returned?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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/pdf.py

and an example of some output:

http://flightlogg.in/chris/print.pdf

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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):
"""
Prepares the popup flight form based on how the user wants each
field
widget to be rendered as.
"""

from plane.models import Plane
from logbook.forms import TextPlaneField, FlightForm

if profile.text_plane:
text_plane_field =
TextPlaneField(queryset=Plane.objects.none())
FlightForm.base_fields['plane'] = text_plane_field
return FlightForm

return PopupFlightForm

This was bad because when it edited the class like that, it effected
all users. The next request that came in had the incorrect form field.
I kept getting errors such as "ValueError: invalid literal for int()
with base 10: 'N488AF'", which is caused by the form rendering the
textbox, but when it comes time to recieve that data the form class
has changed in that it now expects the data to be an integer from a
dropdown box.

So then I changed the way it worked by just defining two different
form classes, one with the textbox field, the other with the dropdown
box. This worked 100% fine, but wasn't very flexible.

So then I edited it so it deepcopies the form class first, and then
edits the fields on that copied class. I thought this would work, but
we're back to square one.

This is what I have now:

def proper_flight_form(profile):
"""
Prepares the popup flight form based on how the user wants each
field
widget to be rendered as.
"""

from copy import deepcopy
from plane.models import Plane
from logbook.forms import TextPlaneField, FlightForm

if profile.text_plane:
text_plane_field =
TextPlaneField(queryset=Plane.objects.none())
NewForm = deepcopy(FlightForm)
NewForm.base_fields['plane'] = text_plane_field
return NewForm

return FlightForm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 somevariable url %} where
> "url" can be hard coded like "/cm/add" and somevariable would have to
> store the url which i think is too complex.
>
> option 2:
> some if statement that directly compares the url like {% if {url} == "/
> cm/add/" %}
>
> any thoughts and ideas guys?
>
> Thank you for all your replies. :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 average of
about 10 images.

I'm thinking of creating an app which acts, in part, as a modified
text widget in the admin. There will be a text box just like how there
is now, plus there will also be above it, another widget where you can
drag and drop images. When you save the model instance, it will save
those images into a directory named according to the slug of the
instance, or by the primary key, or maybe even the natural key.

Each image will be given a number based on the order of it being
uploaded. In the text box, where you want the images to be placed, you
enter something like  and the {1} will be replaced with
the url for that image.

Before I get started on this, does something similar to this exist? I
don't want to reinvent the wheel or anything...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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(maxlength=1)

instead of defining a 'female' and 'male' custom managers as is
illustrated in the docs? Whenever I need to define 'table level'
functionality, I've always gone with the above method rather than
bother with a custom manager. What am I missing out on?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Expiring view caches

2010-02-11 Thread HARRY POTTRER
just a quick note to anyone out there who finds this thread with the
same problem as me:

in that snippet, you need to change this line:

if cache.has_key(key):

to this:

if key and cache.has_key(key):

in order for it to work. It seems that registering accounts on django-
snippets is broken, so 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/snippets/936/
>
> > Some what old though (2008), so it might need updating to work properly.
>
> > -- dz
>
> > 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 my site. It only takes a few hundred milliseconds, but none the
> > > less I want some kind of cache sitting behind this page.
>
> > > The only problem is that the data on this page is somewhat dynamic.
> > > Whenever the user changes some data, the cache needs to be canceled
> > > and the page needs to be re-rendered. I can very easiely connect a
> > > signal or something to the user changing the data, but I'm having
> > > trouble figuring out how to expiring the view cache.
>
> > > I tried reverse()-ing the URL, and then feeding that into
> > > cache.delete(), but that didn't work. The docs really don't say how to
> > > expire per-view cache's other than just waiting for the expiration
> > > time to pass.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Expiring view caches

2010-02-11 Thread HARRY POTTRER
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/snippets/936/
>
> Some what old though (2008), so it might need updating to work properly.
>
> -- dz
>
> 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 my site. It only takes a few hundred milliseconds, but none the
> > less I want some kind of cache sitting behind this page.
>
> > The only problem is that the data on this page is somewhat dynamic.
> > Whenever the user changes some data, the cache needs to be canceled
> > and the page needs to be re-rendered. I can very easiely connect a
> > signal or something to the user changing the data, but I'm having
> > trouble figuring out how to expiring the view cache.
>
> > I tried reverse()-ing the URL, and then feeding that into
> > cache.delete(), but that didn't work. The docs really don't say how to
> > expire per-view cache's other than just waiting for the expiration
> > time to pass.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 behind this page.

The only problem is that the data on this page is somewhat dynamic.
Whenever the user changes some data, the cache needs to be canceled
and the page needs to be re-rendered. I can very easiely connect a
signal or something to the user changing the data, but I'm having
trouble figuring out how to expiring the view cache.

I tried reverse()-ing the URL, and then feeding that into
cache.delete(), but that didn't work. The docs really don't say how to
expire per-view cache's other than just waiting for the expiration
time to pass.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 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 are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Do you maybe have INTERNAL_IPS set in your settings?
> It's used to decide on which addresses the toolbar will be shown.
>
> Read more about this on:http://github.com/robhudson/django-debug-toolbar.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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.
> 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.objects.filter(datetime__hour="00:00")
>
> or something, but that actually works...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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.objects.filter(datetime__hour="00:00")

or something, but that actually works...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 needs to know which field the
coordinates are stored in.

Right now I have no choice but require you to pass in a string
representing the field name. But I think a better way would be to do
it kind of like this:

class MyModel(models.Model):
lat_lng = PointField()
name = CharFIeld(max_length=20)

class Meta:
verbose_name_plural = 'My Models'
lat_lng_field = 'lat_lng'

Then just modify MyClass to get the field name from the Model's Meta
class. Is this possible somehow? If not, whats the best way to go
about this without having to pass in the field name directly?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 into a search.
>
> ex I've tried:
>
> queryset = MyModel.objects.filter(summary__icontains=q).filter
> (title__icontains=q)
>
> and
>
> queryset = MyModel.objects.filter(summary__icontains=q,
> title__icontains=q)
>
> Neither work, although judging by the docs the second one shouldn't in
> this case.  Has anyone successfully searched a MySQL DB using
> icontains on 2 filelds in the same model?  Any help greatly
> appreciated :)
>
> T

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 of an annotation? In my particular case, 'distance' is
stored as an attribute of a Route object which is attached to Flight
via Foreign Key.

Flight.objects.annotate(distance=Sum('route__distance')).extra(select=
{'speed': 'distance / time'})

which doesn't work. How can this be achieved? Or is it even possible?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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.1, and it works perfectly. I've
been using it for 2 days and have had no problems.

What can I do to get this added to 1.2? (or any release for that
matter.) I have some free time, and a weird desire to make this part
of Django. I'm not familiar on how the whole process works. What do I
need to do?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 verbal attacks.
>
> Surely it should be grounds for instant removal?
>
> Regards,
> Wayne
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 used in the route
>>> # turned into a LineString
>>> ls = Airport.objects.filter(routebase__route=r).make_line()
>>> ls


How can I find the total distance of that LineString object, so that
it returns a Distance object that I can then convert to nautical
miles? the .length() method here just returns a float, which is in who-
knows-what units...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---