Re: what to do instead of adding to Query.extra_where ?

2010-09-01 Thread Paul Winkler
Hah. That was a pretty long message relative to how quickly I found
the answer myself :-p
Sorry for the noise.

For posterity, extra(where=...) is indeed the solution. I overlooked
the obvious:
the class I was trying to fix is itself a subclass of QuerySet.  So
given this line:

clone.query.extra_where += ('db_newsitem.id =
db_attribute.news_item_id',)

the replacement is now:

clone = clone.extra(where=('db_newsitem.id =
db_attribute.news_item_id',))

Seems to work fine.

On Sep 1, 11:41 pm, Paul Winkler  wrote:
> Hi folks,
>
> I'm working on a codebase (a fork ofhttp://code.google.com/p/ebcode/)
> that is supposed to be run against Django 1.1. It has several lines
> like this:
>
>     clone.query.extra_where += ('db_newsitem.id =
> db_attribute.news_item_id',)
>
> That line raises a traceback like this:
>
> Traceback (most recent call last):
>   File "./everyblock/everyblock/cities/boston/building_permits/
> retrieval.py", line 90, in 
>     PermitScraper().update()
>   File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
> retrieval/scrapers/newsitem_list_detail.py", line 208, in update
>     super(NewsItemListDetailScraper, self).update()
>   File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
> retrieval/scrapers/list_detail.py", line 112, in update
>     self.update_from_string(page)
>   File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
> retrieval/scrapers/list_detail.py", line 140, in update_from_string
>     old_record = self.existing_record(list_record)
>   File "./everyblock/everyblock/cities/boston/building_permits/
> retrieval.py", line 65, in existing_record
>     qs = qs.by_attribute(self.schema_fields['raw_address'],
> record['address'])
>   File "/home/pw/builds/openblock/builds/20100824/ebpub/ebpub/db/
> models.py", line 317, in by_attribute
>     clone = self.prepare_attribute_qs()
>   File "/home/pw/builds/openblock/builds/20100824/ebpub/ebpub/db/
> models.py", line 300, in prepare_attribute_qs
>     clone.query.extra_where += ('db_newsitem.id =
> db_attribute.news_item_id',)
> AttributeError: 'GeoQuery' object has no attribute 'extra_where'
>
> For more context, the relevant models.py code is 
> athttp://github.com/openplans/openblock/blob/master/ebpub/ebpub/db/mode...
> and `clone.query` is an instance of
> django.contrib.gis.db.models.sql.query.GeoQuery, which inherits from
> the usual BaseQuery.
>
> Now, I've found by googling and downloading old releases that
> django.db.models.sql.query.BaseQuery had an extra_where attribute as
> of Django 1.0, but it's gone in Django 1.1.
> And from looking at recent and old versions of the docs, I don't think
> that extra_where was ever really part of the API; you're probably not
> supposed to twiddle it directly.
>
> I haven't yet found a documented way to solve 
> this.http://docs.djangoproject.com/en/dev/ref/models/querysets/talks about
> the .extra(where=...) method,
> but that's part of the manager API and the QuerySet API, not the Query
> API.
>
> The one thing I've found, by poking around in the django source, is to
> call clone.query.where.add(ExtraWhere(...)) but it's not clear to me
> whether that's really part of the API either. Is there a better /
> "correct" way?
>
> Thanks,

-- 
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: fetching values from model

2010-09-01 Thread commonzenpython
no :)

-- 
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: fetching values from model

2010-09-01 Thread Pradnya
Hey thanks,
Is there anyway I can call a function in HTML template?


On Sep 1, 6:23 pm, Steve Holden  wrote:
> On 9/1/2010 9:13 AM, Pradnya wrote:>> ok. Is there any way I can load the 
> model inside HTML template?
> >> What is {% load  %} tag all about?
>
> The {% load %} tag is for loading custom tags. Nothing to do with
> accessing the database.
>
> Why do you find it desirable to load records in the template?  What's
> wrong with doing it in the view, which is what everyone else does and
> how Django is intended to be used? See Jonas' remarks below.
>
> regards
>  Steve
>
> >> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
>  You don't write Python code inside your template file. That's
>  one of the basic django template rules. You can pass values
>  from your views to your template and show them there. Or
>  generate the HTML in your view and show it from there, which
>  isn't something I could advise if you're creating a larger
>  application.
>
>  Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> >> Hello,
>
> >> Is it possible to fetch a particular record from model
> >> using school.object.get(id = 1) inside html template.
>
> >> Please suggest.
>
> >> Thanks Pradnya
>
> >> -- 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.
>
>  Met vriendelijke groeten,
>
>  Jonas Geiregat jo...@geiregat.org

-- 
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: mod_wsgi, apache, windows XP

2010-09-01 Thread Graham Dumpleton


On Sep 2, 1:13 pm, Jesse  wrote:
> I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
> supposedly works.  I changed the name of the file to mod_wsgi and
> placed into Apache modules library.  I changed the folders, so the
> apache folder by itself and created the following in the apache
> http.conf file:
> WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"
>
> 
> Order allow,deny
> Allow from all
> 
>
> The myapp.wsgi is:
> def application(environ, start_response):
>     status = '200 OK'
>     output = 'Hello World!'
>
>     response_headers = [('Content-type', 'text/plain'),
>                         ('Content-Length', str(len(output)))]
>     start_response(status, response_headers)
>
>     return [output]
>
> Apache starts fine, no errors, but the localhost is still the original
> apache page and not hello world.

What URL are you using? Sounds like you are using:

  http://localhost

and not:

  http://localhost/myapp

Your WSGIScriptAlias has it mounted at sub URL not root of site which
is where standard Apache 'It Works' page would be found.

Graham

>
> On Sep 1, 4:25 pm, Graham Dumpleton 
> wrote:
>
>
>
> > On Sep 2, 4:46 am, Jesse  wrote:
>
> > > created project using startproject testproject
>
> > > Problems with apache_django_wsgi.conf
> > > 1.  Added following line toApache:
> > > LoadModule wsgi_module modules/mod_wsgi.so
>
> > > 2. Created folder c:/django/testproject/apache
>
> > > 3.  Created file c:/django/testproject/apache/django.wsgi
> > > // code starts
> > > import os, sys
> > > sys.path.append("/c:/django")
>
> > All your paths where you have '/c:' instead of just 'c:' are wrong to
> > start with.
>
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > > import django.core.handlers.wsgi
>
> > > application = django.core.handlers.wsgi.WSGIHandler()
> > > // code ends
>
> > > 4.  Apachestarts and restarts. local host is originalapache"It
> > > works"
>
> > > 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> > > //code starts
> > > Alias /media/ /c:/django/testproject/media/
>
> > > 
> > > Order deny,allow
> > > Allow from all
> > > 
>
> > > WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> > > 
> > > Order deny,allow
> > > Allow from all
> > > 
> > > //code ends
>
> > > 6.  Added following line toApachehttp.conf
> > > Include "c:/django/testproject/apache/apache_django_wsgi.conf"
>
> > > 7.  Apacheerror, cannot restart.
>
> > > Any help is much appreciated.
>
> > Does theApacheerror log have anything in it?
>
> > WhichApacheversion? Which Python version? Which mod_wsgi object did
> > you grab, or did you compile from source code?
>
> > Are you trying to run 64bitWindows?
>
> > BTW, recommended to test first with a WSGI hello world program and not
> > Django.
>
> > See hello world example in:
>
> >  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> > Graham

-- 
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: fetching values from model

2010-09-01 Thread Pradnya
Hey thanks,
Is there anyway I can call a function in HTML template?


On Sep 1, 6:23 pm, Steve Holden  wrote:
> On 9/1/2010 9:13 AM, Pradnya wrote:>> ok. Is there any way I can load the 
> model inside HTML template?
> >> What is {% load  %} tag all about?
>
> The {% load %} tag is for loading custom tags. Nothing to do with
> accessing the database.
>
> Why do you find it desirable to load records in the template?  What's
> wrong with doing it in the view, which is what everyone else does and
> how Django is intended to be used? See Jonas' remarks below.
>
> regards
>  Steve
>
> >> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
>  You don't write Python code inside your template file. That's
>  one of the basic django template rules. You can pass values
>  from your views to your template and show them there. Or
>  generate the HTML in your view and show it from there, which
>  isn't something I could advise if you're creating a larger
>  application.
>
>  Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> >> Hello,
>
> >> Is it possible to fetch a particular record from model
> >> using school.object.get(id = 1) inside html template.
>
> >> Please suggest.
>
> >> Thanks Pradnya
>
> >> -- 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.
>
>  Met vriendelijke groeten,
>
>  Jonas Geiregat jo...@geiregat.org

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



what to do instead of adding to Query.extra_where ?

2010-09-01 Thread Paul Winkler
Hi folks,

I'm working on a codebase (a fork of http://code.google.com/p/ebcode/)
that is supposed to be run against Django 1.1. It has several lines
like this:

clone.query.extra_where += ('db_newsitem.id =
db_attribute.news_item_id',)

That line raises a traceback like this:

Traceback (most recent call last):
  File "./everyblock/everyblock/cities/boston/building_permits/
retrieval.py", line 90, in 
PermitScraper().update()
  File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
retrieval/scrapers/newsitem_list_detail.py", line 208, in update
super(NewsItemListDetailScraper, self).update()
  File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
retrieval/scrapers/list_detail.py", line 112, in update
self.update_from_string(page)
  File "/home/pw/builds/openblock/builds/20100824/ebdata/ebdata/
retrieval/scrapers/list_detail.py", line 140, in update_from_string
old_record = self.existing_record(list_record)
  File "./everyblock/everyblock/cities/boston/building_permits/
retrieval.py", line 65, in existing_record
qs = qs.by_attribute(self.schema_fields['raw_address'],
record['address'])
  File "/home/pw/builds/openblock/builds/20100824/ebpub/ebpub/db/
models.py", line 317, in by_attribute
clone = self.prepare_attribute_qs()
  File "/home/pw/builds/openblock/builds/20100824/ebpub/ebpub/db/
models.py", line 300, in prepare_attribute_qs
clone.query.extra_where += ('db_newsitem.id =
db_attribute.news_item_id',)
AttributeError: 'GeoQuery' object has no attribute 'extra_where'


For more context, the relevant models.py code is at
http://github.com/openplans/openblock/blob/master/ebpub/ebpub/db/models.py
and `clone.query` is an instance of
django.contrib.gis.db.models.sql.query.GeoQuery, which inherits from
the usual BaseQuery.

Now, I've found by googling and downloading old releases that
django.db.models.sql.query.BaseQuery had an extra_where attribute as
of Django 1.0, but it's gone in Django 1.1.
And from looking at recent and old versions of the docs, I don't think
that extra_where was ever really part of the API; you're probably not
supposed to twiddle it directly.

I haven't yet found a documented way to solve this.
http://docs.djangoproject.com/en/dev/ref/models/querysets/ talks about
the .extra(where=...) method,
but that's part of the manager API and the QuerySet API, not the Query
API.

The one thing I've found, by poking around in the django source, is to
call clone.query.where.add(ExtraWhere(...)) but it's not clear to me
whether that's really part of the API either. Is there a better /
"correct" way?

Thanks,

-- 
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: mod_wsgi, apache, windows XP

2010-09-01 Thread Jesse
I'm using Python 2.7, Apache 2.2 and grabbed the mod_wsgi that
supposedly works.  I changed the name of the file to mod_wsgi and
placed into Apache modules library.  I changed the folders, so the
apache folder by itself and created the following in the apache
http.conf file:
WSGIScriptAlias /myapp "c:/public/apache/myapp.wsgi"


Order allow,deny
Allow from all


The myapp.wsgi is:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)

return [output]

Apache starts fine, no errors, but the localhost is still the original
apache page and not hello world.
Jesse

On Sep 1, 4:25 pm, Graham Dumpleton 
wrote:
> On Sep 2, 4:46 am, Jesse  wrote:
>
> > created project using startproject testproject
>
> > Problems with apache_django_wsgi.conf
> > 1.  Added following line toApache:
> > LoadModule wsgi_module modules/mod_wsgi.so
>
> > 2. Created folder c:/django/testproject/apache
>
> > 3.  Created file c:/django/testproject/apache/django.wsgi
> > // code starts
> > import os, sys
> > sys.path.append("/c:/django")
>
> All your paths where you have '/c:' instead of just 'c:' are wrong to
> start with.
>
>
>
>
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > import django.core.handlers.wsgi
>
> > application = django.core.handlers.wsgi.WSGIHandler()
> > // code ends
>
> > 4.  Apachestarts and restarts. local host is originalapache"It
> > works"
>
> > 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> > //code starts
> > Alias /media/ /c:/django/testproject/media/
>
> > 
> > Order deny,allow
> > Allow from all
> > 
>
> > WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> > 
> > Order deny,allow
> > Allow from all
> > 
> > //code ends
>
> > 6.  Added following line toApachehttp.conf
> > Include "c:/django/testproject/apache/apache_django_wsgi.conf"
>
> > 7.  Apacheerror, cannot restart.
>
> > Any help is much appreciated.
>
> Does theApacheerror log have anything in it?
>
> WhichApacheversion? Which Python version? Which mod_wsgi object did
> you grab, or did you compile from source code?
>
> Are you trying to run 64bitWindows?
>
> BTW, recommended to test first with a WSGI hello world program and not
> Django.
>
> See hello world example in:
>
>  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> Graham

-- 
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 to add a non-field text property to forms in a formset

2010-09-01 Thread bobhaugen
On Sep 1, 12:17 pm, Bill Freeman  wrote:
> This seems to me to be a job for the template.  The forms documentation has
> a section on custom rendering which shows you how to iterate through the
> fields, or access them by name.  You would insert whatever HTML construct
> was appropriate for your text, providing a context variable giving its 
> contents,
> if necessary.

I guess I do not understand your reply.

I'm already iterating through the fields in the template, accessing
them by name.  Actually, many forms' worth of fields, in a many-rowed
table.  How would I display the product description for each row as
flexibly-wrapped text, rather than as a field widget?  That is what I
am trying to do.

Sorry if I am missing something that should have been obvious to me
from "whatever HTML construct".  Could you provide an example (or even
another hint), that works with a formset?

-- 
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 oracle database queries in one request problem

2010-09-01 Thread Steve Holden
On 9/1/2010 5:54 PM, Reinout van Rees wrote:
> On 09/01/2010 02:00 PM, Reinout van Rees wrote:
>> Hi,
>>
>> I'm deploying a site on windows with oracle (and I don't know either of
>> them well). Simple apache+wsgi setup for now.
> 
> I'll have to test it out tomorrow when I'm near the windows machine
> again, but I might have found the solution in an existing bug report:
> http://code.djangoproject.com/ticket/13351
> 
> In a threaded situation (which you always have with mod_wsgi on
> windows), you apparently need to pass the cx_oracle database driver a
> threaded=True option (which is off by default).
> 
> So I added the following to my database config and I'm hoping I'll be
> happy tomorrow morning...
> 
> 'OPTIONS': {'threaded': True}
> 
> 
> I'll update the ticket when it helps.
> 
Good work!

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: Can't login to admin site

2010-09-01 Thread Karen Tracey
On Wed, Sep 1, 2010 at 1:23 PM, vgarvardt  wrote:

> Django 1.2.1
>
> Created new project, set DB settings (postgresql_psycopg2),
> MEDIA_ROOT, MEDIA_URL, TEMPLATE_DIRS, added django.contrib.admin to
> INSTALLED_APPS.
>
> In urls.py uncommented:
> from django.contrib import admin
> admin.autodiscover()
>
> and
>
> (r'^admin/', include(admin.site.urls)),
>
> Run manage.py syncdb - tables and superuser were successfully created.
> Run manage.py runserver, opened http://127.0.0.1:8000/admin/ in
> browser - got admin site login page, entered superuser login/pwd,
> pressed Login button and got django debug error page:
>
> TypeError at /admin/
>
> add() takes at most 6 arguments (7 given)
>
> Request Method: POST
> Request URL:http://127.0.0.1:8000/admin/
> Exception Type: TypeError
> Exception Value:
>
> add() takes at most 6 arguments (7 given)
>
> Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/
> models/base.py in _collect_sub_objects, line 558
> Python Executable:  /usr/bin/python
> Python Version: 2.6.5
> etc.
>
> What am I doing wrong?
>
>
The full traceback would help diagnose. Is there any possibility your
installation of Django is corrupt -- like from a partially-applied install
of 1.2.1 over 1.1? That's rather what it looks like.

Karen
-- 
http://tracey.org/kmt/

-- 
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: Discrepancy between model formset and the queryset it's based on

2010-09-01 Thread Alec Shaner
Perhaps see:

http://docs.djangoproject.com/en/1.2/topics/forms/formsets/

where it talks about the "extra" keyword that controls how many blank forms
to add, the default is 1


On Wed, Sep 1, 2010 at 5:31 PM, ses1984  wrote:

> Basically I have a queryset with N items in it, which I use to create
> a model formset, which then has N+1 items in it. I'm not sure why this
> is happening.
>
> Here is a summary of the problem. Please forgive my crude methods for
> gathering information (if anyone has feedback on that topic, I would
> like to hear it)
>
> http://dpaste.com/hold/237587/
>
> --
> 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: mod_wsgi, apache, windows XP

2010-09-01 Thread Graham Dumpleton


On Sep 2, 4:46 am, Jesse  wrote:
> created project using startproject testproject
>
> Problems with apache_django_wsgi.conf
> 1.  Added following line to Apache:
> LoadModule wsgi_module modules/mod_wsgi.so
>
> 2. Created folder c:/django/testproject/apache
>
> 3.  Created file c:/django/testproject/apache/django.wsgi
> // code starts
> import os, sys
> sys.path.append("/c:/django")

All your paths where you have '/c:' instead of just 'c:' are wrong to
start with.

> os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
> // code ends
>
> 4.  Apache starts and restarts. local host is original apache "It
> works"
>
> 5.  Created file c:/django/testproject/apache_django_wsgi.conf
> //code starts
> Alias /media/ /c:/django/testproject/media/
>
> 
> Order deny,allow
> Allow from all
> 
>
> WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi
>
> 
> Order deny,allow
> Allow from all
> 
> //code ends
>
> 6.  Added following line to Apache http.conf
> Include "c:/django/testproject/apache/apache_django_wsgi.conf"
>
> 7.  Apache error, cannot restart.
>
> Any help is much appreciated.

Does the Apache error log have anything in it?

Which Apache version? Which Python version? Which mod_wsgi object did
you grab, or did you compile from source code?

Are you trying to run 64bit Windows?

BTW, recommended to test first with a WSGI hello world program and not
Django.

See hello world example in:

  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Graham

-- 
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 oracle database queries in one request problem

2010-09-01 Thread Reinout van Rees

On 09/01/2010 02:00 PM, Reinout van Rees wrote:

Hi,

I'm deploying a site on windows with oracle (and I don't know either of
them well). Simple apache+wsgi setup for now.


I'll have to test it out tomorrow when I'm near the windows machine 
again, but I might have found the solution in an existing bug report: 
http://code.djangoproject.com/ticket/13351


In a threaded situation (which you always have with mod_wsgi on 
windows), you apparently need to pass the cx_oracle database driver a 
threaded=True option (which is off by default).


So I added the following to my database config and I'm hoping I'll be 
happy tomorrow morning...


'OPTIONS': {'threaded': True}


I'll update the ticket when it helps.


Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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: Surreptitious caching of JS in Django

2010-09-01 Thread buddhasystem

I really didn't configure any caching of JS myself, with the exception that
it gets served statically. Disabling cache altogether is not an attractive
option as my testing goes against expensive queries.



Reinout van Rees wrote:
> 
> On 08/30/2010 07:52 PM, buddhasystem wrote:
>>
>> Hello,
>> with the generous help of many of you, I easily set up JSON caching
>> feature
>> in my Django app, in a few views.
>>
>> The problem I'm now facing is that according to what I observe, Django
>> also
>> caches Javascript code in its memcached backend.
> 
> That's probably something you configured yourself.
> 
> Anyway, in development you can uncomment any CACHE_BACKEND in your 
> settings.py and no caching will happen.
> 
> 
> Reinout
> 
> 
> -- 
> Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
> Collega's gezocht!
> Django/python vacature in Utrecht: http://tinyurl.com/35v34f9
> 
> -- 
> 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.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Surreptitious-caching-of-JS-in-Django-tp29575393p29594246.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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: fetching values from model

2010-09-01 Thread Justin Myers
The only way to access a model from within a template is if the view
specifically passed it via the template's context. Even then, you
wouldn't be able to do much passing the model _class_ this way; you
should be passing specific model _instances_. As the design
philosophies doc says, "We see a template system as a tool that
controls presentation and presentation-related logic – and that’s it."
http://docs.djangoproject.com/en/dev/misc/design-philosophies/#template-system

{% load %} is completely unrelated. It's used to load custom template
tags and filters: 
http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/

-Justin

On Sep 1, 8:12 am, Pradnya  wrote:
> ok. Is there anyway I can load model inside HTML template? or
> basically what is {% load  %} is used for ?
>
> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
>
> > You don't write Python code inside your template file. That's one of the 
> > basic django template rules.
> > You can pass values from your views to your template and show them there.
> > Or generate the HTML in your view and show it from there, which isn't 
> > something I could advise if you're creating a larger application.
>
> > Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> > > Hello,
>
> > > Is it possible to fetch a particular record from model using
> > > school.object.get(id = 1) inside html template.
>
> > > Please suggest.
>
> > > Thanks
> > > Pradnya
>
> > > --
> > > 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.
>
> > Met vriendelijke groeten,
>
> > Jonas Geiregat
> > jo...@geiregat.org

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



Discrepancy between model formset and the queryset it's based on

2010-09-01 Thread ses1984
Basically I have a queryset with N items in it, which I use to create
a model formset, which then has N+1 items in it. I'm not sure why this
is happening.

Here is a summary of the problem. Please forgive my crude methods for
gathering information (if anyone has feedback on that topic, I would
like to hear it)

http://dpaste.com/hold/237587/

-- 
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: PIL on 10.6 = PAIN

2010-09-01 Thread keynesiandreamer
Well last night I started working on removing all traces of PIL and
libjpeg as well as the install instructions from Andrews link (Thansk
Andrew!)

If there was a problem to encounter I seemed to hit it... :-(

It all started when Git would not unzip, I finally got that with the
xjvf flag I believe, and then now I get an error due to a dylib not
being linked to x86_64 architecture. JESUS!

I spent time trying to research that without much luck :(

I upgraded the default mac installation python to python 2.6.6 and
also am using virtualenv for my django envs and am having issues
installing virtualenvwrapper, yet another install problem... Looks
like something with the the source file and the virtualenv_bashrc
file.

Atleast in the morning my patience is a bit better... I will try
hammering away at it again tomororw. I think I need a day off from it.

Thanks everybody for all their insight and advice, it is very much
appreciated. If you are anywhere near SF, there is beer on me for it.

-Ben


On Sep 1, 4:09 am, Mathieu Leduc-Hamel  wrote:
> This is because you should not use the Python interpreter from you're
> Mac installation. Are you using buildout ? VirtualEnv? or nothing ?
>
> Buildout:
>
> /opt/local/bin/python2.6 bootstrap.py
>
> Virtualenv:
>
> virtualenv -p /opt/local/bin/python2.6 
>
> Nothing:
>
> /opt/local/bin/python2.6 manage.py runserver
>
> On Tue, Aug 31, 2010 at 9:40 PM, keynesiandreamer
>
>
>
>
>
>  wrote:
> > So I tried the Macports option and it started to look good, but then I
> > got:
>
> > --->  Installing py26-pil @1.1.7_1
> > --->  Activating py26-pil @1.1.7_1
> > Error: Target org.macports.activate returned: Image error: /opt/local/
> > Library/Frameworks/Python.framework/Versions/2.6/bin/pilconvert.py
> > already exists and does not belong to a registered port.  Unable to
> > activate port py26-pil. Use 'port -f activate py26-pil' to force the
> > activation.
> > Log for py26-pil is at: /opt/local/var/macports/logs/
> > _opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py2 
> > 6-
> > pil/main.log
> > Error: Status 1 encountered during processing.
> > To report a bug, see 
> > Ben-Jammin-MacBook:~ martinek$ port -f activate py26-pil
> > Warning: Failed to open Portfile from registry for py26-pil @1.1.7_1
> > --->  Activating py26-pil
> > Error: port activate failed: sqlite error: attempt to write a readonly
> > database (8)
> > Ben-Jammin-MacBook:~ martinek$ sudo port install py26-pil
>
> > Sudo didn't work either
> > :-(
>
> > I am not even sure what DB is being discussed there...
>
> > I also tried reinstalling PIL after the failure of MacPorts and
> > something might have worked here. I don't get the same problem at the
> > python prompt trying import _imaging
>
> > Unfortunately Django/Pinax doesn't seem to see this after reactivating
> > the ENV and restarting the server:
>
> > BLurghh!!!
>
> > Is it worth trying to remake the virtualenv I am working with? Would
> > that help or is the problem still up the stream?
>
> > -Ben
>
> > On Aug 31, 11:49 am, keynesiandreamer 
> > wrote:
> >> Thanks Bill and Mathieu!
>
> >> I will try the Mac port option first, in fact I did look at it last
> >> night probably around 1am or so...
>
> >> I treied rebuilding the virtual env I was using as well just to
> >> verify, but the problem seem higher up the stream and Bill indicated.
> >> I will take a look for the ld.conf equiv in OSX at lunch today.
>
> >> Thanks!
> >> Ben
>
> >> On Aug 31, 10:20 am, Mathieu Leduc-Hamel  wrote:
>
> >> > To work with PIL and other librairies a little bit weird and difficult
> >> > to install the best way is to install Macport and after that:
>
> >> > port install py26-pil
>
> >> > and you'll need to use the python of the macport installation:
>
> >> > $ /opt/local/bin/python2.6
>
> >> > It's the samething on linux, i'm alway using the PIL package from my 
> >> > distro...
>
> >> > On Tue, Aug 31, 2010 at 7:10 PM, Bill Freeman  wrote:
> >> > > This sounds more like libjpeg isn't on the library load path, a
> >> > > system, rather than python, setting.
>
> >> > > I haven't done this with a Mac, but PIL has been troublesome on *nix
> >> > > servers for us as well.
>
> >> > > The common problems for us don't sound like your problem.  [Some
> >> > > versions of PIL install as "Imaging" rather than PIL.  If libjpeg
> >> > > isn't installed first, including development data (headers, stub
> >> > > library (called import library on Windows)) when your packaging system
> >> > > separates them, when you first build PIL, you can rebuild it until you
> >> > > are blue in the face and it won't pick up libjpeg that you installed
> >> > > later - need to totally remove PIL and rebuild]
>
> >> > > You seem to have successfully built to use libjpeg, but it isn't
> >> > > there.  I can think of three 

Re: _unicode_ method not working?

2010-09-01 Thread Daniel Roseman
On Sep 1, 7:28 pm, Erskine  wrote:
> Hi,
>
> I've just started using Django and have been following the 'Writing
> your first Django App' tutorial. So far so good, but I've run into a
> little irritation - the use of the _unicode_ method doesn't work for
> me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting
> right, but when I run the Python shell the only response I get for
> Poll.objects.all() is Polls: poll objects and not the objects
> themselves. This is my code as I've been following along on Page 1 of
> the tutorial.
>
> Thanks
>
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def _unicode_(self):
>         return self.question
>     def was_published_today(self):
>         return self.pub_date.date() == datetime.date.today()
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>     def _unicode_(self):
>         return self.choice

It's two underscores each side, not one - __unicode__, not _unicode_.
--
DR.

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



_unicode_ method not working?

2010-09-01 Thread Erskine
Hi,

I've just started using Django and have been following the 'Writing
your first Django App' tutorial. So far so good, but I've run into a
little irritation - the use of the _unicode_ method doesn't work for
me. I'm using Django 1.2.1. I'm pretty sure I've got the indenting
right, but when I run the Python shell the only response I get for
Poll.objects.all() is Polls: poll objects and not the objects
themselves. This is my code as I've been following along on Page 1 of
the tutorial.

Thanks


from django.db import models
import datetime

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def _unicode_(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def _unicode_(self):
return self.choice

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



mod_wsgi, apache, windows XP

2010-09-01 Thread Jesse
created project using startproject testproject

Problems with apache_django_wsgi.conf
1.  Added following line to Apache:
LoadModule wsgi_module modules/mod_wsgi.so

2. Created folder c:/django/testproject/apache

3.  Created file c:/django/testproject/apache/django.wsgi
// code starts
import os, sys
sys.path.append("/c:/django")

os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
// code ends

4.  Apache starts and restarts. local host is original apache "It
works"

5.  Created file c:/django/testproject/apache_django_wsgi.conf
//code starts
Alias /media/ /c:/django/testproject/media/


Order deny,allow
Allow from all


WSGIScriptAlias / /c:/django/testproject/apache/django.wsgi


Order deny,allow
Allow from all

//code ends

6.  Added following line to Apache http.conf
Include "c:/django/testproject/apache/apache_django_wsgi.conf"

7.  Apache error, cannot restart.

Any help is much appreciated.
Jesse

-- 
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: urlencode in Django

2010-09-01 Thread refreegrata
just a few moments ago i saw this in the django documentation. Now
works fine. Thanks.

On 1 sep, 12:10, Tom Evans  wrote:
> On Mon, Aug 30, 2010 at 10:45 PM, refreegrata  wrote:
> > now works for all characters. I don't  know why, but now finally
> > works. ñ is converted to "%C3%B1", ó is converted to "%C3%B3", + to
> > "%2B", ...
>
> > thanks.
>
> > P.D.: I hate use special characters in an url, generaly is a bad idea,
> > but is necessary in my application.
> > The client want to filter registers according the  name, and the name
> > can have special characters, and i must to paginate the results. The
> > other option is use a ghost form and javascript.
>
> > Thanks.
>
> The url resolver takes care of all of this magic for you. If you find
> it isn't, then you aren't using it right. For instance:
>
> link
>
> This is clearly an incorrect use of a url pattern. Instead, the var
> argument should be included as part of the urlpattern, and var given
> as an argument to the url template tag.
>
> link
>
> Do it like this, and you won't have problems. If you need to generate
> a query string, use the pattern as described by Alexandre González in
> the first reply.
>
> Cheers
>
> Tom

-- 
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 1.2 modelformset_factory fails with meta: widgets

2010-09-01 Thread refreegrata
rewrite the __init__., redefining the form element in this place. The
error must to dissapear.

class FormMyForm(ModelForm):
def __init__(self, *args, **kwargs):
super(FormMyForm, self).__init__(*args, **kwargs)
self.fields[''] =
forms.CharField(widget=forms.TextInput(attrs={.}))

class Meta:
model = Model
fields = ['']

On 1 sep, 12:01, Jason  wrote:
> Thanks! I'll give that a try.
>
> On Aug 13, 8:55 am, Matthew R  wrote:
>
> > I got hit by this same bug and here's the workaround I used, for
> > future reference. Basically you need to specify a formfield_callback
> > kwarg to modelformset_factory that just passes along any kwargs it
> > receives (namely, in this case, the 'widget' argument) to
> > Field.formfield():
>
> > def create_formfield(f, **kwargs):
> >     return f.formfield(**kwargs)
>
> > ArticleFormSet = modelformset_factory(Article,
> >   form = ArticleForm,
> >   formfield_callback=create_formfield,
> >   extra=0)
>
> > On Jul 29, 11:33 am, Jason  wrote:
>
> > > Can anyone confirm that passing in a form withMeta.widgets set to
> > > modelformset_factory() does in fact work?
>
> > > I've tried stripping my code down to the basics and still get the same
> > > exception. Debugging Django code doesn't help me because it fails
> > > during a lamda function that I don't quite understand.
>
> > > If anyone else has this problem I'll go ahead and submit a bug report.
>
> > > On Jul 28, 12:50 pm, Jason  wrote:
>
> > > > Traceback:
> > > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> > > > get_response
> > > >   100.                     response = callback(request,
> > > > *callback_args, **callback_kwargs)
> > > > File "C:\Documents and Settings\goodrich\PycharmProjects\CCC\Aggregator
> > > > \newsmail\views.py" in manage_articles
> > > >   174.                                           form = ArticleForm)
> > > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > > modelformset_factory
> > > >   669.
> > > > formfield_callback=formfield_callback)
> > > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > > modelform_factory
> > > >   407.     return ModelFormMetaclass(class_name, (form,),
> > > > form_class_attrs)
> > > > File "C:\Python25\lib\site-packages\django\forms\models.py" in __new__
> > > >   220.                                       opts.exclude,
> > > > opts.widgets, formfield_callback)
> > > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > > fields_for_model
> > > >   178.         formfield = formfield_callback(f, **kwargs)
>
> > > > Exception Type: TypeError at /newsmail/manage/
> > > > Exception Value: () got an unexpected keyword argument
> > > > 'widget'
>
> > > > On Jul 28, 12:00 pm, Daniel Roseman  wrote:
>
> > > > > On Jul 28, 7:08 pm, Jason  wrote:
>
> > > > > > For example:
>
> > > > > > class ArticleForm(ModelForm):
> > > > > >     classMeta:
> > > > > >         model = Article
> > > > > >         widgets = {
> > > > > >              'pub_date': SplitSelectDateTimeWidget(),
> > > > > >              'expire_date': CalendarWidget(attrs={'class':'date-
> > > > > > pick'})
> > > > > >         }
>
> > > > > > And in a view function:
> > > > > > ...
> > > > > >     ArticleFormSet = modelformset_factory(Article,
> > > > > >                                           form = ArticleForm,
> > > > > >                                           extra=0)
> > > > > > ...
>
> > > > > > Removing 'widgets' from theMetain ArticleForm fixes the error.
>
> > > > > > The new widgets convention here is really handy. I don't want to 
> > > > > > lose
> > > > > > it!
>
> > > > > > Any tips?
>
> > > > > How does it fail? What error do you get? If there's a traceback,
> > > > > please post it here.
> > > > > --
> > > > > DR.

-- 
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: url lookup not working?

2010-09-01 Thread Daniel Roseman
On Sep 1, 5:43 pm, eiriks  wrote:
> I'm reading Bennets Practical Django Projects and I'm stuck on chapter
> 6, on templates.
>
> The error I get is:
> "Caught an exception while rendering: Could not import
> django.views.generic_list_detail. Error was: No module named
> generic_list_detail"
> with this line highlighted:
> 20           Entries a>
>

Pretty sure that should be "generic.list_detail", with a dot instead
of the first underscore. You'll have to look through your code to see
where you've used that, as it's not in the code you supply below.
--
DR.

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



Querying a many-to-many field based on entries' number in the relationship

2010-09-01 Thread Jordon Wii
Hi,
I have a model named 'Period' and a model named 'Schedule'.  They have
a many-to-many relationship.  I need to get all Period's whose
position in the relationship is a certain number (All second periods
in each schedule, for example).

I could use raw SQL to query the m2m database, but is this possible
without raw SQL?


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



Can't login to admin site

2010-09-01 Thread vgarvardt
Django 1.2.1

Created new project, set DB settings (postgresql_psycopg2),
MEDIA_ROOT, MEDIA_URL, TEMPLATE_DIRS, added django.contrib.admin to
INSTALLED_APPS.

In urls.py uncommented:
from django.contrib import admin
admin.autodiscover()

and

(r'^admin/', include(admin.site.urls)),

Run manage.py syncdb - tables and superuser were successfully created.
Run manage.py runserver, opened http://127.0.0.1:8000/admin/ in
browser - got admin site login page, entered superuser login/pwd,
pressed Login button and got django debug error page:

TypeError at /admin/

add() takes at most 6 arguments (7 given)

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/
Exception Type: TypeError
Exception Value:

add() takes at most 6 arguments (7 given)

Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/
models/base.py in _collect_sub_objects, line 558
Python Executable:  /usr/bin/python
Python Version: 2.6.5
etc.

What am I doing 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.



url lookup not working?

2010-09-01 Thread eiriks
I'm reading Bennets Practical Django Projects and I'm stuck on chapter
6, on templates.

The error I get is:
"Caught an exception while rendering: Could not import
django.views.generic_list_detail. Error was: No module named
generic_list_detail"
with this line highlighted:
20   Entries

I've followed the book pretty tightly, and get the following
traceback:

Environment:

Request Method: GET
Request URL: http://me.info/blog/
Django Version: 1.2 alpha 1 SVN-12117
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.flatpages',
 'mevi.todo',
 'mevi.search',
 'mevi.coltrane',
 'mevi.tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Template error:
In template /home/users/me/www/templates/base.html, error at line 20
   Caught an exception while rendering: Could not import
django.views.generic_list_detail. Error was: No module named
generic_list_detail
   10 : 
   11 :   me.info - stuff
   12 :   things
   13 :   
   14 :   Blogitem2item2
   15 :   
   16 : 
   17 :
   18 : 
   19 : 
   20 :  Entries
   21 :  Links
   22 :  Cats
   23 :  Tags
   24 : 
   25 : 
   26 : {# {{ object.title }} #}
   27 : {% block content %}
   28 : {% endblock %}
   29 :
   30 : {% block whatis %}

Traceback:
File "/home/users/me/django/django/core/handlers/base.py" in
get_response
  99. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/users/me/django/django/views/generic/date_based.py" in
archive_index
  49. return HttpResponse(t.render(c), mimetype=mimetype)
File "/home/users/me/django/django/template/__init__.py" in render
  184. return self._render(context)
File "/home/users/me/django/django/template/__init__.py" in _render
  178. return self.nodelist.render(context)
File "/home/users/me/django/django/template/__init__.py" in render
  787. bits.append(self.render_node(node, context))
File "/home/users/me/django/django/template/debug.py" in render_node
  72. result = node.render(context)
File "/home/users/me/django/django/template/loader_tags.py" in render
  128. return compiled_parent._render(context)
File "/home/users/me/django/django/template/__init__.py" in _render
  178. return self.nodelist.render(context)
File "/home/users/me/django/django/template/__init__.py" in render
  787. bits.append(self.render_node(node, context))
File "/home/users/me/django/django/template/debug.py" in render_node
  72. result = node.render(context)
File "/home/users/me/django/django/template/loader_tags.py" in render
  128. return compiled_parent._render(context)
File "/home/users/me/django/django/template/__init__.py" in _render
  178. return self.nodelist.render(context)
File "/home/users/me/django/django/template/__init__.py" in render
  787. bits.append(self.render_node(node, context))
File "/home/users/me/django/django/template/debug.py" in render_node
  82. raise wrapped

Exception Type: TemplateSyntaxError at /blog/
Exception Value: Caught an exception while rendering: Could not import
django.views.generic_list_detail. Error was: No module named
generic_list_detail

Original Traceback (most recent call last):
  File "/home/users/me/django/django/template/debug.py", line 72, in
render_node
result = node.render(context)
  File "/home/users/me/django/django/template/defaulttags.py", line
372, in render
url = reverse(self.view_name, args=args, kwargs=kwargs,
current_app=context.current_app)
  File "/home/users/me/django/django/core/urlresolvers.py", line 357,
in reverse
*args, **kwargs)))
  File "/home/users/me/django/django/core/urlresolvers.py", line 278,
in reverse
possibilities = self.reverse_dict.getlist(lookup_view)
  File "/home/users/me/django/django/core/urlresolvers.py", line 199,
in _get_reverse_dict
self._populate()
  File "/home/users/me/django/django/core/urlresolvers.py", line 179,
in _populate
for name in pattern.reverse_dict:
  File "/home/users/me/django/django/core/urlresolvers.py", line 199,
in _get_reverse_dict
self._populate()
  File "/home/users/me/django/django/core/urlresolvers.py", line 191,
in _populate
lookups.appendlist(pattern.callback, (bits, p_pattern))
  File "/home/users/me/django/django/core/urlresolvers.py", line 138,
in _get_callback
raise ViewDoesNotExist, "Could not import %s. Error was: %s" %
(mod_name, str(e))
ViewDoesNotExist: Could not import django.views.generic_list_detail.
Error was: No module 

Re: how to add a non-field text property to forms in a formset

2010-09-01 Thread Bill Freeman
This seems to me to be a job for the template.  The forms documentation has
a section on custom rendering which shows you how to iterate through the
fields, or access them by name.  You would insert whatever HTML construct
was appropriate for your text, providing a context variable giving its contents,
if necessary.

On Wed, Sep 1, 2010 at 11:04 AM, bobhaugen  wrote:
> I often want to add properties to a formset that will fill a table
> cell with flexibly wrapping, read-only descriptive text.  For example,
> the description of a product, where the enterable field is the
> quantity ordered.
>
> If I use a field, the widget gets a fixed width and the contents do
> not wrap (unless I use a Textarea, which then gets a fixed number of
> rows).  The product descriptions can vary from one word to a military-
> style extended riff on options.
>
> Moreover, if I understand correctly, it is either not possible or
> unwise to display the initial value of a field as a string.
>
> So what I end up doing is rolling my own set of forms (that is, not
> using a formset) where I can add extra text properties to each form at
> will.
>
> Any other better solutions to this problem?
>
> Did I miss anything in the above description?
>
> Thanks.
>
> --
> 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: urlencode in Django

2010-09-01 Thread Tom Evans
On Mon, Aug 30, 2010 at 10:45 PM, refreegrata  wrote:
> now works for all characters. I don't  know why, but now finally
> works. ñ is converted to "%C3%B1", ó is converted to "%C3%B3", + to
> "%2B", ...
>
> thanks.
>
> P.D.: I hate use special characters in an url, generaly is a bad idea,
> but is necessary in my application.
> The client want to filter registers according the  name, and the name
> can have special characters, and i must to paginate the results. The
> other option is use a ghost form and javascript.
>
> Thanks.
>

The url resolver takes care of all of this magic for you. If you find
it isn't, then you aren't using it right. For instance:

link

This is clearly an incorrect use of a url pattern. Instead, the var
argument should be included as part of the urlpattern, and var given
as an argument to the url template tag.

link

Do it like this, and you won't have problems. If you need to generate
a query string, use the pattern as described by Alexandre González in
the first reply.

Cheers

Tom

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



New Release of ibm_db_django(1.0.1)

2010-09-01 Thread Rahul
IBM_DB_DJANGO-1.0.1
---
IBM_DB_DJANGO adaptor enables access to IBM databases from Django
applications http://www.djangoproject.com/. The adaptor is developed
and maintained by IBM.

What's New?

 - Fixed LIMIT constraint in select statement with column name alias
 - Fixed Unique column constraint with one NULL value
 - Fixed Unique columns together with one null value
 - Added Standard deviation, Variance function support (for population
standard deviation and variance)
 - Added MOD, BITAND and BITOR function support

SVN access to the source
---
http://code.google.com/p/ibm-db/source/browse/trunk/IBM_DB/ibm_db_django/

Installation

$ easy_install ibm_db_django

Feedback/Suggestions/Issues

You can provide us feedback/suggestions, or report a bug/defect, or
ask for help by using any of the following channels:
1. Mailing us at open...@us.ibm.com
2. Opening a new issue at http://code.google.com/p/ibm-db/issues/list.
3. By opening new discussion at http://groups.google.co.in/group/ibm_db.
For prerequisites, installation steps and help details, visit -
http://code.google.com/p/ibm-db/wiki/ibm_db_django_README
Try this out and let us know you valuable feedback. Have fun.

Cheers,
Rahul Priyadarshi

Download Express-C for free, go to:
---
-
http://www.ibm.com/software/data/db2/express/download.html?S_CMP=ECDDWW01_TACT=ACDB2011

-- 
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 1.2 modelformset_factory fails with meta: widgets

2010-09-01 Thread Jason
Thanks! I'll give that a try.

On Aug 13, 8:55 am, Matthew R  wrote:
> I got hit by this same bug and here's the workaround I used, for
> future reference. Basically you need to specify a formfield_callback
> kwarg to modelformset_factory that just passes along any kwargs it
> receives (namely, in this case, the 'widget' argument) to
> Field.formfield():
>
> def create_formfield(f, **kwargs):
>     return f.formfield(**kwargs)
>
> ArticleFormSet = modelformset_factory(Article,
>   form = ArticleForm,
>   formfield_callback=create_formfield,
>   extra=0)
>
> On Jul 29, 11:33 am, Jason  wrote:
>
> > Can anyone confirm that passing in a form withMeta.widgets set to
> > modelformset_factory() does in fact work?
>
> > I've tried stripping my code down to the basics and still get the same
> > exception. Debugging Django code doesn't help me because it fails
> > during a lamda function that I don't quite understand.
>
> > If anyone else has this problem I'll go ahead and submit a bug report.
>
> > On Jul 28, 12:50 pm, Jason  wrote:
>
> > > Traceback:
> > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> > > get_response
> > >   100.                     response = callback(request,
> > > *callback_args, **callback_kwargs)
> > > File "C:\Documents and Settings\goodrich\PycharmProjects\CCC\Aggregator
> > > \newsmail\views.py" in manage_articles
> > >   174.                                           form = ArticleForm)
> > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > modelformset_factory
> > >   669.
> > > formfield_callback=formfield_callback)
> > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > modelform_factory
> > >   407.     return ModelFormMetaclass(class_name, (form,),
> > > form_class_attrs)
> > > File "C:\Python25\lib\site-packages\django\forms\models.py" in __new__
> > >   220.                                       opts.exclude,
> > > opts.widgets, formfield_callback)
> > > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > > fields_for_model
> > >   178.         formfield = formfield_callback(f, **kwargs)
>
> > > Exception Type: TypeError at /newsmail/manage/
> > > Exception Value: () got an unexpected keyword argument
> > > 'widget'
>
> > > On Jul 28, 12:00 pm, Daniel Roseman  wrote:
>
> > > > On Jul 28, 7:08 pm, Jason  wrote:
>
> > > > > For example:
>
> > > > > class ArticleForm(ModelForm):
> > > > >     classMeta:
> > > > >         model = Article
> > > > >         widgets = {
> > > > >              'pub_date': SplitSelectDateTimeWidget(),
> > > > >              'expire_date': CalendarWidget(attrs={'class':'date-
> > > > > pick'})
> > > > >         }
>
> > > > > And in a view function:
> > > > > ...
> > > > >     ArticleFormSet = modelformset_factory(Article,
> > > > >                                           form = ArticleForm,
> > > > >                                           extra=0)
> > > > > ...
>
> > > > > Removing 'widgets' from theMetain ArticleForm fixes the error.
>
> > > > > The new widgets convention here is really handy. I don't want to lose
> > > > > it!
>
> > > > > Any tips?
>
> > > > How does it fail? What error do you get? If there's a traceback,
> > > > please post it here.
> > > > --
> > > > DR.
>
>

-- 
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: seeing HTML code, not the interpreted html

2010-09-01 Thread Bradley Hintze
I just made the HTML in the template using a for loop. DOH!!

On Wed, Sep 1, 2010 at 10:38 AM, Bradley Hintze
 wrote:
> Hi all,
>
> I am playing with iframes for the first time and am gelling some
> undesired results. The 'stuff' in my frame shows as HTML code instead
> of the expected html 'interpretation.' I hope that made sense) I am
> looking to fix this. Here is what I did: I generated a string with all
> my html in it and saved it under a request.session key. On my template
> I simply put {{ key }} and thus I get my result.
>
> Can I ge django to interpret my strinng as HTML?
>
> Heres the relevant code
>
>
> results.html (template)
> ...
> 
>  Your browser does not support iframes.
> 
> ...
>
> urls.py
> ...
>    (r'^rotamer_diff/$', rotamer_dif_frame),
> ...
>
> views.py
> ...
> def rotamer_dif_frame(request):
>    return render_to_response('rotamer_dif_frame.html',
> request.session, context_instance=RequestContext(request))
> ...
>
> rotamer_dif_frame.htm
>
> {{ rotamer_dif_html }}
>
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

-- 
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 to add a non-field text property to forms in a formset

2010-09-01 Thread bobhaugen
I often want to add properties to a formset that will fill a table
cell with flexibly wrapping, read-only descriptive text.  For example,
the description of a product, where the enterable field is the
quantity ordered.

If I use a field, the widget gets a fixed width and the contents do
not wrap (unless I use a Textarea, which then gets a fixed number of
rows).  The product descriptions can vary from one word to a military-
style extended riff on options.

Moreover, if I understand correctly, it is either not possible or
unwise to display the initial value of a field as a string.

So what I end up doing is rolling my own set of forms (that is, not
using a formset) where I can add extra text properties to each form at
will.

Any other better solutions to this problem?

Did I miss anything in the above description?

Thanks.

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



seeing HTML code, not the interpreted html

2010-09-01 Thread Bradley Hintze
Hi all,

I am playing with iframes for the first time and am gelling some
undesired results. The 'stuff' in my frame shows as HTML code instead
of the expected html 'interpretation.' I hope that made sense) I am
looking to fix this. Here is what I did: I generated a string with all
my html in it and saved it under a request.session key. On my template
I simply put {{ key }} and thus I get my result.

Can I ge django to interpret my strinng as HTML?

Heres the relevant code


results.html (template)
...

  Your browser does not support iframes.

...

urls.py
...
(r'^rotamer_diff/$', rotamer_dif_frame),
...

views.py
...
def rotamer_dif_frame(request):
return render_to_response('rotamer_dif_frame.html',
request.session, context_instance=RequestContext(request))
...

rotamer_dif_frame.htm

{{ rotamer_dif_html }}


-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Multiple authentication sources to one database

2010-09-01 Thread Alex
I am trying to write an application that allows two different kinds of
authentication: Users in the wild can register and use the site with a
new username, password and email and authenticate as usual, and others
can use a single-sign-on solution provided by my university. django-
cas (http://code.google.com/p/django-cas/) and django-cas-provider
(http://nitron.org/projects/django-cas-provider/) both handle the
single-sign-on solution, but they overload the username field to
correspond to the username provided by CAS. This means that if someone
registers as "johndoe" then someone who authenticates as "johndoe"
with CAS will suddenly have access to the internals of the other
account.

Is there a way to separate out these authentication methods so that
both can be used on the same django installation? (They both need
access to the same database of information.) If this isn't possible, I
may try to create a whole second instance of django running on the
same database (but then they both will want to use the "auth_users"
table anyways).

-- 
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 is this feature called?

2010-09-01 Thread norus
Hi all,

I've decided to start learning Django and Python at the same time. The
project I'm working on will help configure Nagios directly from the
Django administation page. Here's a sample screenshot of what I've
done so far: http://valiyev.net/tmp/progress.png

Now my question is as follows, under "Check options", how do I add an
additional CharField where I would be able to submit arguments to the
command in "Service Checks"? Here's how other people did it (all I
could find was this screenshot: 
http://www.linuxaddicted.de/blog/wp-content/uploads/2009/03/picture-6.png).

Thanks in advance.

norus

-- 
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: Chat application in Django

2010-09-01 Thread yves_s
I also looking for realtime messaging for django and found this two
links.

http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-twisted/

http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/

yves

-- 
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: {% csrf_token %} template tag not outputting the hidden field

2010-09-01 Thread Jonas Geiregat
I had the same problem some day's ago.
Did you add the context_instance parameter in the render_to_reponse function 
call. It's needed for CSRF to work.

For example: return render_to_response('blog/index.html', {'posts': posts}, 
context_instance=RequestContext(req))

Regards,

Jonas.
Op 30-aug-2010, om 20:46 heeft Erik het volgende geschreven:

> Hi Django Users-
> I'm having trouble with the {% csrf_token %} tag.
> On my site I have a regular login view / page / url, which uses
> the django contrib registration app.  I include the CSRF token in my
> login template and it works fine.
> I'd also like a little login box in the corner of every page,
> which will either show a login form or a "you're logged in!" message
> depending on whether the user is logged in.  So, I wrote a little form
> into my base.html template that other templates inherit from; and I
> stuck the {% csrf_token %} tag in there as well.
> The part I don't understand is, if I load the login url in the
> browser ( mysite.com/login/ ) both forms work, I can login with them,
> and when I view the source the CSRF token tag has put a hidden field
> into my form.
> However, when I'm on any other page - for example the front page
> - the token tag just leaves a blank space and doesn't output anything,
> but it doesn't give me an error message on loading the page - as it
> would when I try to use a token tag that doesn't exist - such as {%
> faketokentag  %}.  Of course, because the csrf token tag doesn't
> create any output (in the HTML source generated) when the form is
> submitted the CSRF error occurs.
> I'm rendering all such pages with the generic view
> direct_to_template , which, because it's a generic view, the
> documentation suggests should just work with CSRF.
> Does anyone have any suggestions?
> 
> Thank you,
> Erik
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




-- 
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 + Postgres

2010-09-01 Thread meitham
> So I have installed postgres, pyscopg2.
>
> su postgres
> created a database
> updated my settings.py:
> DATABASES = {
>     'default': {
>         'ENGINE': 'django.db.backends.postgresql_psycopg2',
>         'NAME': 'template1',
>         'USER': 'postgres',
>         'PASSWORD': 'postgres',
>
> Then I have su postgres
> postg...@myvps:/var/www/django/$ python manage.py syncdb
>
> That upates the database, with all the admin database stuff, but it
> doesnt find anything at the admin url
>
Did you run django as a postgres user too?

-- 
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: Query overhead or not ?

2010-09-01 Thread Jonas Geiregat
Tag.objects.values('name').annotate(times_used=Count('post__tags'))

That's the solution!

Op 1-sep-2010, om 15:00 heeft Jonas Geiregat het volgende geschreven:

> I look at aggregation and annotation but I don't think It's possible to solve 
> this by using any of those two systems. 
> Or am I overlooking something ?
> 
> 
> Op 31-aug-2010, om 13:09 heeft Jonas Geiregat het volgende geschreven:
> 
>> Thanks for your advise. I'm short of time right now so I briefly looked at 
>> django's aggregation possibilities.
>> I'll look into them more deeply tonight.
>> 
>> But I stumbled upon a problem.
>> 
>> Post.objects.values('tags')
>> 
>> Gives me:
>> 
>> FieldError: Invalid field name: 'tags'
>> 
>> In [56]: Post.tags
>> Post.tags  
>> 
>> In [56]: Post.tags
>> Out[56]: 
>> > at 0x78f9f0>
>> 
>> Post.tags does exist. Maybe it's because it's a ManyToManyField ? So I tried 
>> Post.objects.values('tags__name'). Still got an error ?
>> 
>> I'm wondering why ?
>> 
>> Op 31-aug-2010, om 09:28 heeft Jirka Vejrazka het volgende geschreven:
>> 
 tags = Tag.objects.all()
 
 for t in tags:
  indexed_tags[t] = Post.objects.filter(tags__name=t).count()
 
 Next I would sort indexed_tags and I have a dictionary of which tags are 
 used the most.
 
 I'm wondering if this is a good idea ? Since if I have 1000 tags this 
 would require 1000 queries just for one simple tag cloud.
 Is there a better way of solving this without adding an extra count field 
 to the Tag model.
>>> 
>>> Hi Jonas,
>>> 
>>> your gut feeling was correct - it's not a very good idea, although
>>> it might work for a small site. You might want to take a look at
>>> database aggregation in Django:
>>> http://docs.djangoproject.com/en/1.2/topics/db/aggregation/
>>> 
>>> Cheers
>>> 
>>>   Jirka
>>> 
>>> -- 
>>> 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.
>>> 
>> 
>> Met vriendelijke groeten,
>> 
>> Jonas Geiregat
>> jo...@geiregat.org
>> 
>> 
>> 
>> 
>> -- 
>> 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.
>> 
> 
> Met vriendelijke groeten,
> 
> Jonas Geiregat
> jo...@geiregat.org
> 
> 
> 
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




-- 
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: Chat application in Django

2010-09-01 Thread David Koblas

 Two challenges with long polling and Apache/mod_python -

* First is that you'll need to have N-user connections open at a minimum 
based on the number of users you have using the system simultaneously.  
Thus your memory footprint and performance is going to suffer as the 
number of users increases.


* Second - the demo app I have assumes a single process model for 
handling communications (e.g. all notification is done via callbacks).  
So you would need to build some kind of server who maintains state if 
you ran things under apache (multi-process dispatch model).


--david


On 8/31/10 10:33 PM, Shamail Tayyab wrote:

Hi,

@Jeff, Erlang! Pretty surprised to see that.
@Alexander, doesn't work :( - or might be I am not able to get it..
@David, cool I'll try this, but will this work using mod_python / Apache?
@ebry1,
Imagine 1 people live chatting, that means 1 requests per
second, but in real world, only 3000 messages might have been
delivered. (as example). Polling will bring your net throughput of the
server to almost one tenth.

@all,
Can you suggest me the side effects of using Sockets via 1x1px flash
applet embedded on the page? Apart from the fact that flash is
required.

Thanks

On Wed, Sep 1, 2010 at 5:23 AM, ebry1  wrote:

I am interested in this problem too, I need to pass some additional
data along side chat messages.

Why did you decide to abandon polling?  I was thinking of thinking of
using it and updating about twice a second.



On Aug 31, 6:34 am, Shamail Tayyab  wrote:

Hi,

I am working on a chat application in Django, how can I ensure that I
do not have to poll the server for any chat data.

Possible approaches that I've been to:

1. BAD - use polling.

2. Use long polling - bad approach afa browser support is concerned.

3. Using sockets in flash - makes the application flash dependent.

Is there some good way to do this? Or if there is something Django
specific? Something like HTTPBinding or any 3rd party tested libraries?
I am expected to provide support till IE6. :-(

Correct me if I am wrong, flash is available on 95% of the systems, this
approach looks like safest bet, is it good to go?

Btw, how does Gmail and FB chat works?

Thanks

--
Shamail Tayyab
Blog:http://shamail.in/blog

--
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: fetching values from model

2010-09-01 Thread Steve Holden
On 9/1/2010 9:13 AM, Pradnya wrote:
>> ok. Is there any way I can load the model inside HTML template?
>> What is {% load  %} tag all about?
>> 
The {% load %} tag is for loading custom tags. Nothing to do with
accessing the database.

Why do you find it desirable to load records in the template?  What's
wrong with doing it in the view, which is what everyone else does and
how Django is intended to be used? See Jonas' remarks below.

regards
 Steve

>> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
 You don't write Python code inside your template file. That's
 one of the basic django template rules. You can pass values
 from your views to your template and show them there. Or
 generate the HTML in your view and show it from there, which
 isn't something I could advise if you're creating a larger
 application.
 
 Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
 
 
 
>> Hello,
 
>> Is it possible to fetch a particular record from model
>> using school.object.get(id = 1) inside html template.
 
>> Please suggest.
 
>> Thanks Pradnya
 
>> -- 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.
 
 Met vriendelijke groeten,
 
 Jonas Geiregat jo...@geiregat.org
>> 

-- 
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: fetching values from model

2010-09-01 Thread Jonas Geiregat
I suggest you read the djangobook or some of the django documentation because 
this is very well documented.

Good luck with that!

Op 1-sep-2010, om 15:13 heeft Pradnya het volgende geschreven:

> ok. Is there any way I can load the model inside HTML template? What
> is {% load  %} tag all about?
> 
> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
>> You don't write Python code inside your template file. That's one of the 
>> basic django template rules.
>> You can pass values from your views to your template and show them there.
>> Or generate the HTML in your view and show it from there, which isn't 
>> something I could advise if you're creating a larger application.
>> 
>> Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>> 
>> 
>> 
>>> Hello,
>> 
>>> Is it possible to fetch a particular record from model using
>>> school.object.get(id = 1) inside html template.
>> 
>>> Please suggest.
>> 
>>> Thanks
>>> Pradnya
>> 
>>> --
>>> 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.
>> 
>> Met vriendelijke groeten,
>> 
>> Jonas Geiregat
>> jo...@geiregat.org
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




-- 
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: fetching values from model

2010-09-01 Thread Pradnya
ok. Is there any way I can load the model inside HTML template? What
is {% load  %} tag all about?

On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
> You don't write Python code inside your template file. That's one of the 
> basic django template rules.
> You can pass values from your views to your template and show them there.
> Or generate the HTML in your view and show it from there, which isn't 
> something I could advise if you're creating a larger application.
>
> Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
>
>
> > Hello,
>
> > Is it possible to fetch a particular record from model using
> > school.object.get(id = 1) inside html template.
>
> > Please suggest.
>
> > Thanks
> > Pradnya
>
> > --
> > 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.
>
> Met vriendelijke groeten,
>
> Jonas Geiregat
> jo...@geiregat.org

-- 
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: fetching values from model

2010-09-01 Thread Pradnya
ok. Is there anyway I can load model inside HTML template? or
basically what is {% load  %} is used for ?

On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
> You don't write Python code inside your template file. That's one of the 
> basic django template rules.
> You can pass values from your views to your template and show them there.
> Or generate the HTML in your view and show it from there, which isn't 
> something I could advise if you're creating a larger application.
>
> Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
>
>
> > Hello,
>
> > Is it possible to fetch a particular record from model using
> > school.object.get(id = 1) inside html template.
>
> > Please suggest.
>
> > Thanks
> > Pradnya
>
> > --
> > 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.
>
> Met vriendelijke groeten,
>
> Jonas Geiregat
> jo...@geiregat.org

-- 
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: fetching values from model

2010-09-01 Thread Jonas Geiregat

You don't write Python code inside your template file. That's one of the basic 
django template rules.
You can pass values from your views to your template and show them there.
Or generate the HTML in your view and show it from there, which isn't something 
I could advise if you're creating a larger application.



Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:

> Hello,
> 
> Is it possible to fetch a particular record from model using
> school.object.get(id = 1) inside html template.
> 
> Please suggest.
> 
> Thanks
> Pradnya
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




-- 
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: Query overhead or not ?

2010-09-01 Thread Jonas Geiregat
I look at aggregation and annotation but I don't think It's possible to solve 
this by using any of those two systems. 
Or am I overlooking something ?


Op 31-aug-2010, om 13:09 heeft Jonas Geiregat het volgende geschreven:

> Thanks for your advise. I'm short of time right now so I briefly looked at 
> django's aggregation possibilities.
> I'll look into them more deeply tonight.
> 
> But I stumbled upon a problem.
> 
> Post.objects.values('tags')
> 
> Gives me:
> 
> FieldError: Invalid field name: 'tags'
> 
> In [56]: Post.tags
> Post.tags  
> 
> In [56]: Post.tags
> Out[56]:  object at 0x78f9f0>
> 
> Post.tags does exist. Maybe it's because it's a ManyToManyField ? So I tried 
> Post.objects.values('tags__name'). Still got an error ?
> 
> I'm wondering why ?
> 
> Op 31-aug-2010, om 09:28 heeft Jirka Vejrazka het volgende geschreven:
> 
>>> tags = Tag.objects.all()
>>> 
>>> for t in tags:
>>>   indexed_tags[t] = Post.objects.filter(tags__name=t).count()
>>> 
>>> Next I would sort indexed_tags and I have a dictionary of which tags are 
>>> used the most.
>>> 
>>> I'm wondering if this is a good idea ? Since if I have 1000 tags this would 
>>> require 1000 queries just for one simple tag cloud.
>>> Is there a better way of solving this without adding an extra count field 
>>> to the Tag model.
>> 
>> Hi Jonas,
>> 
>> your gut feeling was correct - it's not a very good idea, although
>> it might work for a small site. You might want to take a look at
>> database aggregation in Django:
>> http://docs.djangoproject.com/en/1.2/topics/db/aggregation/
>> 
>>  Cheers
>> 
>>Jirka
>> 
>> -- 
>> 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.
>> 
> 
> Met vriendelijke groeten,
> 
> Jonas Geiregat
> jo...@geiregat.org
> 
> 
> 
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




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



fetching values from model

2010-09-01 Thread Pradnya
Hello,

Is it possible to fetch a particular record from model using
school.object.get(id = 1) inside html template.

Please suggest.

Thanks
Pradnya

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



multiple oracle database queries in one request problem

2010-09-01 Thread Reinout van Rees

Hi,

I'm deploying a site on windows with oracle (and I don't know either of 
them well).  Simple apache+wsgi setup for now.


Problem: one specific page kills off the mod_wsgi/django part. The rest 
of apache keeps working. "Kill off" meaning "it doesn't react anymore 
and takes quite some time for apache to kill it when I close apache.


The only error message I can find is an
"errno 10054" "existing connection was forcibly closed".  I can only 
guess that the remote database server closed something.



The specific page is the only one that fires off queries to both 
databases, so within the same request.  Anyone got any hints on where to 
look?  How to debug?   How to fix it?



Reinout (who dislikes the amount of handy debug info he's got...)


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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: static files

2010-09-01 Thread Reinout van Rees

On 08/30/2010 09:26 PM, Bradley Hintze wrote:

base.html
...


   


That "media/xyz.gif" means that if you've got a
http://example.com/subdir/test.html page, the image looked up is
http://example.com/subdir/media/ajax-loader.gif

You probably want "/media/ajax-loader.gif".

And: you're apparently not using {{ MEDIA_URL }} in your template, which 
is intended precisely to get the url right (and absolute).



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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: Surreptitious caching of JS in Django

2010-09-01 Thread Reinout van Rees

On 08/30/2010 07:52 PM, buddhasystem wrote:


Hello,
with the generous help of many of you, I easily set up JSON caching feature
in my Django app, in a few views.

The problem I'm now facing is that according to what I observe, Django also
caches Javascript code in its memcached backend.


That's probably something you configured yourself.

Anyway, in development you can uncomment any CACHE_BACKEND in your 
settings.py and no caching will happen.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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: GeoDjango: default 4326 SRID doesn't work for transform()

2010-09-01 Thread Reinout van Rees

On 08/30/2010 04:14 PM, kyleduncan wrote:

Hi,

thanks for the tips! to answer your questions:

1. our model doesnt specify a coordinate system, it just saves the lat
and lng that are returned from google maps.
2. i thought transforming had to be done to make a lat/lng point
"spatial" before distance was calculated. have i got that wrong?
3. i'm not actually sure we even have a "geodatabase". all we have are
pointfields in the model for users, which save the lat/lng points from
google.


Those PointFields are what make it a geo database (well, that's how I 
use the terminology anyway).


So your_object.your_point_field.distance(another.your_point_field) ought 
to give you a distance alright.


I don't know from the top of my head which unit that distance is in. 
I've only had to pick the closest one till now :-)



i'm not really capable enough to know how to proceed on my own from
your points, but for now i'll try removing the transform() (and also
placing it after) and i'll also specify the transform SRID of 900973
(is that the SRID for google or are you talking about something else
with that number?)


Oopsie, that's 900913 instead of 900973 (google written in characters 
that look a bit similar).



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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: PIL on 10.6 = PAIN

2010-09-01 Thread Mathieu Leduc-Hamel
This is because you should not use the Python interpreter from you're
Mac installation. Are you using buildout ? VirtualEnv? or nothing ?

Buildout:

/opt/local/bin/python2.6 bootstrap.py

Virtualenv:

virtualenv -p /opt/local/bin/python2.6 

Nothing:

/opt/local/bin/python2.6 manage.py runserver

On Tue, Aug 31, 2010 at 9:40 PM, keynesiandreamer
 wrote:
> So I tried the Macports option and it started to look good, but then I
> got:
>
> --->  Installing py26-pil @1.1.7_1
> --->  Activating py26-pil @1.1.7_1
> Error: Target org.macports.activate returned: Image error: /opt/local/
> Library/Frameworks/Python.framework/Versions/2.6/bin/pilconvert.py
> already exists and does not belong to a registered port.  Unable to
> activate port py26-pil. Use 'port -f activate py26-pil' to force the
> activation.
> Log for py26-pil is at: /opt/local/var/macports/logs/
> _opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-
> pil/main.log
> Error: Status 1 encountered during processing.
> To report a bug, see 
> Ben-Jammin-MacBook:~ martinek$ port -f activate py26-pil
> Warning: Failed to open Portfile from registry for py26-pil @1.1.7_1
> --->  Activating py26-pil
> Error: port activate failed: sqlite error: attempt to write a readonly
> database (8)
> Ben-Jammin-MacBook:~ martinek$ sudo port install py26-pil
>
> Sudo didn't work either
> :-(
>
> I am not even sure what DB is being discussed there...
>
> I also tried reinstalling PIL after the failure of MacPorts and
> something might have worked here. I don't get the same problem at the
> python prompt trying import _imaging
>
> Unfortunately Django/Pinax doesn't seem to see this after reactivating
> the ENV and restarting the server:
>
> BLurghh!!!
>
> Is it worth trying to remake the virtualenv I am working with? Would
> that help or is the problem still up the stream?
>
> -Ben
>
> On Aug 31, 11:49 am, keynesiandreamer 
> wrote:
>> Thanks Bill and Mathieu!
>>
>> I will try the Mac port option first, in fact I did look at it last
>> night probably around 1am or so...
>>
>> I treied rebuilding the virtual env I was using as well just to
>> verify, but the problem seem higher up the stream and Bill indicated.
>> I will take a look for the ld.conf equiv in OSX at lunch today.
>>
>> Thanks!
>> Ben
>>
>> On Aug 31, 10:20 am, Mathieu Leduc-Hamel  wrote:
>>
>>
>>
>> > To work with PIL and other librairies a little bit weird and difficult
>> > to install the best way is to install Macport and after that:
>>
>> > port install py26-pil
>>
>> > and you'll need to use the python of the macport installation:
>>
>> > $ /opt/local/bin/python2.6
>>
>> > It's the samething on linux, i'm alway using the PIL package from my 
>> > distro...
>>
>> > On Tue, Aug 31, 2010 at 7:10 PM, Bill Freeman  wrote:
>> > > This sounds more like libjpeg isn't on the library load path, a
>> > > system, rather than python, setting.
>>
>> > > I haven't done this with a Mac, but PIL has been troublesome on *nix
>> > > servers for us as well.
>>
>> > > The common problems for us don't sound like your problem.  [Some
>> > > versions of PIL install as "Imaging" rather than PIL.  If libjpeg
>> > > isn't installed first, including development data (headers, stub
>> > > library (called import library on Windows)) when your packaging system
>> > > separates them, when you first build PIL, you can rebuild it until you
>> > > are blue in the face and it won't pick up libjpeg that you installed
>> > > later - need to totally remove PIL and rebuild]
>>
>> > > You seem to have successfully built to use libjpeg, but it isn't
>> > > there.  I can think of three possibilities:
>>
>> > > 1. It really isn't there, maybe the reverse problem of installing a
>> > > "development" package but not the main one.
>>
>> > > 2. It's there, but it doesn't match the version your _imagning.so was
>> > > built against.
>>
>> > > 3. It's there, but the library loader hasn't been told about it.  On
>> > > linux this means findable via ld.conf (or ld.so.conf) and ldconfig has
>> > > been run since.  Package installation scripts usually take care of
>> > > this, but it sometimes needs to be done by hand, if you're just, for
>> > > example, unpacking a tarball.  I don't know the equivalent for osx.
>>
>> > > Good luck.
>>
>> > > Bill
>>
>> > > On Tue, Aug 31, 2010 at 12:41 PM, keynesiandreamer
>> > >  wrote:
>> > >> Howdy!
>>
>> > >> I have been working with Django/Pinax on a 10.6.4 system with python
>> > >> 2.6.6 and have had no luck getting PIL to work. I have looked through
>> > >> about 10-15 paged including ones listed on this group with no results.
>> > >> Currently the error I am getting is:
>> > >> The _imaging C module is not installed
>>
>> > >> I have verified _imaging.so is in the file system. So it seems like a
>> > >> syspath issue. I tried 

Django RawQuerySet with Oracle CLOB

2010-09-01 Thread huw_at1
Hi there,

I've recently been using the raw() manager method to perform a few
more complex SQL queries on my Oracle DB and this has been working
very nicely. One particular SQL, however, appears to be giving blank
or phantom objects:

raw_query_list = list(tmp_class.object.raw(SELECT TO_CHAR(clob_column)
AS tmp_char, pk AS tmp_pk FROM table_name WHERE conditions))

where the tmp_class consists of:

class tmp_class(models.Model):

tmp_pk = models.IntegerField(primary_key=True)
tmp_char = models.TextField()

class Meta:
managed=False

Running the SQL query through cx_Oracle gives expected results however
when trying to present the list through a template the objects all
appear as blank. I realise that strictly speaking converting CLOB to
VARCHAR2 gives rise to potential issues over string length however in
this case all values in the CLOB column are less than 4000 characters.
My problem is that I am unsure as to where to start debugging. If I
had to guess at what the source of the problem was given the symptoms
I would say that it was something to do with the fact that CLOBs
operate using memory pointers rather than actual values so the phantom
objects are displayed as a result of the pointer being at the end of
the column. I could have made a mistake with the model however so I am
unsure. Any suggestions?

Many thanks as ever.

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