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
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
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
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
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
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
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",
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
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
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
> 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"),
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
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
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
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
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
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
; 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
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
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
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
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
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):
"""
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
24 matches
Mail list logo