Django snippets - printable view?

2011-01-19 Thread Derek
I see the original design for the Django Snippets site was by Jeff Croft.  I
am not sure if he is involved any more, or who maintains the site design,
but I was wondering if the CSS could be upgraded to allow for an improved,
printable view?

Thanks
Derek

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



Re: Pinax: worth installing?

2011-01-19 Thread Derek
Jason

I have been planning to use Pinax for a large social network site, but your
comments make me concerned (and wondering if I should wait for a 1.0
release).  I'd appreciate it if you could be a bit more specific about the
issues you have encountered or know about.

I assume that Django itself (being mature and stable) is not the problem.
Given that Pinax is essentially just a bundle of third party apps, are the
problems with:

(a) one or more of the specific apps themselves?

(b) the way that one or more of the apps interact?

(c) only the sample data / demos?

Also, the great strength of successful open source projects is the
interaction between developers and community.  What has the response been
when you have communicated these issues to them ... do they not care?  do
they respond at all?

Thanks
Derek


On 19 January 2011 18:46, Jason  wrote:

> I've found the current state of Pinax to be a bit hard to use.
>
> Yes, it offers these 'ready-to-use' projects but they do not work out
> of the box. There are CSRF problems, they don't load the initial
> sample data properly, and sometimes they just don't load at all.
>
> This is the case at least when I use the pip installation. (oh which
> btw I flat out couldn't get to work period on Windows)
>
> Overall it leaves me very worried about beginning a serious project in
> Pinax. I'll definitely check back again with it at the official 0.9
> release but for now I remain weary.
>
> On Jan 18, 5:26 am, ashdesigner  wrote:
> > Guys, are there any considerable drawbacks of using Pinax for Django?
> > Is it worth installing, or is it better to launch and develop on
> > "pure" Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



[beginner] extra_context in generic views

2011-01-19 Thread John Yeukhon Wong
http://docs.djangoproject.com/en/dev/topics/generic-views/#adding-extra-context
I am confused by the model scenario.

"For example, think of showing a list of all the books on each
publisher detail page. The object_detail generic view provides the
publisher to the context, but it seems there's no way to get
additional information in that template."
So, say below the detail of a publisher (first name, last name, books
published, phone, address, logo...etc), we might want to display a
list of other publisher.

"This would populate a {{ book_list }} variable in the template
context. This pattern can be used to pass any information down into
the template for the generic view. It's very handy."

So why do we create extra_context anyway?

A section above, the urlpatterns was
"urlpatterns = patterns('',
(r'^publishers/$', list_detail.object_list, publisher_info)
)"

I am confused. Can anyone explain what's going on if I have the
extra_context, and how do I exactly used that? 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread arlolra
maybe use something like piston
https://bitbucket.org/jespern/django-piston/wiki/Home

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



Re: Django + CSS

2011-01-19 Thread Vovk Donets
Man, this is just a quote from Django Documentation.

2011/1/20 Osiaq 

> Same problem here. Follow those rules, is simple and is working
> perfect.
>
>
> http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html
>
>


-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Readonly on subset of forms in Admin inlines

2011-01-19 Thread Peter Phillips
Hello,

Is there a straightforward way to set fields to read only for a subset
of the forms in an inline formset in the Admin? I'd like to set some
fields to read only on my inline form for rows that were not created
by the user. However, when I set the fields to read only, it of course
affects all rows/forms in the inline, preventing the user from editing
their own rows. Do I need to do a custom formset for
InlineModelAdmin.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [django-users] Custom signals

2011-01-19 Thread Łukasz Rekucki
On 20 January 2011 02:00, Piotr Zalewa  wrote:
> I'm trying to add custom signals to my models.
> I'm sure I'm missing some step.
>
> http://paste.pocoo.org/show/323618/
>

The "sender" argument in receiver() must match the one in send()
(using identity). In receive() you're using a class, while in send()
you're passing an instance of that class, so they have no chance of
matching.

Try:

post_copy.send(sender=type(self), copied_to=new_version)

-- 
Łukasz Rekucki

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



Re: 4 different domains on single apache/mod_wsgi

2011-01-19 Thread Graham Dumpleton
Technically it should be able to made to work. I would recommend though you 
use mod_wsgi daemon mode and delegate each Django site instance to its own 
process, rather than each sharing the same process but in different sub 
interpreters. See:

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

This will ensure that leakage of environment variables or other process 
level settings across sub interpreters doesn't occur.

Graham

On Thursday, January 20, 2011 11:20:36 AM UTC+11, Osiaq wrote:
>
> Hi all! 
> I have 2 separate projects, with 2 separate domains 
>
> The problem: first website, ELG, is working OK. 
> Another, cc4h, cannot find template index.html, but is working perfect 
> on localhost with Django development server. 
>
> Do you know any good tutorial regarding multiple domains on single 
> Apache? 
> It doesnt seems as easy as I thought it will be. 
>
> Thank you 
>
> Code: 
>
> Both WSGI files (projects ELG and CC4H): 
> - 
>  /home/django/projects/elg/apache/elg.wsgi 
>  /home/django/projects/cc4h/apache/cc4h.wsgi 
> - 
> import os, sys 
> sys.path.append('/home/django/projects') 
> os.environ['DJANGO_SETTINGS_MODULE'] = 'elg.settings' #for project 
> cc4h is 'cc4h.settings' 
> import django.core.handlers.wsgi 
> application = django.core.handlers.wsgi.WSGIHandler() 
>
>  
> My httpd.conf: 
>  
> NameVirtualHost * 
>  
> ServerName www.domain1.com 
> ServerAdmin ***l...@gmail.com 
> Alias /robots.txt /home/django/projects/elg/media/robots.txt 
> Alias /favicon.ico /home/django/projects/elg/media/favicon.ico 
> AliasMatch ^/([^/]*\.css) /home/django/projects/elg/media/css/$1 
> AliasMatch ^/([^/]*\.js) /home/django/projects/elg/media/js/$1 
> Alias /media/ /home/django/projects/elg/media/ 
>  
> Order deny,allow 
> Allow from all 
>  
> WSGIScriptAlias / /home/django/projects/elg/apache/elg.wsgi 
>  
> Order allow,deny 
> Allow from all 
>  
>  
>
>
>  
> ServerName www.domain2.com 
> ServerAdmin ***l...@gmail.com 
> Alias /robots.txt /home/django/projects/cc4h/media/robots.txt 
> Alias /favicon.ico /home/django/projects/cc4h/media/favicon.ico 
> AliasMatch ^/([^/]*\.css) /home/django/projects/cc4h/media/css/$1 
> AliasMatch ^/([^/]*\.js) /home/django/projects/cc4h/media/js/$1 
> Alias /media/ /home/django/projects/cc4h/media/ 
>  
> Order deny,allow 
> Allow from all 
>  
> WSGIScriptAlias / /home/django/projects/cc4h/apache/cc4h.wsgi 
>  
> Order allow,deny 
> Allow from all 
>  
>  
>
>

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



Re: 4 different domains on single apache/mod_wsgi

2011-01-19 Thread Kenneth Gonsalves
On Wed, 2011-01-19 at 16:56 -0800, Osiaq wrote:
> Hi Kenneth!
> Distro: Ubuntu Server 10.04 

well ubuntu follows the debian mode for setting up virtual hosts - you
have virtual hosts files in /etc/apache/sites-available and you symlink
them to /etc/apache/sites-enabled/. Here is a typical virtual host file:


ServerAdmin webmas...@xlquest.web
DocumentRoot /var/www/quadmulc/
ServerName quadmulc.web
ErrorLog logs/quadmulc-error_log
CustomLog logs/quadmulc-access_log common

Alias /media/ /home/lawgon/django-trunk/django/contrib/admin/media/
Alias /smedia/ /home/lawgon/smedia/
Alias /sitemedia/ /home/lawgon/quadmulc/sitemedia/

WSGIScriptAlias / /home/lawgon/quadmulc/apache/django.wsgi


Order deny,allow
Allow from all


Order deny,allow
Allow from all


Order deny,allow
Allow from all


-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread scabbage
Is there a way to completely disable CSRF handling?

Is there an documentation about how to create web services APIs using
Django without frontends?

Thanks.

On Jan 19, 3:26 pm, Andy McKay  wrote:
> > What if I wanna expose my views as web services without providing a
> > UI, how do I make sure clients (e.g. Ajax, actionscript, etc) can use
> > it without this CSRF issue?
>
> You can mark things as exempt if you'd like to and are aware of the 
> implications:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions
> --
>   Andy McKay
>   a...@clearwind.ca
>   twitter: @andymckay

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



[django-users] Custom signals

2011-01-19 Thread Piotr Zalewa
I'm trying to add custom signals to my models.
I'm sure I'm missing some step.

http://paste.pocoo.org/show/323618/

zalun
-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Search

2011-01-19 Thread delegbede
How do I insert a search field into a django page. 

I have looked through the documentation and couldn't get anything. 

I actually want to search for a phone number on a page where there are a lot of 
phone numbers. 

Kindly help. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Osiaq 
Sender: django-users@googlegroups.com
Date: Wed, 19 Jan 2011 16:49:19 
To: Django users
Reply-To: django-users@googlegroups.com
Subject: Re: Django + CSS

Same problem here. Follow those rules, is simple and is working
perfect.

http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html



On Jan 20, 1:58 am, "brian.mus...@ff.com"
 wrote:
> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here:http://docs.djangoproject.com/en/dev/howto/static-files/
> None of which actually ended up working for me and instead ended up
> using this:
>
> urlpatterns in urls.py:
> (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
>
> and then on my actual template page:
> 
>
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
> solution I ended up using which does work.
>
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc?  It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options.  I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common.  My two cents.

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

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



Re: 4 different domains on single apache/mod_wsgi

2011-01-19 Thread Osiaq
Hi Kenneth!
Distro: Ubuntu Server 10.04

As I said the firs site, ELG is working OK.
I just changed second site (cc4h) WSGI and it worked, printing "Hello
World!"
so domains are redirected OK. (please see code below)
But the website itself is not working, still can't find the template

Regards!

-
 /home/django/projects/cc4h/apache/cc4h.wsgi
-
#import os, sys
#sys.path.append('/home/django/projects')
#os.environ['DJANGO_SETTINGS_MODULE'] = 'cc4h.settings'
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()

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]


On Jan 20, 2:46 am, Kenneth Gonsalves  wrote:
> On Wed, 2011-01-19 at 16:20 -0800, Osiaq wrote:
> > It doesnt seems as easy as I thought it will be.
>
> it is as easy as falling of a log! If you can tell us what distro you
> are using we can point the way.
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django + CSS

2011-01-19 Thread Osiaq
Same problem here. Follow those rules, is simple and is working
perfect.

http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html



On Jan 20, 1:58 am, "brian.mus...@ff.com"
 wrote:
> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here:http://docs.djangoproject.com/en/dev/howto/static-files/
> None of which actually ended up working for me and instead ended up
> using this:
>
> urlpatterns in urls.py:
> (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
>
> and then on my actual template page:
> 
>
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
> solution I ended up using which does work.
>
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc?  It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options.  I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common.  My two cents.

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



Re: 4 different domains on single apache/mod_wsgi

2011-01-19 Thread Kenneth Gonsalves
On Wed, 2011-01-19 at 16:20 -0800, Osiaq wrote:
> It doesnt seems as easy as I thought it will be.

it is as easy as falling of a log! If you can tell us what distro you
are using we can point the way.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django + CSS

2011-01-19 Thread Eric Chamberlain
Unless you are trying to serve your CSS inline, which it doesn't appear to be 
the case from your post, why wouldn't you serve your CSS files like any other 
static file?  Serve the static file with your web server or CDN and put the url 
in the template, no magic required.

On Jan 19, 2011, at 3:58 PM, brian.mus...@ff.com wrote:

> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here: http://docs.djangoproject.com/en/dev/howto/static-files/
> None of which actually ended up working for me and instead ended up
> using this:
> 
> urlpatterns in urls.py:
> (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
> 
> and then on my actual template page:
> 
> 
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
> solution I ended up using which does work.
> 
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc?  It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options.  I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common.  My two cents.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Can someone help with Many-to-many referencing and then calculations against another field on the linked model

2011-01-19 Thread Kenneth Gonsalves
On Wed, 2011-01-19 at 22:34 +, The Stanley Household wrote:
> Happy to send Model if needed but at the moment I'm unable to run the
> server to provide admin error report, can C from terminal if that
> would help with the error. 

please copy and paste your code - it is easier for us to help when we
see what you are doing
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django + CSS

2011-01-19 Thread brian.mus...@ff0000.com
Is it me or does it blow your mind that there is not one standard way
of importing something as common as CSS files into Django templates?
I realize there are a plethora of options as mentioned on the official
site here: http://docs.djangoproject.com/en/dev/howto/static-files/
None of which actually ended up working for me and instead ended up
using this:

urlpatterns in urls.py:
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': '/Users/home/djcode/mysite/media/
css/','show_indexes' : True}),

and then on my actual template page:


I suppose I was feeling a little misdirected by the default
settings.py in my projects folder where CSS and other Media are
supposed to be stored.
ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
solution I ended up using which does work.

My main complaint is this - for something so common as importing CSS
into django templates - why not just make it painfully obvious in the
documentation/djangobook with one golden way of doing so - why does
everything have to be so modular, etc?  It starts to feel
counterproductive at a certain point - like why I am not just writing
this in python myself if there are going to be so many options.  I
think django could use a little tightening up. I understand it's loose
coupling ways, etc - but don't use that as a shield for something
possibly unfinished? The solution I ended up using felt like a hack
for something so common.  My two cents.

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



4 different domains on single apache/mod_wsgi

2011-01-19 Thread Osiaq
Hi all!
I have 2 separate projects, with 2 separate domains

The problem: first website, ELG, is working OK.
Another, cc4h, cannot find template index.html, but is working perfect
on localhost with Django development server.

Do you know any good tutorial regarding multiple domains on single
Apache?
It doesnt seems as easy as I thought it will be.

Thank you

Code:

Both WSGI files (projects ELG and CC4H):
-
 /home/django/projects/elg/apache/elg.wsgi
 /home/django/projects/cc4h/apache/cc4h.wsgi
-
import os, sys
sys.path.append('/home/django/projects')
os.environ['DJANGO_SETTINGS_MODULE'] = 'elg.settings' #for project
cc4h is 'cc4h.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


My httpd.conf:

NameVirtualHost *

ServerName www.domain1.com
ServerAdmin ***l...@gmail.com
Alias /robots.txt /home/django/projects/elg/media/robots.txt
Alias /favicon.ico /home/django/projects/elg/media/favicon.ico
AliasMatch ^/([^/]*\.css) /home/django/projects/elg/media/css/$1
AliasMatch ^/([^/]*\.js) /home/django/projects/elg/media/js/$1
Alias /media/ /home/django/projects/elg/media/

Order deny,allow
Allow from all

WSGIScriptAlias / /home/django/projects/elg/apache/elg.wsgi

Order allow,deny
Allow from all





ServerName www.domain2.com
ServerAdmin ***l...@gmail.com
Alias /robots.txt /home/django/projects/cc4h/media/robots.txt
Alias /favicon.ico /home/django/projects/cc4h/media/favicon.ico
AliasMatch ^/([^/]*\.css) /home/django/projects/cc4h/media/css/$1
AliasMatch ^/([^/]*\.js) /home/django/projects/cc4h/media/js/$1
Alias /media/ /home/django/projects/cc4h/media/

Order deny,allow
Allow from all

WSGIScriptAlias / /home/django/projects/cc4h/apache/cc4h.wsgi

Order allow,deny
Allow from all



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



Dynamic form and grouping elements

2011-01-19 Thread gregtrobertson
I have been trying to learn Django (and Python). 

I have a form that can have up to n elements. Each of those elements has 3 
parts to it (a TextField, a TagField and a Checkbox). The form init looks 
like this

def __init__(self, *args, **kwargs):

notesAndTags = kwargs.pop('notesAndTags')

super(NotesAndTagsForm, self).__init__(*args, **kwargs)
   
for i, tagandtext in enumerate(notesAndTags):
self.fields['tag_%s' % i] = TagField(initial = tagandtext.tag)
self.fields['text_%s' % i] = 
forms.CharField(widget=forms.Textarea, initial=tagandtext.text)
self.fields['import_%s' % i] = forms.BooleanField(initial=True) 


This is based on this explanation of dynamic 
formsand the form creates 
just fine. 

I need the fields displayed together (as they were created) so I have a 
checkbox, the Tag Field and the textarea all cleanly grouped.

The question is how do you then display that form using the correct tags?   

If I do a 
 Python Syntax (Toggle Plain 
Text
)
 

   1. {{ form }}
   
{{ form }}
 in the template how do I ensure that the fields are grouped together as 
they should be?  Should I override the as_table (or other method) to output 
as I see fit? 

Alternatively I can output each element (well I could) but I can't figure 
out how to access each at the same time because trying to use the formloop 
counter in an output tag produces an error.  I could zip the 3 lists into a 
single and output it using a loop BUT my concern is whether or not I could 
always guarantee that the zipped list would be present.

So what is the best practice around how to do this? 

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



Re: Error 'long' has no attribute provision

2011-01-19 Thread John
Thank you very much for your response.

I guess I should have realized the problem with the constructor.  The
'report_header' was a virtual record that was previously never written
to the database, I inherited the further development of this code and
I am still learning some of the details of python/django.

I did simplify the code slightly, the exception handling is a little
better than the code that I posted in that it returns an error
response, but thank you for the advice.


On Jan 19, 12:38 pm, Łukasz Rekucki  wrote:
> On 19 January 2011 18:06, John  wrote:
>
> > def reports_list(request, period_id)
> >   # some other irrelevant code
> >   try:
> >      reportheader=ReportHeader.objects.get(pk=1
> >   except Exception, e:
> >      pass
> >   return render_to_response("reports_list.html, locals(),
> > context_instance=RequestContext(request))
>
> 1) You don't want to modify __init__() of your model like this:
>
>   def __init__(self, request, *args, **kwargs)
>      self.provision=request.provision
>      self.period=self.provision.get_current_period()
>
> If the new constructor requires an additional "request", how does the
> ORM create instances of it ? It doesn't know anything about request.
> You can make a helper function. Or if you really want to be a part of
> the class, make an alternative constructor:
>
>    @classmethod
>    def from_provision(cls, provision):
>         instance = cls()
>         instance.provision = provision
>         instance.perio = provision.get_current_period()
>
>     # in your view code::
>
>     header = ReportHeader.from_provision(requrest.provision)
>
> 2) The moment you wrote "locals()" all the code in your view becomes
> relevant, because you're passing all the local variables to your
> template. This seems very popular amongst some groups, but I
> personally consider this not only bad style, but error-prone and
> possibly dangerous.
>
> 3) Catching exceptions like that most likely masks the real problem
> (Like the fact, that creating an instance of ReportHeader failed, due
> to buggy constructor). After all, you're rendering the template even
> if you failed to fetch the data you most likely need to render it.
>
> --
> Łukasz Rekucki

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



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Andy McKay
> What if I wanna expose my views as web services without providing a
> UI, how do I make sure clients (e.g. Ajax, actionscript, etc) can use
> it without this CSRF issue?

You can mark things as exempt if you'd like to and are aware of the 
implications:

http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions
--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

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



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread scabbage
How do I add CSRF token to curl then?

What if I wanna expose my views as web services without providing a
UI, how do I make sure clients (e.g. Ajax, actionscript, etc) can use
it without this CSRF issue?


Thanks.

On Jan 19, 4:14 am, Jirka Vejrazka  wrote:
> > However, when I tried this:
>
> >    $ curl -d "name=Bob"http://localhost:8000/demo/test
>
>   curl -d sends data using POST method, not GET method (see curl
> documentation). Django expects CSRF token in all POST requests, 
> checkhttp://docs.djangoproject.com/en/dev/ref/contrib/csrf/
>
>    HTH
>
>      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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to install Django on sitecloud.com

2011-01-19 Thread Javier Guerra Giraldez
On Wed, Jan 19, 2011 at 5:33 PM, Afke  wrote:
> "You just need to
> put your python scripts under cgi-bin folders and run them"

sounds like they allow one-shot python scripts but not long-running
python apps (like Django)

i think there's some hacky way to make it work; but performance would
be terrible, since it would restart everything for each and every HTTP
request.

-- 
Javier

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



How to install Django on sitecloud.com

2011-01-19 Thread Afke
Hi

How to install Django on sitecloud.com .I have Cloud Hosting account
python is installed.  I got msg from site operator "You just need to
put your python scripts under cgi-bin folders and run them"

Cloud Hosting account have ,Secure Shell (SSH)

I am little confused  I am new with Django but I realy love it .Any
help will help me a lot .

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



Can someone help with Many-to-many referencing and then calculations against another field on the linked model

2011-01-19 Thread The Stanley Household
Dear whoever is out there

This is my first e-mail to any kind of group.  I am also new to all the
concepts of programming, SQL, Python and Django.  I've worked quite hard
over the last six months to try an teach myself all these things.  I am
now writing an App and need some help with some calculating fields on my
model.  Although it would be nice to have someone just write the
required lines I would really like to know the concepts I'm missing.
I've trawled endless blogs and such like and although there is loads in
the Docs I can't quite seem to fathom the crux of my problem.

I have say class A with fields 1,2,3 say 3 = Decimal field
and then class B with fields 1,2,3 and say 3 =M2M field to A

I would like to pull into class B a calculation of class A.3 WHERE the
reference is linked in a row on class B.3

It maybe that there is only one reference on B.3 to A.3 but then again
there maybe 10 joins

Happy to send Model if needed but at the moment I'm unable to run the
server to provide admin error report, can C from terminal if that
would help with the error.

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



Re: Django Email

2011-01-19 Thread Eduardo Cereto Carvalho
django-mailer[1] is a nice application to have around if you're planning to
send too much emails. It queues messages and retry failled attempts.

[1]

On Wed, Jan 19, 2011 at 8:09 PM, Shawn Milochik  wrote:

> Whatever method you decide to use to gather the e-mail addresses is up to
> you, and depends on your needs.
>
> The send_mail function accepts a list of recipients, and it doesn't really
> matter how you get them.
>
> Two notes on sending e-mail, though:
>
> 1. Ensure that you're sending the e-mail multiple times (once to each
> person) to ensure privacy. Unless, for some reason, it's fine that all
> recipients get the e-mail addresses of the others.
>
> 2. SMTP communications are expensive, so you may want to go deeper than the
> send_mail function so you can create an SMTP connection and send multiple
> messages then include it. Otherwise you'll create a new SMTP connection for
> each message, which will take longer. Unless that's what you want.
>
> Shawn
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Eduardo Cereto Carvalho

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



Re: Django and google webmaster tools file

2011-01-19 Thread Martin Tiršel
Yes, you are right, this file is only for verification and not served  
regullary, so it is easier to add such urlpattern.


Martin

On Wed, 19 Jan 2011 22:36:37 +0100, Eduardo Cereto Carvalho  
 wrote:


Your static files probably already live in your MEDIA_URL and this file  
must

live in your root path.

As this is just a single file and won't be handled often you can take the
same approach I use when dealing with robots.txt. Keep in mind that this  
is

not a recomended way to serve static files but you can think about these
files as exceptions.

Add a line to your url conf with the path you want it to be on and create
the file as a template with only static content:

urlpatterns += patterns('django.views.generic.simple',
 (r'^robots.txt$', 'direct_to_template', {'template':'robots.txt',
'mimetype':'text/plain'}),
)


On Wed, Jan 19, 2011 at 5:03 PM, Martin Tiršel   
wrote:



This is a static file and should be served directly by webserver, so you
need to configure your webserver to provide this file (like other static
files but from another url).

It is possible to server it by Django too, then you are looking for
django.views.static.serve but It is not recommended.

Regards,
Martin Tirsel



On Wed, 19 Jan 2011 19:39:41 +0100, galago  wrote:

 How can I put a file, which is needed by the Google Webmasters Tool?  
Where

to put it or how to configure django to read it?



--
You received this message because you are subscribed to the Google  
Groups

"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.






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



Re: Django Email

2011-01-19 Thread Shawn Milochik
Whatever method you decide to use to gather the e-mail addresses is up 
to you, and depends on your needs.


The send_mail function accepts a list of recipients, and it doesn't 
really matter how you get them.


Two notes on sending e-mail, though:

1. Ensure that you're sending the e-mail multiple times (once to each 
person) to ensure privacy. Unless, for some reason, it's fine that all 
recipients get the e-mail addresses of the others.


2. SMTP communications are expensive, so you may want to go deeper than 
the send_mail function so you can create an SMTP connection and send 
multiple messages then include it. Otherwise you'll create a new SMTP 
connection for each message, which will take longer. Unless that's what 
you want.


Shawn

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



Re: Django and google webmaster tools file

2011-01-19 Thread Eduardo Cereto Carvalho
Your static files probably already live in your MEDIA_URL and this file must
live in your root path.

As this is just a single file and won't be handled often you can take the
same approach I use when dealing with robots.txt. Keep in mind that this is
not a recomended way to serve static files but you can think about these
files as exceptions.

Add a line to your url conf with the path you want it to be on and create
the file as a template with only static content:

urlpatterns += patterns('django.views.generic.simple',
 (r'^robots.txt$', 'direct_to_template', {'template':'robots.txt',
'mimetype':'text/plain'}),
)


On Wed, Jan 19, 2011 at 5:03 PM, Martin Tiršel  wrote:

> This is a static file and should be served directly by webserver, so you
> need to configure your webserver to provide this file (like other static
> files but from another url).
>
> It is possible to server it by Django too, then you are looking for
> django.views.static.serve but It is not recommended.
>
> Regards,
> Martin Tirsel
>
>
>
> On Wed, 19 Jan 2011 19:39:41 +0100, galago  wrote:
>
>  How can I put a file, which is needed by the Google Webmasters Tool? Where
>> to put it or how to configure django to read it?
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Eduardo Cereto Carvalho

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



Re: Django Template CSS Load Path

2011-01-19 Thread Matías Iturburu
On Wed, Jan 19, 2011 at 5:30 PM, Eduardo Cereto Carvalho <
eduardocer...@gmail.com> wrote:

> You can use MEDIA_URL conf to get the root path to your media files.
>
>  />
>
>
the above code is correct, just make sure that you are using the media
context processor or returning a RequestContext, not just plain Context.
Check out your settings.py for this one of this in the
TEMPLATE_CONTEXT_PROCESSORS constant.

'django.core.context_processors.request',
'django.core.context_processors.media',



>
> On Wed, Jan 19, 2011 at 5:55 PM, octopusgrabbus  > wrote:
>
>> I am trying to load a css file in my base.html template
>>
>> 
>>
>>
>>{% block title %}Test{% endblock %} 
>>
>>   
>>
>> What kind of path is supposed to go in the href? Is it relative to the
>> document root?
>>
>> Does anyone have an example of loading a css file including the Apache
>> configuration?
>>
>> Thanks.
>> cmn
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Eduardo Cereto Carvalho
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Matías Iturburu
http://www.linkedin.com/in/miturburu | http://ltmo.com.ar

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



Re: thumbnails and rackspace files

2011-01-19 Thread garagefan
easy thumbnails certainly does a decent job of creating thumbnails.
I'm not too fond of having a template tag do that though... it
basically does what i'm think of doing, but in a different area. it
also doesn't send the thumbnail over to cloudfiles, which is really
what i'm wanting to do, and without running syncstatic.

i'll take a look through easy thumbnail and see if there are any clues
for me... i should just have to override it's save functionality to
get what i need.

thanks for cumulus! its nicer having a specific backend for this
instead of one that is useful for multiples.. at this time anyway.

On Jan 19, 2:56 pm, Michel Thadeu Sabchuk  wrote:
> Hi,
>
> > setting up django-storages was simple...
>
> I recommend you to use django-cumulus [1] rather than django-storages.
> The first one is a rewrite made by the same author.
>
> > however... on the save of my gallery application i'm creating
> > thumbnails. this is easy to do with my custom field... normally.
> > django-storages doesnt work so well with this. So i need to come up
> > with a work around. My first thought was to grab the image from the
> > CDN server, open it with PIL, crop and create the thumbnail, save it
> > to my server, push it to my files server then delete the files on the
> > working server.
>
> Do you know django easy-thumbnails [2]? I think it will fit your
> needs.
>
> Feel free to contact me on private to share rackspace cloudfiles
> specific experiences ;)
>
> Best regards.
>
> [1]https://github.com/richleland/django-cumulus
> [2]https://github.com/SmileyChris/easy-thumbnails
>
> --
> Michel Sabchuk

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



Re: Django Template CSS Load Path

2011-01-19 Thread Eduardo Cereto Carvalho
You can use MEDIA_URL conf to get the root path to your media files.




On Wed, Jan 19, 2011 at 5:55 PM, octopusgrabbus
wrote:

> I am trying to load a css file in my base.html template
>
> 
>
>
>{% block title %}Test{% endblock %} 
>
>   
>
> What kind of path is supposed to go in the href? Is it relative to the
> document root?
>
> Does anyone have an example of loading a css file including the Apache
> configuration?
>
> Thanks.
> cmn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Eduardo Cereto Carvalho

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



Django Email

2011-01-19 Thread hank23
I'm in the process of coding the logic to send email through the
send_mail package of Django. My question is what's the best way to
support sending an email to multiple recipients? I had thought of
using a text box to enter each address individually and then having a
button click call a javascript function to concatenate the current
address input to the recipient list which it builds. But never having
done this before I thought I would ask if there was a better way that
I maybe hadn't thought of. Thanks for the help.

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



Re: thumbnails and rackspace files

2011-01-19 Thread Michel Thadeu Sabchuk
Hi,

> setting up django-storages was simple...

I recommend you to use django-cumulus [1] rather than django-storages.
The first one is a rewrite made by the same author.

> however... on the save of my gallery application i'm creating
> thumbnails. this is easy to do with my custom field... normally.
> django-storages doesnt work so well with this. So i need to come up
> with a work around. My first thought was to grab the image from the
> CDN server, open it with PIL, crop and create the thumbnail, save it
> to my server, push it to my files server then delete the files on the
> working server.

Do you know django easy-thumbnails [2]? I think it will fit your
needs.

Feel free to contact me on private to share rackspace cloudfiles
specific experiences ;)

Best regards.

[1] https://github.com/richleland/django-cumulus
[2] https://github.com/SmileyChris/easy-thumbnails

--
Michel Sabchuk

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



Django Template CSS Load Path

2011-01-19 Thread octopusgrabbus
I am trying to load a css file in my base.html template




{% block title %}Test{% endblock %} 

   

What kind of path is supposed to go in the href? Is it relative to the
document root?

Does anyone have an example of loading a css file including the Apache
configuration?

Thanks.
cmn

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



thumbnails and rackspace files

2011-01-19 Thread garagefan
setting up django-storages was simple... using rackspace's python API
to send an image to my container... met with some troubles (broken
pipe error on code that worked).

however... on the save of my gallery application i'm creating
thumbnails. this is easy to do with my custom field... normally.
django-storages doesnt work so well with this. So i need to come up
with a work around. My first thought was to grab the image from the
CDN server, open it with PIL, crop and create the thumbnail, save it
to my server, push it to my files server then delete the files on the
working server.

this seems like a lot of processes to be running and there has got to
be a simpler way. and my idea on injecting this code would be into a
signal, pre save, assuming that the file is written to the files
server prior to the item being saved. currently i have a custom field
extending the ImageField w/ an attr_class that extends the
ImageFieldFile. I'd prefer to run everything in the attr_class if
possible and would prefer to stay away from grabbing the image from
the public url and do modify the image and create the thumbnail along
the way.

i suppose i could go the simple route and and use css to alter the
main image.

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



Re: URLField strange error

2011-01-19 Thread galago
ModelForm:
class ArticleForm(ModelForm):
title = 
forms.CharField(widget=forms.TextInput(attrs={'class':'input_visible_title',
  'title' : 
_(u'Tytuł'),}), max_length=255, min_length=3)
content = 
forms.CharField(widget=forms.Textarea(attrs={'class':'add_editor'}), 
min_length=200)
image_proposal = 
forms.URLField(widget=forms.TextInput(attrs={'class':'input_visible_title',}), 
max_length=255, required=False, verify_exists=False)
tags_tmp = 
forms.CharField(widget=forms.TextInput(attrs={'class':'input_visible_title',}), 
max_length=255, min_length=1)
categories = 
forms.ModelMultipleChoiceField(queryset=Category.objects.all(), 
widget=forms.CheckboxSelectMultiple)
is_sketch = forms.BooleanField(required=False)
class Meta:
model = Article
fields = ('title', 'content', 'categories', 'tags_tmp', 
'image_proposal')

Model:
class Article(models.Model):

image_proposal = models.URLField(max_length=255, verify_exists=False, 
blank=True)


def save(self):
if not self.pk:
self.slug = slughifi(self.title)
super(Article, self).save()


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



Re: URLField strange error

2011-01-19 Thread Ian Clelland
On Wed, Jan 19, 2011 at 10:37 AM, galago  wrote:
> Django 1.2.4,
> Python 2.7
> All is coded as it should be. debugger shows error in python code as You
> said. Maybe it will be fixed in the future. Exception is only when i put [ .
> When i put [] all is ok :)

Yes, either a bare '[' or ']' in the URL hostname will trigger this error.

Oddly, the URLValidator in django.core.validators should be catching
the ValueError that is coming back from urllib2; Django should already
be handling this. How are you trying to insert the value? Is this
being handled through a ModelForm, or are you saving the model
manually?

Regards,
Ian Clelland


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



Re: Django and google webmaster tools file

2011-01-19 Thread Martin Tiršel
This is a static file and should be served directly by webserver, so you  
need to configure your webserver to provide this file (like other static  
files but from another url).


It is possible to server it by Django too, then you are looking for  
django.views.static.serve but It is not recommended.


Regards,
Martin Tirsel


On Wed, 19 Jan 2011 19:39:41 +0100, galago  wrote:

How can I put a file, which is needed by the Google Webmasters Tool?  
Where

to put it or how to configure django to read it?


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



Re: Django and google webmaster tools file

2011-01-19 Thread SQ9MEV
galago pisze:
> How can I put a file, which is needed by the Google Webmasters Tool? 
> Where to put it or how to configure django to read it?
AFAIR, you can add a DNS record or meta tag as well, meta tag coud be
placed in your template, probably base.html

-- 
Bartek

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



Django and google webmaster tools file

2011-01-19 Thread galago
How can I put a file, which is needed by the Google Webmasters Tool? Where 
to put it or how to configure django to read it?

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



Re: URLField strange error

2011-01-19 Thread galago
Django 1.2.4,
Python 2.7
All is coded as it should be. debugger shows error in python code as You 
said. Maybe it will be fixed in the future. Exception is only when i put [ . 
When i put [] all is ok :)

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



Pracovní nabídka

2011-01-19 Thread Plovarna
Ahojte,
v lednu mi končí roční smlouva, během které jsme v malém týmu budovali Django 
aplikaci pro zahraničního klienta. Protože se chci v budoucnu věnovat projektu 
Scuk.cz, smlouvu jsem už neprodlužoval.

Před odchodem jsem ještě kolegům slíbil, že jim s hledáním nového člověka 
pomůžu a proto přeposílám jejich nabídku:

Sháníme šikovné Djangonauty, kteří by nám pomohli 
s vývojem existujícího projektu (eshopový a skladový 
systém). Jedná se převážne o práci z domu, s občasnými 
schůzkami v Prostějově. Případným zájemcům pošlu víc 
informací.
Jan Munclinger, jan.munclin...@gmail.com

Za sebe můžu ještě dodat, že pracovní podmínky byly solidní, měli jsme volnost 
ve výběru technologií, mohli jsme pracovat z domu a s pěnězi to bylo taky dobré 
(zatím nejlukrativnější džob co jsem kdy měl). Zájemci by ale zároveň měli 
počítat s vysokým nasazením, protože projekt už je rozjetý a termíny stanoveny. 
Budou se muset rychle zorientovat a co nejdříve se aktivně zapojit do vývoje.

Pokud vás tato nabídka oslovila, ozvěte se přímo Honzovi Munclingerovi 
(jan.munclin...@gmail.com).


Michal Valoušek

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



Re: URLField strange error

2011-01-19 Thread Ian Clelland
On Wed, Jan 19, 2011 at 6:29 AM, galago  wrote:
> When I try to insert that string to urlfield: http://asd[d I get strange
> exception:
>
> Invalid IPv6 URL
>
> How to correct it to show message and not error 500?

You will likely need to post some more information: What version of
Django, and what version of Python are you using?

A very quick search suggests that this is a new exception emitted by
Python 2.7; Django's URLField tries to validate the url with an actual
network connection, using Python's urllib2.

The URL you are trying to insert may be just valid enough to get past
the regex checks, and is then parsed by Python as an IPv6 address, and
rejected.

I don't have python 2.7 installed anywhere to check this, but if true,
this may be a bug in Django: Either the regex checks should be
tightened, or the new exception should be caught in the URL Validator.

Without some more info, this is all speculation anyway, though.

Regards,
Ian Clelland


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



Re: URLField strange error

2011-01-19 Thread aa56280
Something's not right with the data. Can you post more details - like, what 
string are you trying to insert exactly?

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



Re: Error 'long' has no attribute provision

2011-01-19 Thread Łukasz Rekucki
On 19 January 2011 18:06, John  wrote:
> def reports_list(request, period_id)
>   # some other irrelevant code
>   try:
>      reportheader=ReportHeader.objects.get(pk=1
>   except Exception, e:
>      pass
>   return render_to_response("reports_list.html, locals(),
> context_instance=RequestContext(request))

1) You don't want to modify __init__() of your model like this:

  def __init__(self, request, *args, **kwargs)
 self.provision=request.provision
 self.period=self.provision.get_current_period()

If the new constructor requires an additional "request", how does the
ORM create instances of it ? It doesn't know anything about request.
You can make a helper function. Or if you really want to be a part of
the class, make an alternative constructor:

   @classmethod
   def from_provision(cls, provision):
instance = cls()
instance.provision = provision
instance.perio = provision.get_current_period()

# in your view code::

header = ReportHeader.from_provision(requrest.provision)

2) The moment you wrote "locals()" all the code in your view becomes
relevant, because you're passing all the local variables to your
template. This seems very popular amongst some groups, but I
personally consider this not only bad style, but error-prone and
possibly dangerous.

3) Catching exceptions like that most likely masks the real problem
(Like the fact, that creating an instance of ReportHeader failed, due
to buggy constructor). After all, you're rendering the template even
if you failed to fetch the data you most likely need to render it.

-- 
Łukasz Rekucki

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



Re: Inner classses

2011-01-19 Thread balu
Thank you sir.

On Jan 19, 10:12 pm, Tom Evans  wrote:
> On Wed, Jan 19, 2011 at 5:05 PM, balu  wrote:
> > Respected sir
>
> > I'm working to create an Online examination system using django. In
> > that concept there will be Question bank from which the Questions will
> > be created. I'm trying to implement this but I cannot access the
> > subclass - "Question" inside the "QuestionBank" class.
>
> > class QuestionBank(models.Model):
>
> >    subject=models.CharField(max_length=30)
>
> >    class Question():
>
> >        def __init__(self):
>
> >            question = models.CharField(max_length = 500)
> >            option_1 = models.CharField(max_length = 100)
> >            option_2 = models.CharField(max_length = 100)
> >            option_3 = models.CharField(max_length = 100)
> >            option_4 = models.CharField(max_length = 100)
>
> >            answer = models.CharField(max_length = 100)
>
> > Please letme know how to access the inner class through "Admin"
> > interface.
>
> > Looking forward to your reply
>
> Django model classes don't work like that. Explain what relationship
> you want between Question and QuestionBank - I imagine a QuestionBank
> object has many Question objects? In which case you want two separate
> classes, with Question having a ForeignKey field pointing at
> QuestionBank.
>
> See the docs for more information:
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#foreignkey
>
> Cheers
>
> Tom- Hide quoted text -
>
> - Show quoted text -

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



Error 'long' has no attribute provision

2011-01-19 Thread John
Background:
In a financial application I need to archive a set of reports at the
end of each reporting period, the model is reasonably complex but I
have 3 models of direct concern, a 'provision', 'period' and
'reportheader'.  The code is correctly generating the reports and they
are archived in a subdirectory under the media root and the
'reportheader' information in the MySQL database looks perfectly fine.

Problem is that I can not read the information back from the
database.  I have tried to read a single report header specifying the
pk=1 (MySQL Query return the record just fine) and get the error
reported in the subject line raised from the 'get'.  Of course what I
really want is to get the related set of reports from the period, but
the code to do that returns an empty querySet.

Model code:
class ReportHeader(models.Model):
   """comment"""
   provision = models.ForeignKey(Provision, null=False, blank=False)
   period = models.ForeignKey(Period, null=False, blank=False)
   report_name = models.CharField(max_length=100, null=False)
   # couple of othe field definitions
   saved_file = models.FileField(upload_to="reports", null=True,
blank=True)

   def __init__(self, request, *args, **kwargs)
  self.provision=request.provision
  self.period=self.provision.get_current_period()

Report Generation Code:
   filename, report = report_generator.report(request)
   report_header=ReportHeader(request)
   report_header.report_name=report_name
   load = InMemoryUploadedFile(file=report,
field_name=report_header.saved_file, name=filename,
content_type="application/pdf", size=report.tell(), charset=None)
   report_header.saved_file=load
   report_header.save()

Failing Code:
def reports_list(request, period_id)
   # some other irrelevant code
   try:
  reportheader=ReportHeader.objects.get(pk=1
   except Exception, e:
  pass
   return render_to_response("reports_list.html, locals(),
context_instance=RequestContext(request))

Sample database content:
  id  provision_idperiod_id
report_name  .   saved_file
  1   1   4 Net Income Per
Book reports/NIPBQ12010AllCompanies.pdf


Does anyone have a clue why the simple get is failing?

Thank You.

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



Re: Inner classses

2011-01-19 Thread Tom Evans
On Wed, Jan 19, 2011 at 5:05 PM, balu  wrote:
> Respected sir
>
> I'm working to create an Online examination system using django. In
> that concept there will be Question bank from which the Questions will
> be created. I'm trying to implement this but I cannot access the
> subclass - "Question" inside the "QuestionBank" class.
>
> class QuestionBank(models.Model):
>
>    subject=models.CharField(max_length=30)
>
>    class Question():
>
>        def __init__(self):
>
>            question = models.CharField(max_length = 500)
>            option_1 = models.CharField(max_length = 100)
>            option_2 = models.CharField(max_length = 100)
>            option_3 = models.CharField(max_length = 100)
>            option_4 = models.CharField(max_length = 100)
>
>            answer = models.CharField(max_length = 100)
>
> Please letme know how to access the inner class through "Admin"
> interface.
>
> Looking forward to your reply
>

Django model classes don't work like that. Explain what relationship
you want between Question and QuestionBank - I imagine a QuestionBank
object has many Question objects? In which case you want two separate
classes, with Question having a ForeignKey field pointing at
QuestionBank.

See the docs for more information:

http://docs.djangoproject.com/en/1.2/ref/models/fields/#foreignkey

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



Inner classses

2011-01-19 Thread balu
Respected sir

I'm working to create an Online examination system using django. In
that concept there will be Question bank from which the Questions will
be created. I'm trying to implement this but I cannot access the
subclass - "Question" inside the "QuestionBank" class.

class QuestionBank(models.Model):

subject=models.CharField(max_length=30)

class Question():

def __init__(self):

question = models.CharField(max_length = 500)
option_1 = models.CharField(max_length = 100)
option_2 = models.CharField(max_length = 100)
option_3 = models.CharField(max_length = 100)
option_4 = models.CharField(max_length = 100)

answer = models.CharField(max_length = 100)

Please letme know how to access the inner class through "Admin"
interface.

Looking forward to your reply

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



Re: Pinax: worth installing?

2011-01-19 Thread Jason
I've found the current state of Pinax to be a bit hard to use.

Yes, it offers these 'ready-to-use' projects but they do not work out
of the box. There are CSRF problems, they don't load the initial
sample data properly, and sometimes they just don't load at all.

This is the case at least when I use the pip installation. (oh which
btw I flat out couldn't get to work period on Windows)

Overall it leaves me very worried about beginning a serious project in
Pinax. I'll definitely check back again with it at the official 0.9
release but for now I remain weary.

On Jan 18, 5:26 am, ashdesigner  wrote:
> Guys, are there any considerable drawbacks of using Pinax for Django?
> Is it worth installing, or is it better to launch and develop on
> "pure" Django?

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



Django on IIS randomly changing LANGUAGE_CODE

2011-01-19 Thread Rodrigo Cea
I hava a Django production site on IIS 6.0.
The LANGUAGE_CODE is set to 'es-cl'
There are forms on the site. Sometimes the site seems to switch to
English, returning validation errors on dates written in dd/mm/
format. The errors themselves are in English (whereas they're normally
in Spanish).
This is random, and we have not been able to reproduce it on our
Development or Test servers.
Ideas?

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



Re: Pinax: worth installing?

2011-01-19 Thread bobhaugen
I've gone a couple of different ways on Pinax:

* I have built sites using Pinax pretty much as is, and Pinax heavily
customized.

* I have also built sites that did not start with Pinax, but added
several apps blessed by Pinax and using Pinax conventions.

Both approaches worked well.

By the way, Pinax now provides several ready-to-use projects out of
the box, not just a social project.  More coming all the time,
including (I hear) community-developed open source projects.

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



Re: slight model change makes app unusable

2011-01-19 Thread bruno desthuilliers
On 19 jan, 10:52, Santiago Caracol  wrote:
(snip)
> Whenever one wants to see the list of all (461) mobile phones in the
> admin interface, the development server becomes very slow and
> eventually breaks down with a memory error. Below is the class
> MobilePhone. What can I do?


>     def variants(self):
>         self.save()
>         paraphrases = self.paraphrase()
>         for paraphrase in paraphrases:
>             paraphrases.append(self.producer.name + ' ' + paraphrase)

modifying a list inplace while iterating over it is probably not a
good idea:

source = list("abc")
for item in source:
print item
source.append(item + item)
print source
if raw_input("got it ? ") == "ok":
break


a
['a', 'b', 'c', 'aa']
got it ? n
b
['a', 'b', 'c', 'aa', 'bb']
got it ? n
c
['a', 'b', 'c', 'aa', 'bb', 'cc']
got it ? n
aa
['a', 'b', 'c', 'aa', 'bb', 'cc', '']
got it ? n
bb
['a', 'b', 'c', 'aa', 'bb', 'cc', '', '']
got it ? n
cc
['a', 'b', 'c', 'aa', 'bb', 'cc', '', '', '']
got it ? n

['a', 'b', 'c', 'aa', 'bb', 'cc', '', '', '', '']
got it ? ok


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



Re: How to plug in Python: CGI

2011-01-19 Thread ashdesigner
Tonton,

Thank you for hint, I will take a look.

Anthony

On Jan 19, 4:19 pm, Tonton  wrote:
> so nobody is perfect !
>
> is mod_wsgi in apache for windows ?
>
> i think it is like in linux
> one virtual host point to your
> wsgi_handler.py but with \ instead
>
> look this first google result in wsgi apache django windows search :
>
> http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-fo...
>
> good luck
>
> tonton

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



Re: adding fields into another apps forms (in plugin style)

2011-01-19 Thread Shawn Milochik

You can just subclass the form or modelform.

Shawn

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



URLField strange error

2011-01-19 Thread galago
When I try to insert that string to urlfield: http://asd[d I get strange 
exception:

Invalid IPv6 URL



How to correct it to show message and not error 500?

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



Re: Pinax: worth installing?

2011-01-19 Thread ashdesigner
Dear all (and especially Russel!)))

Thank you so much for your efforts to clarify on the subject. Frankly,
I didn't expect THAT useful replies, indeed. Lot of things have been
given proper places.
In a nutshell, and in addition to what has been mentioned above, I am
wondering if there is some description of Django's best practices or
case studies in terms of a webproject layout. Although Django doesn't
force developers to follow one way or another, there should be some
description of how a good project SHOULD be designed.

Any suggestions?

Thanks again,
Anthony

On Jan 19, 4:28 pm, Ivan Uemlianin  wrote:
> Dear ashdesigner
>
> I haven't tried Pinax for a while but last time I did (June 2009) I
> got the impression that it was an all-or-nothing affair.  Pinax was
> marketing itself as a "social networking site in a box" and if that's
> what you wanted, it was a reasonable choice.  However, it turned out
> that I required only a few of the apps in pinax, and quite a few other
> apps not in pinax.  After some experimenting and toing and froing, I
> decided it would be much simpler to build something from scratch (of
> course with django these days "from scratch" is not really from
> scratch).
>
> If someone's objective was to learn about django, I don't think Pinax
> would be a good choice at all, partly because all the work has already
> been done for you.  Mingus might be better for that, as it was created
> as a case study of django applications working together.
>
> I second Cal Leeming's question: can anyone point to Pinax sites in
> the wild?
>
> Best wishes
>
> Ivan
>
> On Jan 19, 8:37 am, Oscar Carballal  wrote:
>
> > O Mar, 18-01-2011 ás 21:37 -0800, Gath escribiu:
>
> > > Magee,
>
> > > Wow! Now thats what we call a response.
>
> > > You made me understand this subject more.
>
> > > Thanks a lot Magee.
>
> > > Gath.
>
> > > On Jan 18, 5:32 pm, Russell Keith-Magee 
> > > wrote:
> > > > On Tue, Jan 18, 2011 at 9:43 PM, Cal Leeming [Simplicity Media Ltd]
>
> > > >  wrote:
> > > > > I would be interested to hear from anyone who has usedPinaxin 
> > > > > production.
> > > > > Although I am discouraged by the maturity (only 2 years old?), it 
> > > > > does seem
> > > > > to contain some useful features.
> > > > > Personally, I would have liked to have seen some of these features 
> > > > > merged
> > > > > into the Django core, rather than forked into a separate project, but 
> > > > > that's
> > > > > just me.
>
> > > > I think we need to clear up some misconceptions here.
> > > > [...]
> > > > However, for most "websitey" websites, this won't be an issue --
> > > >Pinax'sconventions are, for the most part, a bunch of practices that
> > > > you should probably be following anyway --Pinaxjust forces/provides
> > > > the tools to help you to follow them :-)
>
> > +1
>
> > I tried to usepinaxfor a project I'm developing right now and after a
> > while I decided to leave it and start from scratch. As Russ says,pinax
> > works pretty well if your needs follow the ones established bypinax
> > (social sites, intranets, etc.) but if you ever need other thing, or
> > just need an application frompinax, it's a pain to do it.
>
> > Pinaxteam is rewriting most of the code to meet some standard
> > conventions and make the applications less attached to thepinaxmain
> > code. Also, some of the bundled projects are completely outdated, though
> > they work well, but if you use one of those (for example the social
> > site, it's the most outdated) you'll probably need to do a lot of
> > improvements on your own).
>
> > If you want to trypinaxtry the development version (it's two versions
> > ahead of the stable), they are doing a good work.
>
> > Regards,
> > Oscar Carballal

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



Re: Pinax: worth installing?

2011-01-19 Thread Ivan Uemlianin
Dear ashdesigner

I haven't tried Pinax for a while but last time I did (June 2009) I
got the impression that it was an all-or-nothing affair.  Pinax was
marketing itself as a "social networking site in a box" and if that's
what you wanted, it was a reasonable choice.  However, it turned out
that I required only a few of the apps in pinax, and quite a few other
apps not in pinax.  After some experimenting and toing and froing, I
decided it would be much simpler to build something from scratch (of
course with django these days "from scratch" is not really from
scratch).

If someone's objective was to learn about django, I don't think Pinax
would be a good choice at all, partly because all the work has already
been done for you.  Mingus might be better for that, as it was created
as a case study of django applications working together.

I second Cal Leeming's question: can anyone point to Pinax sites in
the wild?

Best wishes

Ivan


On Jan 19, 8:37 am, Oscar Carballal  wrote:
> O Mar, 18-01-2011 ás 21:37 -0800, Gath escribiu:
>
>
>
> > Magee,
>
> > Wow! Now thats what we call a response.
>
> > You made me understand this subject more.
>
> > Thanks a lot Magee.
>
> > Gath.
>
> > On Jan 18, 5:32 pm, Russell Keith-Magee 
> > wrote:
> > > On Tue, Jan 18, 2011 at 9:43 PM, Cal Leeming [Simplicity Media Ltd]
>
> > >  wrote:
> > > > I would be interested to hear from anyone who has usedPinaxin 
> > > > production.
> > > > Although I am discouraged by the maturity (only 2 years old?), it does 
> > > > seem
> > > > to contain some useful features.
> > > > Personally, I would have liked to have seen some of these features 
> > > > merged
> > > > into the Django core, rather than forked into a separate project, but 
> > > > that's
> > > > just me.
>
> > > I think we need to clear up some misconceptions here.
> > > [...]
> > > However, for most "websitey" websites, this won't be an issue --
> > >Pinax'sconventions are, for the most part, a bunch of practices that
> > > you should probably be following anyway --Pinaxjust forces/provides
> > > the tools to help you to follow them :-)
>
> +1
>
> I tried to usepinaxfor a project I'm developing right now and after a
> while I decided to leave it and start from scratch. As Russ says,pinax
> works pretty well if your needs follow the ones established bypinax
> (social sites, intranets, etc.) but if you ever need other thing, or
> just need an application frompinax, it's a pain to do it.
>
> Pinaxteam is rewriting most of the code to meet some standard
> conventions and make the applications less attached to thepinaxmain
> code. Also, some of the bundled projects are completely outdated, though
> they work well, but if you use one of those (for example the social
> site, it's the most outdated) you'll probably need to do a lot of
> improvements on your own).
>
> If you want to trypinaxtry the development version (it's two versions
> ahead of the stable), they are doing a good work.
>
> Regards,
> Oscar Carballal

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



Re: How to plug in Python: CGI

2011-01-19 Thread Tonton
so nobody is perfect !

is mod_wsgi in apache for windows ?

i think it is like in linux
one virtual host point to your
wsgi_handler.py but with \ instead

look this first google result in wsgi apache django windows search :

http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-for-apache-and-django-on-windows/

good luck

tonton

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



Re: How to plug in Python: CGI

2011-01-19 Thread ashdesigner
Graham,

Thanks, but I'm running Windows.

Anthony

On Jan 19, 12:24 am, Graham Dumpleton 
wrote:
> On Wednesday, January 19, 2011 12:52:14 AM UTC+11, tonton wrote:
>
> > now it is seems to be mod_wsgi
>
> > in apache/conf.d/ yoursite.conf
>
> >  WSGIScriptAlias / /path/to/your/djangoproject/wsgi_handler.py
>
> >        WSGIDaemonProcess djangoproject user=CCC group=CCC processes=5
> > threads=1
> >        WSGIProcessGroup djangoproject  
>
> They are on Windows so they can't use mod_wsgi daemon mode.
>
> The best choice for Python web hosting would be not to use Windows in the
> first place. ;-)
>
> Graham
>
> > and had to write an wsgi_handler in djangoproject root where you have
> > settings.py like
>
> > import sys
> > import os
> > sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'Djangoproject.settings'
>
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > things to replace DjangoProject by the name of your project !
> > / is your web root
> > so no other path will work instead  you add an alias for apache
>
> > Alias /aOtherPath/ /taget/to/a/OtehrPater/
>
> > tonton
>
> > On Tue, Jan 18, 2011 at 2:22 PM, ashdesigner  wrote:
>
> >> Hello,
>
> >> On my VPS, I've got Apache running on MS Windows Server 2008 R2. What
> >> is the best way you suggest to plug in Python to be used in a
> >> relatively highly loaded webproject (on Django)? mod_python,
> >> fastCGI?... What are advantages and drawbacks, from your real
> >> experience? I'm new to both Python and Django, so I would appreciate
> >> how-tos as well (particular urls to faqs/docs will do, of course).
>
> >> Thanks,
> >> Anthony
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users...@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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Martin Pajuste
curl -d "name=Bob" -G http://localhost:8000/demo/test 

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



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Martin Pajuste
-d flag sends the specified data in a POST request to the HTTP server, since 
you don't supply CSRF token, Django assumes the post is malicious.
See more http://docs.djangoproject.com/en/dev/ref/contrib/csrf/?from=olddocs

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



Re: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Jirka Vejrazka
> However, when I tried this:
>
>    $ curl -d "name=Bob" http://localhost:8000/demo/test

  curl -d sends data using POST method, not GET method (see curl
documentation). Django expects CSRF token in all POST requests, check
http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

   HTH

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Oh, i've manage to run:

SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) >
1)

using ORM, but that's not what i want. The results vary.

If you're interested:

z = Comment.objects.all()
z.query.group_by = ['message']
z = z.annotate(num_messages=Count('message')).filter(num_messages__gt
= 1)

But results vary with the query in my first statement. Or, maybe i'm
not doing it right.

On 19 янв, 14:58, "[CPR]-AL.exe"  wrote:
> Oh, no, that wouldn't work with CharField. Or, maybe I'm doing
> something wrong.
>
> About a queryset - I mistaken aggregate() for annotate().
>
> On 19 янв, 14:52, "[CPR]-AL.exe"  wrote:
>
>
>
>
>
>
>
> > Wait, wat... o.O I'l try that now, thx.
>
> > On Wed, Jan 19, 2011 at 2:50 PM, Tom Evans  wrote:
> > > On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe 
> > > wrote:
> > > > Hmm, yeah, but that still iterates over the objects and filters out
> > > > them by count on the application server, not on the database one :(
>
> > > > I'm bypassing it already in my running project, but I try to avoid
> > > > using raw sql as longer as it is possible. So, the question, actually
> > > > remains open.
>
> > > > It should go something like [pseudo-code]:
>
> > > Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tab
> > >  lefield__count__gte
> > > > = 1)
>
> > > > But, of course, that wouldn't work, because annotate's return value is
> > > > not a queryset :(
>
> > > Er, says who?
>
> > > Organization.objects.annotate(num_grps=Count('usergroup')).filter(num_grps_
> > >  _gt=2).values_list('id',
> > > flat=True)
> > > [6L, 36L, 19L, 20L, 24L, 32L, 33L, 35L]
>
> > > 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-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com > >  groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Sincerely yours, Alexey.

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



Re: len(qs.all()) != qs.count()

2011-01-19 Thread Martin Pajuste
I would say the problem is in your model. Notice in the beginning of the SQL 
there is "productdescriptions"."id" yet there is no such field in database. 
Just specify 
primary_key=Trueon
 one of your fields.

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



it is user accounts

2011-01-19 Thread vidhya shree
Django comes with a user authentication system. It handles user
accounts, groups, permissions and cookie-based user sessions. This
document explains how things work.

 http://123maza.com/75/daily119/

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



"CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread scabbage
I'm new to Django. I have installed the latest Django and completed
the four-page tutorial. I created a very simple view as below:


from django.http import HttpResponse

def test(request):
return HttpResponse('My name is ' + request.GET['name'])


I'm able to navigate to "http://localhost:8000/demo/test?name=Bob; and
get the following response:

My name is Bob


However, when I tried this:

$ curl -d "name=Bob" http://localhost:8000/demo/test


I got some errors like this:


Forbidden (403)
CSRF verification failed. Request aborted.

Help
Reason given for failure:
No CSRF or session cookie.

...


Does anyone have any ideas?

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Oh, no, that wouldn't work with CharField. Or, maybe I'm doing
something wrong.

About a queryset - I mistaken aggregate() for annotate().

On 19 янв, 14:52, "[CPR]-AL.exe"  wrote:
> Wait, wat... o.O I'l try that now, thx.
>
>
>
>
>
>
>
>
>
> On Wed, Jan 19, 2011 at 2:50 PM, Tom Evans  wrote:
> > On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe 
> > wrote:
> > > Hmm, yeah, but that still iterates over the objects and filters out
> > > them by count on the application server, not on the database one :(
>
> > > I'm bypassing it already in my running project, but I try to avoid
> > > using raw sql as longer as it is possible. So, the question, actually
> > > remains open.
>
> > > It should go something like [pseudo-code]:
>
> > Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tab 
> > lefield__count__gte
> > > = 1)
>
> > > But, of course, that wouldn't work, because annotate's return value is
> > > not a queryset :(
>
> > Er, says who?
>
> > Organization.objects.annotate(num_grps=Count('usergroup')).filter(num_grps_ 
> > _gt=2).values_list('id',
> > flat=True)
> > [6L, 36L, 19L, 20L, 24L, 32L, 33L, 35L]
>
> > 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-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Sincerely yours, Alexey.

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Wait, wat... o.O I'l try that now, thx.

On Wed, Jan 19, 2011 at 2:50 PM, Tom Evans  wrote:

> On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe 
> wrote:
> > Hmm, yeah, but that still iterates over the objects and filters out
> > them by count on the application server, not on the database one :(
> >
> > I'm bypassing it already in my running project, but I try to avoid
> > using raw sql as longer as it is possible. So, the question, actually
> > remains open.
> >
> > It should go something like [pseudo-code]:
> >
> >
> Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tablefield__count__gte
> > = 1)
> >
> > But, of course, that wouldn't work, because annotate's return value is
> > not a queryset :(
> >
>
> Er, says who?
>
> >>>
> Organization.objects.annotate(num_grps=Count('usergroup')).filter(num_grps__gt=2).values_list('id',
> flat=True)
> [6L, 36L, 19L, 20L, 24L, 32L, 33L, 35L]
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Sincerely yours, Alexey.

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread Tom Evans
On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe  wrote:
> Hmm, yeah, but that still iterates over the objects and filters out
> them by count on the application server, not on the database one :(
>
> I'm bypassing it already in my running project, but I try to avoid
> using raw sql as longer as it is possible. So, the question, actually
> remains open.
>
> It should go something like [pseudo-code]:
>
> Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tablefield__count__gte
> = 1)
>
> But, of course, that wouldn't work, because annotate's return value is
> not a queryset :(
>

Er, says who?

>>> Organization.objects.annotate(num_grps=Count('usergroup')).filter(num_grps__gt=2).values_list('id',
>>>  flat=True)
[6L, 36L, 19L, 20L, 24L, 32L, 33L, 35L]

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
But that, again, includes executing raw sql =) And a lot of side-
queries, btw.

On 19 янв, 14:33, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Here's something you could do.
>
> Execute the raw SQL to bring back just the id's, then whilst iterating over
> that, if you need to grab the ORM'd row, just do "row_orm =
> model.get(id=iterated_id_here)"
>
> This is what I tend to do for raw sql queries.
>
>
>
>
>
>
>
> On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe  wrote:
> > Hmm, yeah, but that still iterates over the objects and filters out
> > them by count on the application server, not on the database one :(
>
> > I'm bypassing it already in my running project, but I try to avoid
> > using raw sql as longer as it is possible. So, the question, actually
> > remains open.
>
> > It should go something like [pseudo-code]:
>
> > Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tab 
> > lefield__count__gte
> > = 1)
>
> > But, of course, that wouldn't work, because annotate's return value is
> > not a queryset :(
>
> > On 19 янв, 14:18, "Cal Leeming [Simplicity Media Ltd]"
> >  wrote:
> > > Yeah you should be able to use annotate, something like:
>
> > > from django.db.models import Count
> > > res =
>
> > Book.objects.values('tablefield').annotate(Count('tablefield')).order_by('t
> > ablefield')
> > > res2 = filter(lambda x: x.tablefield__count > 1, res)
>
> > > The above is probably not going to work first time, but it would be
> > > something along those lines most likely.
>
> > > I would suggest that for complex queries, bypassing the ORM isn't
> > > necessarily a bad thing, and there are many cases where a developer will
> > > purposely bypass the ORM at bottlenecks and directly query SQL for
> > > optimization.
>
> > > On Wed, Jan 19, 2011 at 11:07 AM, [CPR]-AL.exe 
> > wrote:
> > > > Umm... Don't know, actually. That seems, that it would be okay, too. Is
> > > > there a way to execute this one using ORM?
>
> > > > On Wed, Jan 19, 2011 at 2:04 PM, Cal Leeming [Simplicity Media Ltd] <
> > > > cal.leem...@simplicitymedialtd.co.uk> wrote:
>
> > > >> May I ask why you didn't just use:
>
> > > >> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) >
> > 1)
>
> > > >> On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe  > >wrote:
>
> > > >>> Hi there.
>
> > > >>> I'm trying to do something like this:
>
> > > >>> SELECT *
> > > >>> FROM table
> > > >>> WHERE tablefield IN (
> > > >>>  SELECT tablefield
> > > >>>  FROM table
> > > >>>  GROUP BY tablefield
> > > >>>  HAVING (COUNT(tablefield ) > 1)
> > > >>> )
>
> > > >>> Tried it in many ways, but didn't suceed. Is there a way to do it
> > with
> > > >>> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
> > > >>> To unsubscribe from this group, send email to
> > > >>> django-users+unsubscr...@googlegroups.com > > >>>  groups.com>
> > 
> > > >>> .
> > > >>> For more options, visit this group at
> > > >>>http://groups.google.com/group/django-users?hl=en.
>
> > > > --
> > > > Sincerely yours, Alexey.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread Cal Leeming [Simplicity Media Ltd]
Here's something you could do.

Execute the raw SQL to bring back just the id's, then whilst iterating over
that, if you need to grab the ORM'd row, just do "row_orm =
model.get(id=iterated_id_here)"

This is what I tend to do for raw sql queries.

On Wed, Jan 19, 2011 at 11:26 AM, [CPR]-AL.exe  wrote:

> Hmm, yeah, but that still iterates over the objects and filters out
> them by count on the application server, not on the database one :(
>
> I'm bypassing it already in my running project, but I try to avoid
> using raw sql as longer as it is possible. So, the question, actually
> remains open.
>
> It should go something like [pseudo-code]:
>
>
> Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tablefield__count__gte
> = 1)
>
> But, of course, that wouldn't work, because annotate's return value is
> not a queryset :(
>
> On 19 янв, 14:18, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
> > Yeah you should be able to use annotate, something like:
> >
> > from django.db.models import Count
> > res =
> >
> Book.objects.values('tablefield').annotate(Count('tablefield')).order_by('t
> ablefield')
> > res2 = filter(lambda x: x.tablefield__count > 1, res)
> >
> > The above is probably not going to work first time, but it would be
> > something along those lines most likely.
> >
> > I would suggest that for complex queries, bypassing the ORM isn't
> > necessarily a bad thing, and there are many cases where a developer will
> > purposely bypass the ORM at bottlenecks and directly query SQL for
> > optimization.
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jan 19, 2011 at 11:07 AM, [CPR]-AL.exe 
> wrote:
> > > Umm... Don't know, actually. That seems, that it would be okay, too. Is
> > > there a way to execute this one using ORM?
> >
> > > On Wed, Jan 19, 2011 at 2:04 PM, Cal Leeming [Simplicity Media Ltd] <
> > > cal.leem...@simplicitymedialtd.co.uk> wrote:
> >
> > >> May I ask why you didn't just use:
> >
> > >> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) >
> 1)
> >
> > >> On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe  >wrote:
> >
> > >>> Hi there.
> >
> > >>> I'm trying to do something like this:
> >
> > >>> SELECT *
> > >>> FROM table
> > >>> WHERE tablefield IN (
> > >>>  SELECT tablefield
> > >>>  FROM table
> > >>>  GROUP BY tablefield
> > >>>  HAVING (COUNT(tablefield ) > 1)
> > >>> )
> >
> > >>> Tried it in many ways, but didn't suceed. Is there a way to do it
> with
> > >>> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
> > >>> To unsubscribe from this group, send email to
> > >>> django-users+unsubscr...@googlegroups.com
> 
> > >>> .
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > Sincerely yours, Alexey.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Hmm, yeah, but that still iterates over the objects and filters out
them by count on the application server, not on the database one :(

I'm bypassing it already in my running project, but I try to avoid
using raw sql as longer as it is possible. So, the question, actually
remains open.

It should go something like [pseudo-code]:

Book.objects.values('tablefield').annotate(Count('tablefield')).filter('tablefield__count__gte
= 1)

But, of course, that wouldn't work, because annotate's return value is
not a queryset :(

On 19 янв, 14:18, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Yeah you should be able to use annotate, something like:
>
> from django.db.models import Count
> res =
> Book.objects.values('tablefield').annotate(Count('tablefield')).order_by('t 
> ablefield')
> res2 = filter(lambda x: x.tablefield__count > 1, res)
>
> The above is probably not going to work first time, but it would be
> something along those lines most likely.
>
> I would suggest that for complex queries, bypassing the ORM isn't
> necessarily a bad thing, and there are many cases where a developer will
> purposely bypass the ORM at bottlenecks and directly query SQL for
> optimization.
>
>
>
>
>
>
>
> On Wed, Jan 19, 2011 at 11:07 AM, [CPR]-AL.exe  wrote:
> > Umm... Don't know, actually. That seems, that it would be okay, too. Is
> > there a way to execute this one using ORM?
>
> > On Wed, Jan 19, 2011 at 2:04 PM, Cal Leeming [Simplicity Media Ltd] <
> > cal.leem...@simplicitymedialtd.co.uk> wrote:
>
> >> May I ask why you didn't just use:
>
> >> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) > 1)
>
> >> On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe wrote:
>
> >>> Hi there.
>
> >>> I'm trying to do something like this:
>
> >>> SELECT *
> >>> FROM table
> >>> WHERE tablefield IN (
> >>>  SELECT tablefield
> >>>  FROM table
> >>>  GROUP BY tablefield
> >>>  HAVING (COUNT(tablefield ) > 1)
> >>> )
>
> >>> Tried it in many ways, but didn't suceed. Is there a way to do it with
> >>> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> django-users+unsubscr...@googlegroups.com >>>  groups.com>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Sincerely yours, Alexey.

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread Cal Leeming [Simplicity Media Ltd]
Yeah you should be able to use annotate, something like:

from django.db.models import Count
res =
Book.objects.values('tablefield').annotate(Count('tablefield')).order_by('tablefield')
res2 = filter(lambda x: x.tablefield__count > 1, res)

The above is probably not going to work first time, but it would be
something along those lines most likely.

I would suggest that for complex queries, bypassing the ORM isn't
necessarily a bad thing, and there are many cases where a developer will
purposely bypass the ORM at bottlenecks and directly query SQL for
optimization.

On Wed, Jan 19, 2011 at 11:07 AM, [CPR]-AL.exe  wrote:

> Umm... Don't know, actually. That seems, that it would be okay, too. Is
> there a way to execute this one using ORM?
>
>
> On Wed, Jan 19, 2011 at 2:04 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> May I ask why you didn't just use:
>>
>> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) > 1)
>>
>> On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe wrote:
>>
>>> Hi there.
>>>
>>> I'm trying to do something like this:
>>>
>>> SELECT *
>>> FROM table
>>> WHERE tablefield IN (
>>>  SELECT tablefield
>>>  FROM table
>>>  GROUP BY tablefield
>>>  HAVING (COUNT(tablefield ) > 1)
>>> )
>>>
>>> Tried it in many ways, but didn't suceed. Is there a way to do it with
>>> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>
>
> --
> Sincerely yours, Alexey.
>

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Umm... Don't know, actually. That seems, that it would be okay, too. Is
there a way to execute this one using ORM?

On Wed, Jan 19, 2011 at 2:04 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> May I ask why you didn't just use:
>
> SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) > 1)
>
> On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe wrote:
>
>> Hi there.
>>
>> I'm trying to do something like this:
>>
>> SELECT *
>> FROM table
>> WHERE tablefield IN (
>>  SELECT tablefield
>>  FROM table
>>  GROUP BY tablefield
>>  HAVING (COUNT(tablefield ) > 1)
>> )
>>
>> Tried it in many ways, but didn't suceed. Is there a way to do it with
>> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>


-- 
Sincerely yours, Alexey.

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread Cal Leeming [Simplicity Media Ltd]
May I ask why you didn't just use:

SELECT id from table GROUP BY tablefield HAVING (COUNT(tablefield) > 1)

On Wed, Jan 19, 2011 at 11:02 AM, [CPR]-AL.exe  wrote:

> Hi there.
>
> I'm trying to do something like this:
>
> SELECT *
> FROM table
> WHERE tablefield IN (
>  SELECT tablefield
>  FROM table
>  GROUP BY tablefield
>  HAVING (COUNT(tablefield ) > 1)
> )
>
> Tried it in many ways, but didn't suceed. Is there a way to do it with
> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
To make it more clear: I have something like a forum and want to find
duplicate messages (meaing the message field should be identical) to
create a report for the moderator.

On 19 янв, 14:02, "[CPR]-AL.exe"  wrote:
> Hi there.
>
> I'm trying to do something like this:
>
> SELECT *
> FROM table
> WHERE tablefield IN (
>  SELECT tablefield
>  FROM table
>  GROUP BY tablefield
>  HAVING (COUNT(tablefield ) > 1)
> )
>
> Tried it in many ways, but didn't suceed. Is there a way to do it with
> Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Is there a way to find objects with duplicate values for some field using ORM?

2011-01-19 Thread [CPR]-AL.exe
Hi there.

I'm trying to do something like this:

SELECT *
FROM table
WHERE tablefield IN (
 SELECT tablefield
 FROM table
 GROUP BY tablefield
 HAVING (COUNT(tablefield ) > 1)
)

Tried it in many ways, but didn't suceed. Is there a way to do it with
Django ORM without having to iterate over objects or using 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



slight model change makes app unusable

2011-01-19 Thread Santiago Caracol
Hello,

I have got a model MobilePhone that has a producer, such as "alcatel",
a canonical name, such as "b-500 s" and a paraphrase type, such as
"a-341 i".  Each instance of MobilePhone is supposed to calculate all
its variants (such as alcatel b-500 s, alcatel b 500 s, alcatel b-500-
s, b-500 s, b 500 s, b-500-s, and so on). This worked perfectly as
long as the producer wasn't a field of its own, but part of the
canonical name. Since I introduced producer names (in order to
simplify the paraphrase types and to allow for variants of producer
names (cf. HP, Hewlett Packard and so on), the app became unusable:
Whenever one wants to see the list of all (461) mobile phones in the
admin interface, the development server becomes very slow and
eventually breaks down with a memory error. Below is the class
MobilePhone. What can I do?

##

class MobilePhone(models.Model):

producer = models.ForeignKey(MobilePhoneProducer)
canonical_name = models.CharField(max_length=200)
paraphrase_type = models.CharField(max_length=50, choices=(
('n-127', 'n-127'),
('a-341 i', 'a-341 i'),
('neotouch', 'neotouch'),
))
lexical_variants = models.ManyToManyField(LexicalVariant,
blank=True)
n127_rx = re.compile('^(?P[a-z]+)\-(?P[0-9]+)$')
a341_i_rx = re.compile('^(?P[a-z]+)\-(?P[0-9]+) (?
P[a-z])$')
neotouch_rx = re.compile('^(?P[a-z]+)$')

def save(self, *args, **kwargs):
self.canonical_name =
whitespace_normalize(self.canonical_name)
super(MobilePhone, self).save(*args, **kwargs)

def __unicode__(self):
return self.canonical_name

def variants(self):
self.save()
paraphrases = self.paraphrase()
for paraphrase in paraphrases:
paraphrases.append(self.producer.name + ' ' + paraphrase)
for variant in self.lexical_variants.all():
paraphrases.append(variant)
paraphrases.append(self.producer.name + ' ' + variant)
if paraphrases:
return ', '.join(paraphrases)
else:
return '(The paraphrase type doesn
\'t seem to match.)'
variants.allow_tags = True

def the_lexical_variants(self):
return ', '.join(self.lexical_variants.all())

the_lexical_variants.short_description = "Lexical variants"

def paraphrase(self):
if self.paraphrase_type == 'n-127':
test = self.n127_rx.search(self.canonical_name)
if test:
chars = test.group('chars')
numb = test.group('numb')
return [
chars + '-' + numb,
chars + numb,
chars + ' ' + numb,
]
elif self.paraphrase_type == 'a-341 i':
test = self.a341_i_rx.search(self.canonical_name)
if test:
chars1 = test.group('chars1')
chars2 = test.group('chars2')
numb = test.group('numb')
return [
chars1 + '-' + numb + ' ' + chars2,
chars1 + ' ' + numb + ' ' + chars2,
chars1 + numb + ' ' + chars2,
chars1 + '-' + numb + '-' + chars2,
chars1 + ' ' + numb + '-' + chars2,
chars1 + numb + '-' + chars2,
chars1 + '-' + numb + chars2,
chars1 + ' ' + numb + chars2,
chars1 + numb + chars2,
]
elif self.paraphrase_type == 'neotouch':
test = self.neotouch_rx.search(self.canonical_name)
if test:
gmodel = test.group('model')
return [
gmodel,
]
return []

###

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



Re: Pinax: worth installing?

2011-01-19 Thread Oscar Carballal
O Mar, 18-01-2011 ás 21:37 -0800, Gath escribiu:
> Magee,
> 
> Wow! Now thats what we call a response.
> 
> You made me understand this subject more.
> 
> Thanks a lot Magee.
> 
> Gath.
> 
> On Jan 18, 5:32 pm, Russell Keith-Magee 
> wrote:
> > On Tue, Jan 18, 2011 at 9:43 PM, Cal Leeming [Simplicity Media Ltd]
> >
> >  wrote:
> > > I would be interested to hear from anyone who has used Pinax in 
> > > production.
> > > Although I am discouraged by the maturity (only 2 years old?), it does 
> > > seem
> > > to contain some useful features.
> > > Personally, I would have liked to have seen some of these features merged
> > > into the Django core, rather than forked into a separate project, but 
> > > that's
> > > just me.
> >
> > I think we need to clear up some misconceptions here.

> > [...]

> > However, for most "websitey" websites, this won't be an issue --
> > Pinax's conventions are, for the most part, a bunch of practices that
> > you should probably be following anyway -- Pinax just forces/provides
> > the tools to help you to follow them :-)

+1

I tried to use pinax for a project I'm developing right now and after a
while I decided to leave it and start from scratch. As Russ says, pinax
works pretty well if your needs follow the ones established by pinax
(social sites, intranets, etc.) but if you ever need other thing, or
just need an application from pinax, it's a pain to do it.

Pinax team is rewriting most of the code to meet some standard
conventions and make the applications less attached to the pinax main
code. Also, some of the bundled projects are completely outdated, though
they work well, but if you use one of those (for example the social
site, it's the most outdated) you'll probably need to do a lot of
improvements on your own).

If you want to try pinax try the development version (it's two versions
ahead of the stable), they are doing a good work.

Regards,
Oscar Carballal

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



Re: adding fields into another apps forms (in plugin style)

2011-01-19 Thread Marc Aymerich
On Wed, Jan 19, 2011 at 3:00 AM, Michael Buckley  wrote:
> I have been looking at the docs, but so far I can't find anything to help.
> I am looking to set up some kind of plugin system, so for example I set up
> my base user registration form, then I might have another app that when
> added to INSTALLED_APPS automatically adds fields into that form.
>
> Been looking in django for a way of easily injecting those extra fields into
> the form, but I can't find anything.  Is there?  Or do I need to write my
> own system?

I've never tried this with forms but I think that if you import the
form that you want to modify and then add then new fields, it should
work.

from my_base_app.forms import BaseForm
BaseForm.plugin_field1 = forms.blablabla
BaseForm.plugin_field2 = forms.blablabla


-- 
Marc

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



Re: Django API efficient enough for filtering tens of millions of records?

2011-01-19 Thread Thomas Weholt
Bulk inserts are the way the go if you can. When inserting a bunch of
data, avoid using the django orm. Do it in plain SQL. The overhead of
creating django orm model instances is way too expensive. Alltough it
may not be bulk insert the sense Nick mentioned above I wrote DSE [
http://pypi.python.org/pypi/dse/0.3.1 ] for that exact purpose, to
insert or update a bunch of data using plain SQL, but it hasn`t been
tested much so don`t use it in production. The thing it solves, can be
done in simple SQL;

Use cursor.executemany("", ).

DSE takes care of creating SQL-statements for insert and updates based
on your models, handles any default values you might have defined in
your model, caches lists of params and executes cursor.executemany
when the list of cached items reaches a specified limit. My experience
is that the performance gain of this solution or a similar one is
huge. Using cursor.executemany might be what Nick meant by bulk
insert, but I think different DB backends handles it differently. I
don`t know. Anyway, I've inserted many thousands of records using DSE
and it takes a fraction of the time when compared to doing it with the
orm.


NB! DSE is a proof-of-concept project more than anything else. It
needs a good re-write, extensive testing and docs, but it might be
helpful.

Thomas





On Wed, Jan 19, 2011 at 2:35 AM, Nick Arnett  wrote:
>
>
> On Tue, Jan 18, 2011 at 12:04 PM, Sithembewena Lloyd Dube
>  wrote:
>>
>> Hi all,
>>
>> I am building a search app. that will query an API. The app. will also
>> store search terms in a very simple table structure.
>>
>> Big question: if the app. eventually hit 10 million searches and I was
>> storing every single search term, would the table hold or would I run into
>> issues?
>
> As someone else said, 10 million records is no big deal for MySQL, in
> principle.
> However, you probably would do better to avoid all the overhead of a
> database transaction for storing each of these.  I'm going to assume that
> there will be duplicates, especially if you normalize the queries.  It would
> make a lot more sense to log the queries into a text file, which has
> extremely low overhead.  Then you'd periodically process the log files,
> normalizing and eliminating duplicates, producing a bulk insert to load into
> the database.  Bulk inserts will be FAR more efficient than using Django.
> Nick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.