Whether to use Model Manager class for DAO

2008-10-15 Thread Info Cascade

Hi --

I am new to Django programming, and need a few tips on how to accomplish
something.

What I need is to have a model that provides a data access layer to
multiple databases. Something like what I have pseudocoded below.  The
idea is to just use the DataAccess layer (class) to access various files
and objects.
So --
da = DataAccess()
result = da.search('Jones')

class DataAccess:
def search(self, searchterm):
   if somecondition:
   se = SearchEngine()
   se.search(searchterm)
  """some more code here"""
   else:
  People.objects.filter(last_name=searchterm)

def add(self, obj):
   """add to search engine, AND add to database"""

def select(self, id)
   """select id from database"""
 
class SearchEngine:
def search(self, searchterm):
   """look in a SOLR server for searchterm"""
def add(self, obj):
def select(self, id)

class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
file_name=models.FileField(...)

But I'm wondering if this isn't a place I should be using a Model
Manager class.

Any ideas about how I should implement a DAO in Django?

Liam

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Timing is everything

2008-10-21 Thread Info Cascade

Hey,

I'm new to Django.  Be nice!
Is there some simple way to time the whole Django process, request to
response?
PHP has something like that.
I'd like to include that information in the response.

Any ideas?

Liam

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



S3Storage, Models, and Files...is this obvious?

2008-10-21 Thread Info Cascade

Hi --
Again, I'm new to Django (and for that matter, Python).

I am using the S3Storage module (and currently set default_storage to
S3Storage).

My model has a FileField which should store the file using S3 (because
S3Storage is the default).

I am creating an mp3 file using Popen, which is returning some
"content," that is the mp3 data.

Now, the question I have is how do I save the data to the model?

I think I need to pass the model a File object, but I'm not sure how I
get the data into a File object to pass to
Model.field.save().  I don't want to have to save it twice!

(And BTW, when I do an obj.save() on a model, so I have to re-get it or
something, in order to retrieve the auto-increment id?)

Okay, does anyone have an example of how to do this?  It would be a
great help!!!


Liam


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango problem -- server hangs on GEOSGeometry calls

2008-10-24 Thread Info Cascade
Hi, Justin,

Thanks SO much for responding!
We met at the WhereCamp meeting, you probably don't remember...
Thanks for looking at this.

Liam

Here's the info...

Server version: Apache/2.2.3
Server built:   Jan 15 2008 20:33:41
With mod_python
Python 2.4.3


ServerName rocket.domain.com
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /var/www/vhosts/rocket.domain.com/html
ErrorLog logs/rocket.domain.com-error_log
CustomLog logs/rocket.domain.com-access_log common

SetHandler python-program
PythonPath "sys.path +
['/var/www/vhosts/rocket.domain.com/django']"
PythonHandler django.core.handlers.modpython
SetEnv PYTHON_EGG_CACHE /var/cache/www/pythoneggs
PythonOption PYTHON_EGG_CACHE /var/cache/www/pythoneggs
SetEnv DJANGO_SETTINGS_MODULE rocket.settings
PythonOption DJANGO_SETTINGS_MODULE rocket.settings
PythonDebug On
PythonAutoReload On


SetHandler default-handler




# Django settings for rocket project.
from aws.S3 import CallingFormat

DEFAULT_FILE_STORAGE = 'aws.S3Storage.S3Storage'

AWS_ACCESS_KEY_ID = 'X'
AWS_SECRET_ACCESS_KEY = 'X'

AWS_STORAGE_BUCKET_NAME = 'xxx'
AWS_CALLING_FORMAT = CallingFormat.PATH
#AWS_CALLING_FORMAT = 'CallingFormat.SUBDOMAIN'

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'rocket' # Or path to database file if using
sqlite3.
DATABASE_USER = 'user1' # Not used with sqlite3.
DATABASE_PASSWORD = 'XX' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not
used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to
use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'xx'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'rocket.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.gis',
'django.contrib.sites',
'rocket.obs'
)
~ 
Justin Bronn wrote:
>   
>> However, if I access the application over http, the server hangs at
>> exactly that spot.  No error logged.
>> If I comment out the line, everything runs fine.
>> 
>
> You're going to have to provide more details on exactly what "http"
> means here.  How are you deploying, e.g., mod_wsgi, mod_python,
> fastcgi?  What's the configuration look like?  What's the web server,
> it's version?
>
> -Justin
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~

Re: GeoDjango problem -- server hangs on GEOSGeometry calls

2008-10-24 Thread Info Cascade

I've got it set on Permissive... I checked that before...
Damn!  Just checked the audit log and it's denying when I access the
app.  Even in Permissive mode.  WTF?
Okay, then.  I'll disable it completely.
I am so sick of selinux!
...
Okay, disabled in /etc/selinux/config, rebooted and now... no messages
in audit log, but same behavior!
Now what?

Justin Bronn wrote:
>> Also, it's on CentOS 5.2
>> Just want to be complete.
>>
>> 
>
> Turn off SELinux.  I'm almost positive that's your problem.
>
> -Justin
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango problem -- server hangs on GEOSGeometry calls

2008-10-25 Thread Info Cascade
Justin,

More, different information --
On further investigation, I've discovered that it's actually hanging
when I try to do a search:
> bbpoly = GEOSGeometry('POLYGON(( 38.302807 -122.867744,
> 38.482792 -122.867744, 38.482792 -122.633660, 38.302807 -122.633660,
> 38.302807 -122.867744))')
> art_list = Article.objects.filter(point__within=bbpoly)
This is on a MySQL database...  we're going to Postgres imminently.
That works if I do the search from the command line, but not if I am
doing it via http/views.py
> from django.contrib.gis.db import models
> from django.contrib.gis.geosimport *
>
> class Article(models.Model):
> id = models.AutoField(primary_key=True)
> title = models.CharField(max_length=300, blank=True)
> point = models.PointField(blank=True)
>   ..
> objects = models.GeoManager()
>
> class Meta:
> db_table = u'article'
> app_label = u'obs'
>
One thing that is different between the http version and the command
line version is that I'm setting up the environment "by hand" in the
script, like this. I don't know if that could have anything to do with it.
> import sys
> sys.path.append('/var/www/vhosts/obsidian.numenet.com/django/obsidian')
>
> from django.core.management import setup_environ
> import settings
> setup_environ(settings)

Any idea how I can debug this? I've got to get it working by Monday!

Trying not to panic...
Liam


Justin Bronn wrote:
>   
>> However, if I access the application over http, the server hangs at
>> exactly that spot.  No error logged.
>> If I comment out the line, everything runs fine.
>> 
>
> You're going to have to provide more details on exactly what "http"
> means here.  How are you deploying, e.g., mod_wsgi, mod_python,
> fastcgi?  What's the configuration look like?  What's the web server,
> it's version?
>
> -Justin
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



S3Storage, FileField -- default_storage.exists() has unwanted side-effects

2008-10-30 Thread Info Cascade
I have a model that has a FileField storage field.
The default_storage system is S3Storage.
I noticed that I was getting unusual results when I simply tried to
verify whether the file existed on disk using the
default_storage.exists() method.
If I call it with the FileField object, it causes Django to actually try
to *get* the file, which is not what I intend.  The S3Storage module
implements exists() as a simple http HEAD request. That part works
fine.  But then Django starts getting the file which eventually results
in an error, so it appears the file doesn't exist when really it does.  
(The file is an audio file, which triggers a series of byte-range
requests, the final one having incorrect value, so I'm getting a series
of 206 codes followed by 416 error code. It causes a key error in
S3Storage or S3 on 'etag'.)

I was able to work around it by using the str() function, which results
in the correct behavior.

Anyway, it was non-intuitive for me that checking whether a file exists
would make Django do a GET on it!  Is this a bug or do I just not
understand what's going on beneath the surface?  (Which is the case,
actually.)  Can someone explain this?

Liam

>
> section_objects =
> Section.objects.in_bulk(section_ids).values()
> if len(section_ids) != len(section_objects):
> print "section count mismatch for article '%d'" %
> (art.id)
> idx = 0
> for sec in section_objects:
> idx += 1
> if sec.url:
> try:
> if not default_storage.exists(*str*(sec.url)):
> print "\tarticle '%s' missing content
> for section %d" % (art.id, idx)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get comment_count in view?

2008-11-04 Thread Info Cascade

I was just asking myself a similar question. I want to know the total
result count of a query but only return  a subset of the query.
Articles.objects.filter(somefield__contains='some
query')[start:start+num_rows]

I understand the slice creates a LIMIT in the database query.  But I
also need the total non-limited result count, which could potentially be
quite large.  It seems wasteful to get the entire query result and then
use .count() or len() to get the number of rows returned, and *then*
slice it anyway.

What is the best approach?

In MySQL it's possible to do
select SQL_CALC_FOUND_ROWS  * from table limit 5,10
Then, you can do "select FOUND_ROWS()"

Has anyone tried something similar?  I'm now using Postgres, which I
assume has some similar functionality. Anyone know what it is?

Any comments welcome.

Best,
Liam



Chatchai Neanudorn wrote:
> from django.contrib.comments.models import Comment
> from post.models import Post
>
> #get comments for model
> Comment.objects.for_model(Post).count()
>
> #get comment for instance
> Comment.objects.for_model(Post.objects.get(id=1)).count()
>
> 2008/11/2 David.D <[EMAIL PROTECTED]
> >
>
>
> I can get comment_count in templates:
>
> {% get_comment_count for object as comment_count %}
>
>
> But how to get it in my view?
>
>
>
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango in Ubuntu 8.10, Segmentation Fault

2008-11-24 Thread Info Cascade

I reported a similar problem in October. Since then, I have tested on a
new server and am experiencing the same problem.  This one is on an
CentOS 5.2 EC2 machine configured as below... I wonder if noting the
workaround discovered by GRoby will give the developers any clues as to
what is going on.  I guess I'll move to Apache 2.2.8 and see if that helps.
Again, it works fine from the command line, but only seg viols when
using Apache.
Justin was good enough to run a test case I created and was unable to
duplicate the error.  I'm wondering now about the exact versions of
Apache and other components that might be causing the problem.

> Linux domU-12-31-39-02-94-32 2.6.16.33-xenU #2 SMP Wed Aug 15 17:27:36
> SAST 2007 x86_64 x86_64 x86_64 GNU/Linux
> mod_python.x86_643.2.8-3.1  installed
> python.x86_642.4.3-19.el5  
> installed 
The Apache configuration:
> Server version: Apache/2.2.3
> Server built:   Nov 10 2007 12:44:14
> Server's Module Magic Number: 20051105:3
> Server loaded:  APR 1.2.7, APR-Util 1.2.7
> Compiled using: APR 1.2.7, APR-Util 1.2.7
> Architecture:   64-bit
> Server MPM: Prefork
>   threaded: no
> forked: yes (variable process count)
> Server compiled with
>  -D APACHE_MPM_DIR="server/mpm/prefork"
>  -D APR_HAS_SENDFILE
>  -D APR_HAS_MMAP
>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
>  -D APR_USE_SYSVSEM_SERIALIZE
>  -D APR_USE_PTHREAD_SERIALIZE
>  -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
>  -D APR_HAS_OTHER_CHILD
>  -D AP_HAVE_RELIABLE_PIPED_LOGS
>  -D DYNAMIC_MODULE_LIMIT=128
>  -D HTTPD_ROOT="/etc/httpd"
>  -D SUEXEC_BIN="/usr/sbin/suexec"
>  -D DEFAULT_PIDLOG="logs/httpd.pid"
>  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
>  -D DEFAULT_LOCKFILE="logs/accept.lock"
>  -D DEFAULT_ERRORLOG="logs/error_log"
>  -D AP_TYPES_CONFIG_FILE="conf/mime.types"
>  -D SERVER_CONFIG_FILE="conf/httpd.conf"

GRoby wrote:
> I replaced packages one at a time with ones from Ubuntu 8.04.  The
> segmentation faults went away when I switched Apache from 2.2.9 to
> 2.2.8, so I can just lock the package with the Hardy version for now.
>
>
> On Nov 18, 4:34 pm, GRoby <[EMAIL PROTECTED]> wrote:
>   
>> Hello,
>>
>> I created a GeoDjango application that I have been successfully using
>> with Ubuntu 8.04.
>>
>> I would like to have as many packages as possible handled by the OS,
>> so I am testing it with Ubuntu 8.10, with all packages installed
>> through Synaptic (including PostGIS, PostGreSQL, Mod-Python, Psycopg2,
>> Django, etc).
>>
>> In a Python Shell, I am able to perform queries on my spatial models
>> successfully.  In a web browser, I get a plain white screen if any
>> code is executed that works with spatially enabled models.  Otherwise
>> everything seems to be working (including an OpenLayers MapServer
>> view, so I know the DB is loaded correctly).
>>
>> In the error.log file, I get a single error per attempted page view
>> like:
>> [Tue Nov 18 16:13:43 2008] [notice] child pid 21074 exit signal
>> Segmentation fault (11)
>> [Tue Nov 18 16:16:59 2008] [notice] child pid 21071 exit signal
>> Segmentation fault (11)
>> [Tue Nov 18 16:19:08 2008] [notice] child pid 21328 exit signal
>> Segmentation fault (11)
>>
>> If I attempt to run the same code in a Python Shell, the code runs
>> correctly.
>>
>> Any ideas, I suspect that it could be a permission or Mod-Python
>> related issue but am not sure where to go from here.
>>
>> Thanks!
>>
>> BTW, if anyone wants a copy of the application, it is available 
>> fromhttp://www.coopgis.org, it is the start of an Electric Utility GIS.
>> 
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango in Ubuntu 8.10, Segmentation Fault

2008-12-01 Thread Info Cascade

FWIW --

I got this working in CentOS5.2 by removing the default (yum installed)
version of apache, and compiling the latest version, 2.2.10.
While I was at it, I compiled the latest version of mod_python.
That was all it took, and now, no more segmentation violations.

Thanks,
Liam

Justin Bronn wrote:
>> Based on comments in a separate thread, GeoDango may have issues with
>> multithreaded configuration. Which Apache MPM was being used for each
>> Apache version, prefork or worker? The worker MPM uses threads and so
>> that could be the culprit.
>> 
>
> Yes -- the libraries GeoDjango uses, GEOS and GDAL, are not thread
> safe.  Thus, it is highly recommended to use the prefork version of
> Apache.
>
>   
>> In a Python Shell, I am able to perform queries on my spatial models
>> successfully.  In a web browser, I get a plain white screen if any
>> code is executed that works with spatially enabled models.
>> 
>
> I created an Ubuntu 8.10 VM to try and test out this problem.
> However, the only way that I could reproduce your exact problem
> (segfault upon HTTP request) is when using the mpm-worker (threaded)
> Apache.  When using the prefork, however, I was able to get both
> mod_python and mod_wsgi to work with a simple demonstration app [1].
> I think mpm-worker is the default when you do `apt-get install
> apache2`, so make sure you have it removed, e.g., `apt-get remove
> apache2-mpm-worker; apt-get install apache2-mpm-prefork`.
>
> BUT, I found another issue -- while I could login to and browse the
> admin interface, whenever I tried to view a geographic model an
> exception would get raised (but no segfault) deep in the admin widgets
> [2], crashing the app.  While this crash occurs in 8.10 it does _not_
> happen in my 8.04 VM.  Thus, this leads me to believe that it may be a
> manifestation of the same troubles you're experiencing.  Moreover,
> this admin crash happens with _both_ mod_python and mod_wsgi in 8.10
> (mod_wsgi configured with `threads=1`).
>
> Needless to say, this behavior has me perplexed at the moment, and due
> to my finals I'm not going to have a lot of time to dig in deeper
> until next month.  Perhaps there's a clash of the libraries that are
> linked to Apache and the ones used by the packaged versions of GEOS/
> GDAL, or maybe it's caused by Ubuntu's AppArmor (confined to just CUPS
> in 8.04) -- but these are just potential possibilities.
>
>   
>> Justin was good enough to run a test case I created and was unable to
>> duplicate the error.  I'm wondering now about the exact versions of
>> Apache and other components that might be causing the problem.
>> 
>
> I still have the CentOS 5.2 VM, and I'll test it out again, but I'm
> not sure yet that this could be the same issue as you reported in
> October.  It's a different distribution that used significantly older
> versions (that also worked in my tests).
>
> [1] http://geodjango.org/hg/world
> [2] 
> http://code.djangoproject.com/browser/django/trunk/django/contrib/gis/admin/widgets.py#L43
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to import DoesNotExist exception ???

2008-12-08 Thread Info Cascade

How do I import the DoesNotExist exception?

This doesn't seem to work:
> from django.db.models.query import DoesNotExist
> try:
> tag = Tag.objects.get(name=cat_name)
> except DoesNotExist:
> # do something else
Doesn't DoesNotExist exist?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to import DoesNotExist exception ???

2008-12-08 Thread Info Cascade

I just want to catch the exception thrown when the query returns nothing.
Thanks, that seems to have done the trick.

[EMAIL PROTECTED] wrote:
> I'm not sure where you got that code snippet from, but DoesNotExist is
> an attribute on model classes, so that shoul read:
>
> except Tag.DoesNotExist.
>
> On Dec 8, 2:52 pm, Info Cascade <[EMAIL PROTECTED]> wrote:
>   
>> How do I import the DoesNotExist exception?
>>
>> This doesn't seem to work:> from django.db.models.query import DoesNotExist
>> 
>>> try:
>>> tag = Tag.objects.get(name=cat_name)
>>> except DoesNotExist:
>>> # do something else
>>>   
>> Doesn't DoesNotExist exist?
>> 
> >
>
>   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[no subject]

2008-12-14 Thread Info Cascade

Hi --

I have a question about many-to-many relationships and how to reference
a related object field using Django syntax via the Manager class.
I think this is probably pretty simple and just reflects my inexperience
working with Django (which overall I am enjoying, btw.)
Anyway, the models look  like this:

class Poi(models.Model): # A "Point of Interest"
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=1024, null=False, db_index=True)
articles = models.ManyToManyField('Article', null=True,
db_table='poi_articles')

class PoiRank(models.Model):
poi = models.OneToOneField(Poi, primary_key=True)
rank = models.IntegerField(null = False, blank = False)

class Article(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=1024, blank=True, db_index=True)
pois = models.ManyToManyField(Poi, null=True, db_table='poi_articles')
status = models.CharField(max_length=27, blank=True)


One Poi can have many Articles written about it.  One Article can be
referenced by many Poi's.
A Poi has 0 or 1 "rank" value which is some measure of its popularity.

Now, I had to set the db_table name to poi_articles because otherwise I
ended up with what were essentially duplicate tables (just with the
order of the foreign keys swapped).
Of course, doing that I then had to remove the duplicate poi_articles
table that got generated the first time I ran syncdb.
This makes me think that I may not have set things up correctly in the
first place.

Anyway, after doing a query I have a QuerySet of articles.  I need to
know that the rank of the article is.  That's all.  It should be simple,
right?

The following SQL give the expected result if I enter it directly:
SELECT p.title, a.status, pr.rank FROM article a
INNER JOIN poi_articles ON a.id = poi_articles.article_id
INNER JOIN poi p ON poi_articles.poi_id = p.id
INNER JOIN poi_rank pr ON pr.poi_id = p.id
WHERE a.id = 803827;

But, how do I create that query using Django syntax and the Manager?

Any help will be very much appreciated!

Thanks,
Liam




--~--~-~--~~~---~--~~
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: Querying across many-to-many relations

2008-12-14 Thread Info Cascade
Malcolm,

Thanks for pointing that out!  That set me on the right course, and I
was able to get things working with _ArticleRank_ this time.
I have a follow-up, though.  Not every article has been assigned a rank.
When a search includes an article without a rank I get an error.
I can just trap the exception, but... is there some better way of
dealing with this?
It's okay to just assign articles with no rank the rank of 0.

Anyway, thanks so much for your prompt and very helpful response!

Liam



Malcolm Tredinnick wrote:
> (You forgot to include a title. I nearly nuked this as spam, by
> accident. So I've thrown in a title for fun.)
>
> On Sun, 2008-12-14 at 19:50 -0800, Info Cascade wrote:
>   
>> Hi --
>>
>> I have a question about many-to-many relationships and how to reference
>> a related object field using Django syntax via the Manager class.
>> I think this is probably pretty simple and just reflects my inexperience
>> working with Django (which overall I am enjoying, btw.)
>> Anyway, the models look  like this:
>>
>> class Poi(models.Model): # A "Point of Interest"
>> id = models.AutoField(primary_key=True)
>> 
>
> By the way, you can leave this out. Django will automatically create a
> field with that name for you that is the primary key.
>
>   
>> title = models.CharField(max_length=1024, null=False, db_index=True)
>> articles = models.ManyToManyField('Article', null=True,
>> db_table='poi_articles')
>>
>> class PoiRank(models.Model):
>> poi = models.OneToOneField(Poi, primary_key=True)
>> rank = models.IntegerField(null = False, blank = False)
>>
>> class Article(models.Model):
>> id = models.AutoField(primary_key=True)
>> title = models.CharField(max_length=1024, blank=True, db_index=True)
>> pois = models.ManyToManyField(Poi, null=True, db_table='poi_articles')
>> status = models.CharField(max_length=27, blank=True)
>>
>>
>> One Poi can have many Articles written about it.  One Article can be
>> referenced by many Poi's.
>> A Poi has 0 or 1 "rank" value which is some measure of its popularity.
>>
>> Now, I had to set the db_table name to poi_articles because otherwise I
>> ended up with what were essentially duplicate tables (just with the
>> order of the foreign keys swapped).
>> Of course, doing that I then had to remove the duplicate poi_articles
>> table that got generated the first time I ran syncdb.
>> This makes me think that I may not have set things up correctly in the
>> first place.
>> 
>
> I don't see anything in your explanation that requires having a
> ManyToManyField on both Article and Poi. Just put the ManyToMany on one
> of the models and you can still use it to refer back and forth. Django's
> relation fields are created nicely so that you only need to specify one
> end, not both. What you have done to hack around this sounds like it
> might lead to problems later.
>
> For argument's sake, I'll assume you get rid of the "pois" attribute on
> the Article table
>
>   
>> Anyway, after doing a query I have a QuerySet of articles.  I need to
>> know that the rank of the article is.  That's all.  It should be simple,
>> right?
>> 
>
> The problem is that your requirement is not well-defined. If you have
> any particular single Article object, there can be many Poi objects
> related to it (that was part of your problem description), each one
> having a different rank. There's no single rank value associated with a
> single Article.
>
> Regards,
> Malcolm
>
>
>
> >
>
>   


--~--~-~--~~~---~--~~
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: Querying across many-to-many relations

2008-12-14 Thread Info Cascade

A more complete explanation:

Ordering on the related table works fine as long as all the articles
have an associated ArticleRank (article_rank.rank, depending on how you
look at it).
> order_by = '-articlerank__rank'
> art_list = Article.objects.filter(\
> title__icontains=term, status='PUBLISHED')\
> .distance(pnt)\
> .order_by(order_by)
A search that includes articles with no entry in the ArticleRank table
*does* include them in the result set, but puts them *first* in the
ordering results.  Then, it includes the rest of the correctly ordered
results.  This is a little confusing.
If I try to access the article's rank (one with a missing ranking) I get
an error.  So, I'm trapping the exception like this:
try:
 article_rank = art.articlerank.rank
except ArticleRank.DoesNotExist:
 article_rank = 0

That's okay, but the ordering is still a problem.  I want it to treat
missing rank as if it were 0 and put those at the bottom of the list.

I suppose I could just add the articles with no ranking to the
article_rank table and give them a ranking of 0.
Is there a better way?


Liam




Malcolm Tredinnick wrote:
> (You forgot to include a title. I nearly nuked this as spam, by
> accident. So I've thrown in a title for fun.)
>
> On Sun, 2008-12-14 at 19:50 -0800, Info Cascade wrote:
>   
>> Hi --
>>
>> I have a question about many-to-many relationships and how to reference
>> a related object field using Django syntax via the Manager class.
>> I think this is probably pretty simple and just reflects my inexperience
>> working with Django (which overall I am enjoying, btw.)
>> Anyway, the models look  like this:
>>
>> class Poi(models.Model): # A "Point of Interest"
>> id = models.AutoField(primary_key=True)
>> 
>
> By the way, you can leave this out. Django will automatically create a
> field with that name for you that is the primary key.
>
>   
>> title = models.CharField(max_length=1024, null=False, db_index=True)
>> articles = models.ManyToManyField('Article', null=True,
>> db_table='poi_articles')
>>
>> class PoiRank(models.Model):
>> poi = models.OneToOneField(Poi, primary_key=True)
>> rank = models.IntegerField(null = False, blank = False)
>>
>> class Article(models.Model):
>> id = models.AutoField(primary_key=True)
>> title = models.CharField(max_length=1024, blank=True, db_index=True)
>> pois = models.ManyToManyField(Poi, null=True, db_table='poi_articles')
>> status = models.CharField(max_length=27, blank=True)
>>
>>
>> One Poi can have many Articles written about it.  One Article can be
>> referenced by many Poi's.
>> A Poi has 0 or 1 "rank" value which is some measure of its popularity.
>>
>> Now, I had to set the db_table name to poi_articles because otherwise I
>> ended up with what were essentially duplicate tables (just with the
>> order of the foreign keys swapped).
>> Of course, doing that I then had to remove the duplicate poi_articles
>> table that got generated the first time I ran syncdb.
>> This makes me think that I may not have set things up correctly in the
>> first place.
>> 
>
> I don't see anything in your explanation that requires having a
> ManyToManyField on both Article and Poi. Just put the ManyToMany on one
> of the models and you can still use it to refer back and forth. Django's
> relation fields are created nicely so that you only need to specify one
> end, not both. What you have done to hack around this sounds like it
> might lead to problems later.
>
> For argument's sake, I'll assume you get rid of the "pois" attribute on
> the Article table
>
>   
>> Anyway, after doing a query I have a QuerySet of articles.  I need to
>> know that the rank of the article is.  That's all.  It should be simple,
>> right?
>> 
>
> The problem is that your requirement is not well-defined. If you have
> any particular single Article object, there can be many Poi objects
> related to it (that was part of your problem description), each one
> having a different rank. There's no single rank value associated with a
> single Article.
>
> Regards,
> Malcolm
>
>
>
> >
>
>   


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Postgres Full-text search -- is it possible?

2008-12-15 Thread Info Cascade
Hi --

I'm wanting to improve searches by using full-text searching.  The
documentation says:
>
>
> search¶
> 
>
> A boolean full-text search, taking advantage of full-text indexing.
> This is like contains but is significantly faster due to full-text
> indexing.
>
> Note this is only available in MySQL and requires direct manipulation
> of the database to add the full-text index.
>
What options are available for Postgres if any?  Postgres has this
capability, I believe. Can Django not use it?

Liam

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Getting SQL from QuerySet

2008-12-30 Thread Info Cascade

Hi --

I am getting intermittent errors on certain database queries on our
production server.
I am having a hard time duplicating them (most of the time they run
okay, only sometimes on the production server am I receiving exception
messages),
so I want to log the SQL query itself and see what it is, and why it
might be failing.
Is there some way of seeing what SQL statement will be executed by a
QuerySet before actually executing it?
I've also set up logging on the database side, so I can look there as well.
Any other ideas for how I might debug this?  See anything wrong with the
queries?
I do need to know the total number of articles returned, and .count() is
the recommended way of doing that. In most cases I'm slicing the
QuerySet after getting the count.

Any help would be very much appreciated!

 ~Liam

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 
86, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/var/www/vhosts/site.com/django/obsidian/obs/views.py", line 219, in 
index
radius=radius, order_by='distance')

  File "/var/www/vhosts/site.com/django/obsidian/obs/data_access.py", line 551, 
in search
art_result_count = art_list.count()

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 296, 
in count
return self.query.get_count()

  File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
237, in get_count
data = obj.execute_sql(SINGLE)

  File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
1734, in execute_sql
cursor.execute(sql, params)

InternalError: current transaction is aborted, commands ignored until end of 
transaction block



The code looks like this:

 if term:

if pnt:

art_list = Article.objects.filter(\

status='PUBLISHED')\

.extra(where=["title_tsv @@ plainto_tsquery(%s)"], 
params=[term])\

.distance(pnt)\
.order_by(*order_by)


else:

art_list = Article.objects.extra (\

where=['title_tsv @@ plainto_tsquery(%s) AND 
status=%s'],params=[term,'PUBLISHED'])\

.order_by(*order_by)

elif search_origin:

try:

art_list = Article.objects.filter(status='PUBLISHED',\

point__distance_lte=(pnt,D(km=radius))).distance(pnt)\

.order_by(*order_by)

except Exception, e:

raise

else:   

raise


The exception comes when I execute the query by getting the count

 art_result_count = art_list.count()
 if rows:
 art_list = art_list[start:start+rows]




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django Developers Wanted

2009-01-23 Thread Info Cascade

Hi --

This will probably be of most interest to Django developers in the San
Francisco Bay Area,
but the company is open to hearing from anyone who might be interested.
This is a new product already getting great press, and a fun development
team.

Feel free to contact me if you have any questions or would like to be
considered.

Best,
Liam



Subject: Internet Developers Wanted for Unique Mobile Application

We're looking for great developers to join our team producing a unique
mobile application for consumers.  We recently launched on the iPhone and
we're getting great traction.  Now it's time to step it up and add the right
people to help accelerate development and porting to other clients.

Our product integrates a number of next generation mobile device and web 2.0
capabilities, including geolocation, mapping, media streaming and
social-networking.  This is your opportunity to apply your skills to a
killer mobile experience unlike anything else and help take us to the next
level.

Our implementation incorporates agile, flexible, and elegant execution of
standard technologies.  While we will consider anyone with a burning desire
to code, the following knowledge/skills are a good indication of our
environment and what we desire:

* Python
* Django (and GeoDjango)
* Memcached
* POSTGRES Replication/Clustering
* Javascript Libraries like jQuery or Dojo
* Database administrator experience
* HTML, CSS, JavaScript, AJAX, XML
* Page Load Optimization
* SEO

Both client and server-side experience are preferred, but not required. If
your experience includes UI and graphic design, that's a plus. We are open
to full-time independent contractors and those looking to take on side
projects outside of their fulltime job.

We are currently looking to close on additional financing so flexibility
around near term compensation is desired.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



FormSet with non input-element data possible?

2009-02-09 Thread Info Cascade

Hi --

I'm creating a FormSet and want to include some data in the form output
that is not an html input element.

Some of the data I pass to the FormSet, which gets passed to the form, I
just want to display, I don't want to put it into an HTML input
element.  I want it to be available in the template.  Here is what I
tried, which doesn't work:


class SectionForm(forms.Form):
section_id = forms.IntegerField(label='Section ID:', required=False,
widget=forms.HiddenInput())
section_title = forms.CharField(label='Title', required=True)
section_text = forms.CharField(label='', widget=forms.Textarea,
required=True)
  
def __init__(self, data=None, auto_id='id_%s', prefix=None,
initial=None, empty_permitted=False):
super (SectionForm, self).__init__(data, auto_id, prefix,
initial, empty_permitted)
   
# This is what I want to do, more or less, but it won't work
(TypeError: unscriptable object)
#self.s3_audio_file = initial['s3_audio_file']


In the template, I want to display s3_audio_file, but I don't need or
want it to be editable.  It's for information only.  Just text, or
html-formatted text.

{{ form.s3_audio_file }}

Is there some way to have the form contain arbitrary data that I pass to
it with the "initial" dictionary?
Perhaps, I have to create a faux Widget and Custom field?  That seems
like a long way around for something that should be simple.

Thanks in advance for any help.

Best,
Liam


Also, I was unsure about what to do with empty_permitted -- I got an
error before I added it to the  super() call.






--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django Developers Wanted

2009-04-01 Thread Info Cascade

Hi, Joe,

We're looking for a Django developer, and I happened upon your profile
at DjangoGigs.
If this looks like it might be of interest, please contact me for more
information.

Best,
Liam Kirsher
415.456.4420


--

Hi --

This will probably be of most interest to Django developers in the San
Francisco Bay Area (our office is located in San Francisco), but the
company is open to hearing
from anyone who might be interested.  This is a new product already
getting great press, over 400,000 downloads, and a fun development team.

Feel free to contact me if you have any questions or would like to be
considered.

Best,
Liam



Subject: Internet Developers Wanted for Unique Mobile Application

We're looking for great developers to join our team producing a unique
mobile application for consumers.  We recently launched on the iPhone and
we're getting great traction.  Now it's time to step it up and add the right
people to help accelerate development and porting to other clients.

Our product integrates a number of next generation mobile device and web 2.0
capabilities, including geolocation, mapping, media streaming and
social-networking.  This is your opportunity to apply your skills to a
killer mobile experience unlike anything else and help take us to the next
level.

Our implementation incorporates agile, flexible, and elegant execution of
standard technologies.  While we will consider anyone with a burning desire
to code, the following knowledge/skills are a good indication of our
environment and what we desire:

* Python
* Django (and GeoDjango)
* Memcached
* POSTGRES Replication/Clustering
* Javascript Libraries like jQuery or Dojo
* Database administrator experience
* HTML, CSS, JavaScript, AJAX, XML
* Page Load Optimization
* SEO

Both client and server-side experience are preferred, but not required. If
your experience includes UI and graphic design, that's a plus. We are open
to full-time independent contractors and those looking to take on side
projects outside of their fulltime job.

We are currently looking to close on additional financing so flexibility
around near term compensation is desired.



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Need help with Query: Q Objects and .extra()

2009-11-13 Thread Info Cascade
Hi --

I need help with a query!

Currently using .extra to do full text query on the article.title field.

art_list = Article.objects.filter(status__status='PUBLISHED')
art_list = art_list.extra(
  where=['title_tsv @@ plainto_tsquery(%s)'],
  params=[term])

That works great.

I want to add the ability to search in a table of tags, so that I return
articles with matching titles plus articles with tags that match the
search term.  That involves a OR statement, for which I believe I need
to use a Q object.

What I can't figure out is how to use the Q object with the .extra. 
Additionally, I need to select distinct() because there can be more than
one matching tag.

The end SQL should look something like this:
SELECT DISTINCT article.*
FROM article JOIN article_tags ON article.id = article_tags.article_id
JOIN tag ON article_tags.tag_id = tag.id
JOIN article_status ON article_status.id = article.status_id
WHERE article_status.status = 'PUBLISHED' AND (tag.name LIKE '%volcano%'
OR title_tsv @@ plainto_tsquery('Aarhus')) ORDER BY article.title;

That gives the correct results, although it's a bit slow.

What I want might look something like this:
 art_list = Article.objects.filter(status__status='PUBLISHED',
QExtra(where=['title_tsv @@ plainto_tsquery(%s)'],
params=[term])) |
Q(tags__name__icontains=term)).distinct()

I may end up doing the tag query using full text search, in which case
it would have to go in the extra(), but I'm not sure about the syntax
for doing the joins "manually" in extra().

Anyone have any suggestions on how to do this?

Liam






--

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=.




Help with Custom Manager and UNION query?

2009-11-30 Thread Info Cascade
Hi --

I've been programming with Django about a year, and really like it, but
I've run into something that I can't quite solve on my own.
I think someone else may be able to offer the answer, or at least a hint
to send me in the right direction.

I have two tables I want to search in simultaneously, Article and Tag. 
They have a many-to-many relationship.
I want to get a QuerySet of Articles that match a query term on
article.title, as well as those that match on tag.name.
I can get what I want using SQL, but how do I do it in Django (with
acceptable performance)?
Ideally, I want to be able to add .filter() and .exclude() to the
QuerySet.  These SQL examples below are the basic idea, but in some
cases I'm adding .filter and .exclude.
Currently, the code looks something like this (I simplified it a bit,
but this should give an idea):
>
> art_list = Article.objects.filter(status__status='PUBLISHED')
> art_list = art_list.extra(
> where=["title_tsv @@ plainto_tsquery(%s)"],
> params=[term])
>  if channel:
> art_list = art_list.filter(channel=channel)
>  art_list = art_list.distinct()
>  art_list = art_list.order_by(*order_by)
Somehow, I want to include the fulltext search on the tag.name field,
where=['name_tsv @@ plainto_tsquery(%s)'],
params=[term])

The two SQL example queries below both give the correct results.
However, the first one with joins takes over 20 seconds.
The second one with UNION is quite fast.

I think what I need to do might be to create a custom manager for
Article that would execute the UNION query and return a QuerySet with
all the matching Articles.  I'm not sure quite how to do that,
especially if I expect it to work with the .filter() and .exclude()
methods. 


-- full-text search on article.title and tag.name
SELECT DISTINCT article.title  
FROM article JOIN article_tags ON article.id = article_tags.article_id
JOIN tag ON article_tags.tag_id = tag.id
JOIN article_status ON article_status.id = article.status_id
WHERE article_status.status = 'PUBLISHED'
AND (tag.name @@ plainto_tsquery('french restaurants')
OR title_tsv @@ plainto_tsquery('french restaurants'))
ORDER BY article.title;


-- alternative full-text search on article.title and tag.name with UNION
--  with ranking
SELECT DISTINCT article.title, ts_rank_cd(title_tsv, q1) AS rank
FROM plainto_tsquery ('french restaurants') AS q1, article
JOIN article_status ON article.status_id = article_status.id
WHERE article_status.status = 'PUBLISHED' AND
title_tsv @@ q1
UNION
SELECT DISTINCT article.title, ts_rank_cd(name_tsv, q2) AS rank
FROM plainto_tsquery('french restaurants') AS q2, article
JOIN article_tags ON article.id = article_tags.article_id
JOIN article_status ON article.status_id = article_status.id
JOIN tag ON article_tags.tag_id = tag.id
WHERE article_status.status = 'PUBLISHED' AND
tag.name @@ q2
ORDER BY rank DESC, title;

So -- if anyone can offer any advice on this, I would very much
appreciate it!!!

Best,
Liam

--

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: Help with Custom Manager and UNION query?

2009-12-01 Thread Info Cascade
John,

Thanks for the response.
I don't think Q objects will work, since I need to do the fullsearch,
and I'm pretty sure that has to go in .extra().
Also, I think Django would create a query with the joins, which are much
slower than the UNION query.
Somebody must have encountered this situation before!

Liam


John M wrote:
> I'm not sure a Manager is what you want, what about Q(http://
> docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-
> q-objects) objects?  I've used them before and I think it's about what
> you'd need.  As for performance, not sure how they stack up
>
> On Nov 30, 2:45 pm, Info Cascade  wrote:
>   
>> Hi --
>>
>> I've been programming with Django about a year, and really like it, but
>> I've run into something that I can't quite solve on my own.
>> I think someone else may be able to offer the answer, or at least a hint
>> to send me in the right direction.
>>
>> I have two tables I want to search in simultaneously, Article and Tag.
>> They have a many-to-many relationship.
>> I want to get a QuerySet of Articles that match a query term on
>> article.title, as well as those that match on tag.name.
>> I can get what I want using SQL, but how do I do it in Django (with
>> acceptable performance)?
>> Ideally, I want to be able to add .filter() and .exclude() to the
>> QuerySet.  These SQL examples below are the basic idea, but in some
>> cases I'm adding .filter and .exclude.
>> Currently, the code looks something like this (I simplified it a bit,
>> but this should give an idea):
>>
>> 
>>> art_list = Article.objects.filter(status__status='PUBLISHED')
>>> art_list = art_list.extra(
>>> where=["title_tsv @@ plainto_tsquery(%s)"],
>>> params=[term])
>>>  if channel:
>>> art_list = art_list.filter(channel=channel)
>>>  art_list = art_list.distinct()
>>>  art_list = art_list.order_by(*order_by)
>>>   
>> Somehow, I want to include the fulltext search on the tag.name field,
>> where=['name_tsv @@ plainto_tsquery(%s)'],
>> params=[term])
>>
>> The two SQL example queries below both give the correct results.
>> However, the first one with joins takes over 20 seconds.
>> The second one with UNION is quite fast.
>>
>> I think what I need to do might be to create a custom manager for
>> Article that would execute the UNION query and return a QuerySet with
>> all the matching Articles.  I'm not sure quite how to do that,
>> especially if I expect it to work with the .filter() and .exclude()
>> methods.
>>
>> -- full-text search on article.title and tag.name
>> SELECT DISTINCT article.title  
>> FROM article JOIN article_tags ON article.id = article_tags.article_id
>> JOIN tag ON article_tags.tag_id = tag.id
>> JOIN article_status ON article_status.id = article.status_id
>> WHERE article_status.status = 'PUBLISHED'
>> AND (tag.name @@ plainto_tsquery('french restaurants')
>> OR title_tsv @@ plainto_tsquery('french restaurants'))
>> ORDER BY article.title;
>>
>> -- alternative full-text search on article.title and tag.name with UNION
>> --  with ranking
>> SELECT DISTINCT article.title, ts_rank_cd(title_tsv, q1) AS rank
>> FROM plainto_tsquery ('french restaurants') AS q1, article
>> JOIN article_status ON article.status_id = article_status.id
>> WHERE article_status.status = 'PUBLISHED' AND
>> title_tsv @@ q1
>> UNION
>> SELECT DISTINCT article.title, ts_rank_cd(name_tsv, q2) AS rank
>> FROM plainto_tsquery('french restaurants') AS q2, article
>> JOIN article_tags ON article.id = article_tags.article_id
>> JOIN article_status ON article.status_id = article_status.id
>> JOIN tag ON article_tags.tag_id = tag.id
>> WHERE article_status.status = 'PUBLISHED' AND
>> tag.name @@ q2
>> ORDER BY rank DESC, title;
>>
>> So -- if anyone can offer any advice on this, I would very much
>> appreciate it!!!
>>
>> Best,
>> Liam
>> 
>
> --
>
> 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.
>
>
>
>   

--

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.




Initial values and unbound forms

2009-12-03 Thread Info Cascade
Hi --

I am trying to set some reasonable defaults as initial field values in a
formset.  Here is what I'm doing

section_form_initial = {
'audio_publisher':default_publisher,
'audio_license':default_license,
'text_format':default_text_format
}

If I do this:
section_forms = SectionFormSet(initial=[section_form_initial])
Only the first form has the initial values.

If I do this:
section_forms =
SectionFormSet(initial=[section_form_initial]*extra_form_count)
The first  forms have initial values, but the formset creates an
additional  forms.

How can I set initial values for the correct number of forms?

Liam

--

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: Pydev + Django + Ubuntu 9.10

2009-12-05 Thread Info Cascade
Turkan,

Perhaps this will help. I just have done this
(PostGIS/Eclipse/Pydev/Django on Ubuntu 9.10) and it's working great! 
After having problems because I had installed Postgres 8.4, I found the
script below, on the net somewhere.
Modify, as appropriate, if you don't need GIS.

You may also want this, for full support in pgadmin3:
apt-get install postgresql-contrib-8.3
cd /usr/share/postgresql/8.3/contrib
psql -U  postgres < adminpack.sql

Getting Eclipse working took some time, and I learned a lot from this:
http://www.socialtext.net/hearplanet/index.cgi?action=display;is_incipient=1;page_name=http%3A%2F%2Fblog.vlku.com%2Findex.php%2F2009%2F06%2F10%2Fdjangoeclipse-with-code-complete-screencast%2F

Best,
Liam
> # Script for installing Django, PostgreSQL, and PostGIS
> # Run with sudo
>
> # Install Django:
> apt-get install python-django python-django-doc
>
> # Install PostgreSQL 8.3
> apt-get install postgresql-8.3 python-psycopg2 pgadmin3
>
> # Packages needed by GeoDjango (gdal is optional, but useful)
> apt-get install postgresql-8.3-postgis binutils libgdal1-1.5.0
> gdal-bin libgeos-3.1.0 proj libpq-dev
>
> # Set yourself up as a PostgreSQL superuser
> su - postgres
> createuser --createdb --superuser `whoami`
>
> # Create the template spatial database
> createdb -E UTF8 template_postgis
> createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
>
> # Allows non-superusers the ability to create from this template
> psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE
> datname='template_postgis';"
>
> # Load the PostGIS SQL routines
> psql -d template_postgis -f
> /usr/share/postgresql-8.3-postgis/lwpostgis.sql
> psql -d template_postgis -f
> /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
>
> # Enable users to alter spatial tables
> psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
> psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
> exit





turkan wrote:
> Hello.
>
> I know ... this topic was discussed quite often. But all the hints I
> found don't really help to setup Eclipse/Pydev under Ubuntu 9.10 for
> Django 1.1 (from the official Ubuntu repositories).
> I tried to follow this tutorial (http://solyaris.wordpress.com/
> 2007/05/16/how-to-djangopydev-on-feisty/), but /usr/share/python-
> support/python-django/ is not present anymore under Ubuntu 9.10.
> So I tried to add /usr/shared/pyshared/django, usr/share/python-
> support/, /usr/lib/python/django to the PYTHONPATH, but without any
> success. My projects still come up with many "undefined variable"
> errors. For example an error is presented for User.add_to_class.
> add_to_class (add_to_class is unkown), even if User seems to be known.
> I read that it is difficult for the IDE to recognize all variables,
> cause of the way some of those are generated on the fly (I am also new
> to Python). But is it possible to get error free projects with Django
> + Pydev?
> Why does Aptana for example does provide such a good Ruby support?
> Does Python/Django provide more dynamic stuff than Ruby?
>
> Regards,
> Kai
>
> --
>
> 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.
>
>
>
>   

--

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: Pydev + Django + Ubuntu 9.10

2009-12-07 Thread Info Cascade
Hi, Turkan,

Sorry -- the link is: here.  
<http://www.socialtext.net/hearplanet/index.cgi?action=display;is_incipient=1;page_name=http%3A%2F%2Fblog.vlku.com%2Findex.php%2F2009%2F06%2F10%2Fdjangoeclipse-with-code-complete-screencast%2F>Hope
that helps.
I had to use Postgres 8.3 instead of 8.4, but that may not be an issue
if you're not using PostGIS.

Liam



turkan wrote:
> Hello Liam,
>
> I am sorry ... I can't access your provided link. Even after
> registering there, it says "You are not authorized to view this
> workspace.".
> I am also not sure why you suggest me Posgresql/PostGIS. I don't have
> any problems with setting up the database, just with setting up Pydev/
> Eclipse correctly.
> Any further suggestions?
>
> Regards,
> Kai
>
>
> On Dec 6, 12:08 am, Info Cascade  wrote:
>   
>> Turkan,
>>
>> Perhaps this will help. I just have done this
>> (PostGIS/Eclipse/Pydev/Django on Ubuntu 9.10) and it's working great!
>> After having problems because I had installed Postgres 8.4, I found the
>> script below, on the net somewhere.
>> Modify, as appropriate, if you don't need GIS.
>>
>> You may also want this, for full support in pgadmin3:
>> apt-get install postgresql-contrib-8.3
>> cd /usr/share/postgresql/8.3/contrib
>> psql -U  postgres < adminpack.sql
>>
>> Getting Eclipse working took some time, and I learned a lot from 
>> this:http://www.socialtext.net/hearplanet/index.cgi?action=display;is_inci...
>>
>> Best,
>> Liam
>>
>> 
>>> # Script for installing Django, PostgreSQL, and PostGIS
>>> # Run with sudo
>>>   
>>> # Install Django:
>>> apt-get install python-django python-django-doc
>>>   
>>> # Install PostgreSQL 8.3
>>> apt-get install postgresql-8.3 python-psycopg2 pgadmin3
>>>   
>>> # Packages needed by GeoDjango (gdal is optional, but useful)
>>> apt-get install postgresql-8.3-postgis binutils libgdal1-1.5.0
>>> gdal-bin libgeos-3.1.0 proj libpq-dev
>>>   
>>> # Set yourself up as a PostgreSQL superuser
>>> su - postgres
>>> createuser --createdb --superuser `whoami`
>>>   
>>> # Create the template spatial database
>>> createdb -E UTF8 template_postgis
>>> createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
>>>   
>>> # Allows non-superusers the ability to create from this template
>>> psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE
>>> datname='template_postgis';"
>>>   
>>> # Load the PostGIS SQL routines
>>> psql -d template_postgis -f
>>> /usr/share/postgresql-8.3-postgis/lwpostgis.sql
>>> psql -d template_postgis -f
>>> /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
>>>   
>>> # Enable users to alter spatial tables
>>> psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
>>> psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
>>> exit
>>>   
>> turkan wrote:
>> 
>>> Hello.
>>>   
>>> I know ... this topic was discussed quite often. But all the hints I
>>> found don't really help to setup Eclipse/Pydev under Ubuntu 9.10 for
>>> Django 1.1 (from the official Ubuntu repositories).
>>> I tried to follow this tutorial (http://solyaris.wordpress.com/
>>> 2007/05/16/how-to-djangopydev-on-feisty/), but /usr/share/python-
>>> support/python-django/ is not present anymore under Ubuntu 9.10.
>>> So I tried to add /usr/shared/pyshared/django, usr/share/python-
>>> support/, /usr/lib/python/django to the PYTHONPATH, but without any
>>> success. My projects still come up with many "undefined variable"
>>> errors. For example an error is presented for User.add_to_class.
>>> add_to_class (add_to_class is unkown), even if User seems to be known.
>>> I read that it is difficult for the IDE to recognize all variables,
>>> cause of the way some of those are generated on the fly (I am also new
>>> to Python). But is it possible to get error free projects with Django
>>> + Pydev?
>>> Why does Aptana for example does provide such a good Ruby support?
>>> Does Python/Django provide more dynamic stuff than Ruby?
>>>   
>>> Regards,
>>> Kai
>>>   
>>> --
>>>   
>>> You received this message because you are subscribed to the

Re: Initial values and unbound forms (apparently a bug?)

2009-12-08 Thread Info Cascade
Hi, Manu,

Thanks for writing.  I tried what you suggested, and the forms were
displayed exactly as I wanted.
However, when I tried to submit the form, it triggered validation errors
for all the fields that were
left blank.
So, the behavior is not quite what I want.
I'm guessing that setting the initial values in that way is triggering
something that marks the form as having been modified.
So, back to the drawing board!

Any ideas, anyone?

Liam


Manu wrote:
> Hello,
>
> I would say that the behavior you have is normal. Quoting the doc
> 
> "Using initial data with a formset:
> Initial data is what drives the main usability of a formset. As shown
> above you can define the number of extra forms. What this means is
> that you are telling the formset how many additional forms to show
> **in addition** to the number of forms it generates from the initial
> data."
> 
>
> What I understood from the doc is that initial values are used for
> existing objects or ones being built. Ie, if you provided 6 forms with
> default values in a formset, you will end up with 6 new objects
> created/modified. It's up to you then to really create/modfiy those
> objects.
>
> Consequently a solution for you would be to set extra=0 and set up you
> inital datas as you have done but not create objects if default
> values have not been changed (for instance).
>
> Manu
>
> --
>
> 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.
>
>
>
>   

--

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: Apache Environment Variables

2009-12-17 Thread Info Cascade
Dan,

This works for me -- using mod_python.

VirtualHost defininition:
> SetEnv VIRTUAL_HOST_NAME dev.hostname.com
> SetEnv DATABASE_NAME dbname
settings.py:
> VIRTUAL_HOST_NAME = os.environ.get('VIRTUAL_HOST_NAME')
> DATABASE_NAME = os.environ.get('DATABASE_NAME')
Liam

Dashdrum wrote:
> I'm using mod_wsgi to host my Django site, and all is working well,
> except...
>
> I'd like to access an environment variable set in the Apache
> configuration like so:
>
> SetEnv TIER dev
>
> The os.environ.get() function seems appropriate for this, but no
> luck.  Using this code:
>
>
> PATH = os.environ.get('PATH','')
> DJANGO_SETTINGS_MODULE = os.environ.get
> ('DJANGO_SETTINGS_MODULE','')
> SERVER_NAME = os.environ.get('SERVER_NAME','')
> TIER = os.environ.get('TIER','')
>
> PATH comes from the operating system (Red Hat) and the proper value is
> returned.  Likewise, DJANGO_SETTINGS_MODULE returns the correct string
> after it is set in django.wsgi.
>
> However, both SERVER_NAME and the custom variable TIER are not
> returned.
>
> Any advice would be most appreciated.
>
> Dan Gentry
>
> --
>
> 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.
>
>
>
>   

--

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.




Help! Need to do full-text query on multiple tables

2010-01-13 Thread Info Cascade
Hi,

Need some help,here!  I posted this a while ago and didn't get any response 
that was helpful.
I still need to resolve it, and someone who understands the problem surely can 
point me in
the right direction.  Do I need a custom manager for a sql UNION query, and if 
so, what is
the best example for me to emulate?

There are two tables we want to full-text search in simultaneously, Article and
Tag. (Table definitions at end of message.)
They have a many-to-many relationship, via the article_tags table.
We want to end up with a QuerySet of Articles that match a query term on
article.title, as well as those that match the same term on tag.name.
(I was thinking this would be a quick way to get full-text search of the
two tables, using Postgres.  However, if it is going to be too much
work, it might be better to put the effort into implementing some other
full-text engine, like Sphinx!)

So, my question is two-fold:
1. How do I get acceptable SQL performance for the query, and
2. How do I create the query in Django

Ideally, I want to be able to add .filter() and .exclude() and
.order_by() to the QuerySet.  These SQL examples below are the basic
idea. Currently, the code looks something like this (I simplified it a
bit, but this should give an idea):
> >
> > art_list = Article.objects.filter(status__status='PUBLISHED')
> > art_list = art_list.extra(
> > where=["title_tsv @@ plainto_tsquery(%s)"],
> > params=[term])
> >  if channel:
> > art_list = art_list.filter(channel=channel)
> >  art_list = art_list.order_by(*order_by)
Somehow, I want to include the fulltext search on the tag.name field,
which would look something like:
where=['name_tsv @@ plainto_tsquery(%s)'],
params=[term])

(Actually, I'm not sure how to do this in Django, in any case, because
of having to use .extra() to do the full-text search on the tag table.
Can I add them to the .extra() WHERE clause?)
So, that's question #2.

I can formulate the query directly in SQL, without using Django.
The SQL example queries below give the correct results.
However, the first one with joins takes over 7 seconds.
The ones with UNION are quite fast.
I also played with doing a subquery, and that is fast, but causes other
issues.
If I could get the first (slow) version to not be so slow, then that would
probably solve my problem, thus that is question #1.  Why so slow?

I think what I need to do might be to create a custom manager for
Article that would execute the UNION query and return a QuerySet with
all the matching Articles.  I'm not sure quite how to do that,
especially if I expect it to work with the .filter() and .exclude()
and .order_by() methods.


-- Full-text search on article.title and tag.name, with join on status
-- 7475ms!
SELECT DISTINCT article.title
FROM article JOIN article_tags ON article.id = article_tags.article_id
JOIN tag ON article_tags.tag_id = tag.id
JOIN article_status ON article_status.id = article.status_id
WHERE article_status.status = 'PUBLISHED'
AND (tag.name @@ plainto_tsquery('french restaurants')
OR title_tsv @@ plainto_tsquery('french restaurants'))
ORDER BY article.title;

-- For comparison, using standard string comparison instead of full-text
-- is substantially faster, and happens to give correct results,
-- although clearly this is not what we want to do.
-- 1569ms
SELECT DISTINCT article.title
FROM article JOIN article_tags ON article.id = article_tags.article_id
JOIN tag ON article_tags.tag_id = tag.id
WHERE (name ilike '%french restaurant%'
OR title ilike '%french%restaurant%')
ORDER BY article.title;

-- Individual full-text searches are quite fast
-- 12ms
SELECT DISTINCT article.title
FROM article
WHERE (title_tsv @@ plainto_tsquery('french restaurants'))
ORDER BY article.title;

-- Individual full-text searches are quite fast
--10ms
SELECT tag.name
FROM tag
WHERE (name_tsv @@ plainto_tsquery('french restaurants'))
ORDER BY tag.name;

-- Alternative full-text search on article.title and tag.name with UNION
-- with ranking.  This returns correct results with acceptable
-- performance, but would be more complicated on the Django side.
-- 640ms
SELECT DISTINCT article.title, ts_rank_cd(title_tsv, q1) AS rank
FROM plainto_tsquery ('french restaurants') AS q1, article
JOIN article_status ON article.status_id = article_status.id
WHERE article_status.status = 'PUBLISHED' AND
title_tsv @@ q1
UNION
SELECT DISTINCT article.title, ts_rank_cd(name_tsv, q2) AS rank
FROM plainto_tsquery('french restaurants') AS q2, article
JOIN article_tags ON article.id = article_tags.article_id
JOIN article_status ON article.status_id = article_status.id
JOIN tag ON article_tags.tag_id = tag.id
WHERE article_status.status = 'PUBLISHED' AND
tag.name @@ q2
ORDER BY rank DESC, title;


So -- if anyone can offer any advice on this, I would very much
appreciate it

Problem with dumpdata and loaddata in python format

2010-08-11 Thread Info Cascade

Hi --

I'm expecting
python manage.py dumpdata --format=python
... to dump data, but it does not.
I get "Error: Unknown serialization format: python" instead.
Specifying json or xml does work, however.

Same for loaddata.
"Problem installing fixture 'fixtures/bme_auth': python is not a known 
serialization format."


I thought this was a supported format?

What am I missing?

Liam

--
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.



M2M Manager -- how to get primary key of join table?

2010-04-22 Thread Info Cascade
Hi --

I have two models with a m2m relationship, and I need to get the value
of the primary key of the join table.

To use the example from the book:

> from django.db import models
>
> class Publication(models.Model):
> title = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.title
>
> class Meta:
> ordering = ('title',)
>
> class Article(models.Model):
> headline = models.CharField(max_length=100)
> publications = models.ManyToManyField(Publication)
>
> def __unicode__(self):
> return self.headline
>
> class Meta:
> ordering = ('headline',) 
Django creates the article_publications join table automatically.

What I need is, for a particular combination of article and publication,
what is the primary key in the join table?

Any thoughts?

Please Cc: me at liamk -- AT -- numenet --DOT--com if you can help!

Thanks,
Liam



-- 
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.



Geospatial queries using F() object... Is this even possible?

2011-08-25 Thread Info Cascade

Hi --

I'm trying to figure out how to do a geospatial query that references a 
model field in the filter.

class Article(geomodels.Model):
point = PointField(...)
radius = IntegerField(...)

query_point = Point (...)

Articles.objects.filter(point__distance_lt=(query_point, F('radius')))

I tried using the F() object, but, not surprisingly, it did not work.
Has anyone figured out how to do this?
Perhaps there's some workaround using extra()?

Liam

Someone else had this question, elsewhere, but it went unanswered...

I have a model (let's call it A) that has a point field  and a radius
field:

class A(geomodels.Model):
point = geomodels.PointField(srid=)
radius = models.PositiveIntegerField()

How do I make a query that yields all A objects for which a given
point's distance from the object's point is within the object's
radius?

My first thought was to use the F() method to reference the radius
field on the A model:

query_point = 
a_qs = A.objects.filter(point__distance_lte=(query_point,
D(mi=F('radius')))

This, of course, does not work.

Any suggestions?



--
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.