Templaite:display li items alternatively using for

2008-10-31 Thread Xian Chen
Hi,

I want to display a list of items by using {% for item in items %}.

To make the web pages look better, I want to use two kinds of 
alternatively.

E.G item
   item

My question is how can i use the tags to implement this requirement?

Any build-in tags for this?

Thanks in advance,

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



Re: alert table while updating model automatically

2008-10-31 Thread Karen Tracey
On Sat, Nov 1, 2008 at 12:51 AM, Xian Chen <[EMAIL PROTECTED]> wrote:

> Hi All,
>
> I want to know whether Django support alerting the tables automatically
> while I modify the models or not.
>
> Suppose the website has run a long time and stored lots of data. In this
> case, the administrator wants to modify the model to add/remove some
> properties. Does the corresponding tables in the database will be alerted
> automatically?
>
> If not, how can make it happen? The administrator has no knowledge about
> SQL language. So, the administrator cannot run ALERT/DROP TABLE ...
>

(First just to clarify -- the word you want here is ALTER, not ALERT.  I was
a little confused reading your message until I realized that.)

There's nothing built into Django that does this. There are, however, at
least three external projects that offer this kind of thing:

http://code.google.com/p/django-evolution/
http://code.google.com/p/dmigrations/
http://south.aeracode.org/wiki

You might want to check them out.  Also if you search the list for terms
like 'schema evolution' or 'schema migration' you may find useful past
discussions on this topic.

Karen

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



Re: FileField; url oddness

2008-10-31 Thread csingley



On Oct 31, 7:05 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:

> My guess is that you need a trailing slash here. Without it, the
> urljoin() function doesn't know 'reports' is a directory, so  it
> strips 'reports' out and replaces it with the path from the database.
> This is why your settings.py includes the following comment above the
> MEDIA_URL setting: "Make sure to use a trailing slash if there is a
> path component"
>
> -Gul

Thanks a lot!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using settings.py mechanism for application settings

2008-10-31 Thread James Bennett

On Fri, Oct 31, 2008 at 8:29 PM, pk <[EMAIL PROTECTED]> wrote:
> Am I missing something? Should that mechanism be refactored so that it
> can be used for user applications? Is there a better way to do
> application level configuration -- i.e. for app designed to be
> distributed and reused?

If you look in django.contrib, there are several applications which
instruct you to fill in a setting which exists only for purposes of
that application. And those are applications like any other
application; it's perfectly acceptable for any application to do this,
so long as its documentation clearly indicates which settings to
supply and what values those settings can have.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



alert table while updating model automatically

2008-10-31 Thread Xian Chen
Hi All,

I want to know whether Django support alerting the tables automatically
while I modify the models or not.

Suppose the website has run a long time and stored lots of data. In this
case, the administrator wants to modify the model to add/remove some
properties. Does the corresponding tables in the database will be alerted
automatically?

If not, how can make it happen? The administrator has no knowledge about SQL
language. So, the administrator cannot run ALERT/DROP TABLE ...

Thanks,
Xian

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



Re: Using settings.py mechanism for application settings

2008-10-31 Thread Sahil R Cooner

I'm a little confused as to the purpose behind the question, it feels
pretty general, so I have a few questions.

1. When you say application are you talking about django apps generated via
the "manage.py startapp" command?

2. LazySettings allows for a "proxying" of the Global settings in your
projectsname.settings.  So I'm wondering if you're talking about in each
"application" from (1.), that you'd have a "local" settings?

3. Refactoring for portability? as per my understanding "refactoring"
means to rewrite better or to improve upon a code block/segment/file
whatever, are you talking about the ability to copy paste an "app"(1.)
into another django project created via django-admin.py so that it
maintains it's own ability to have a local configuration that is
universal regardless of what django project it sits in?

On Fri, Oct 31, 2008 at 06:29:46PM -0700, pk wrote:
> 
> There are always needs for application level configuration settings. I
> really like the way settings.py works, with a package (django) level
> default settings overridable by local settings. However looking at the
> whole LazySettings setup it is not easily used outside of django/conf.
> Am I missing something? Should that mechanism be refactored so that it
> can be used for user applications? Is there a better way to do
> application level configuration -- i.e. for app designed to be
> distributed and reused?
> 
> Thanks,
> P.K.
> 
> > 

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



Re: How to modify field error wording ?

2008-10-31 Thread Karen Tracey
On Fri, Oct 31, 2008 at 11:46 PM, nkulmati <[EMAIL PROTECTED]> wrote:

>
> Hi all:
>
>
> How to modify field error wording ?
> Please do not send me to the page "Form-subclasses-and-modifying-field-
> errors" in the docs.
>
> All I need is to override the error messages, NOT the validation
> system. That page does not address this need for some reason! I don't
> want to start customizing Form and Field classes and overriding
> clean() methods and do all this work just to change the wording of
> common error messages!
>
> Please help!
>

http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages

(A different page than the one you asked not to be sent to.)

Karen

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



Re: Is there a way to use the Cut Filter to only do the first instance?

2008-10-31 Thread Jeff FW

If you know the length of the string that you want to cut off the
beginning, you could use slice:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slice

Really, though, you might be going about this in a strange way.  It
might be better to use the url tag to get the correct URL that you
want in the first place.  But then, I don't know what you're trying to
do.

-Jeff

On Oct 31, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 31, 2008 at 11:55 AM, Frank Peterson
> <[EMAIL PROTECTED]>wrote:
>
>
>
> > I am using the following
> > {{ section.get_absolute_url|cut:"/news/" }}
> > on a string that is
> > /news/new-york-jets/news/
>
> > I need to remove the first /news but the CUT filter removes all
> > instances of it, is there a way for me to remove on the first "/news"?
>
> No, there's no way to make the existing cut filter do this, and I don't see
> another built-in filter that does what you ask.  However if you look at the
> implementation of cut here:
>
> http://code.djangoproject.com/browser/django/tags/releases/1.0/django...
>
> and the doc for Python's string replace method you can pretty easily write
> your own cut_first filter.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to modify field error wording ?

2008-10-31 Thread nkulmati

Hi all:


How to modify field error wording ?
Please do not send me to the page "Form-subclasses-and-modifying-field-
errors" in the docs.

All I need is to override the error messages, NOT the validation
system. That page does not address this need for some reason! I don't
want to start customizing Form and Field classes and overriding
clean() methods and do all this work just to change the wording of
common error messages!

Please help!

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



Using settings.py mechanism for application settings

2008-10-31 Thread pk

There are always needs for application level configuration settings. I
really like the way settings.py works, with a package (django) level
default settings overridable by local settings. However looking at the
whole LazySettings setup it is not easily used outside of django/conf.
Am I missing something? Should that mechanism be refactored so that it
can be used for user applications? Is there a better way to do
application level configuration -- i.e. for app designed to be
distributed and reused?

Thanks,
P.K.

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



Re: HttpRequest with chunked encoding is not buffered

2008-10-31 Thread Tomáš Brambora

I have a standard Django installation without any changes in the
settings (except adding mysql db to the settings.py) and I'm sending
the message to localhost:8000, so there is no proxy or anything else
in the way. Still, the request body comes after me sending the
response...

On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
<[EMAIL PROTECTED]> wrote:
>
>
>
> [EMAIL PROTECTED] wrote:
>> Hello,
>> I'm trying to receive a possibly large XML message via HttpRequest
>> (POST method) with chunked encoding. However, when I send a response,
>> I found out (using Wireshark) that the response is being sent before
>> the whole POST request body is available. I expected Django to be
>> buffering the chunks and that the request would be complete, but
>> that's apparently not happening...
>>
>> I'm reading the body like this:
>> request.POST.values()[0]
>>
>> (Which is probably a wrong way, but I don't know how to do it
>> otherwise.)
>
> What hosting mechanism are you using. Anything that uses WSGI (eg,
> mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
> specification or mod_python support chunked transfer encoding on
> request content. Certainly for mod_python and mod_wsgi, it should give
> an error back before even gets to Django saying that content length
> required to be set.
>
> Graham
> >
>

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



Re: Using Django

2008-10-31 Thread Alessandro
2008/10/31 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hello,
>
> I'm new to Django and it's taken me a while to get things setup
> correctly on Dreamhost. I've done the tutorials on my local machine
> prior to setting things up on Dreamhost but it seems like I'm missing
> instructions on how to actually use Django. Yes, I've read the "Using
> Django" section of the website but I don't even know how/where my
> pages should reside. If I request http://www.mysite.com, how do I
> route that to my "projects" directory where the "mysite" directory
> resides, a symbolic link? - which I tried but just returns a 403
> error. I'm still used to the traditional "mysite.com" directory which
> contains index.php, contact.php, etc., and I don't understand how the
> directory structure for Django works.

Try this setup:
http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mod_rails/

It's the best for me.
In one directory you have static files, in another django src, in
another your project, and if you needs also third party libraries.

And it's used in production for
http://www.animalisenzacasa.org

with success and good performance.




-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Re: FileField; url oddness

2008-10-31 Thread Marty Alchin

On Fri, Oct 31, 2008 at 1:42 PM, csingley <[EMAIL PROTECTED]> wrote:
> report_storage = ReportStorage(location='%s/reports' %
> settings.MEDIA_ROOT,
>base_url=settings.MEDIA_URL
> +'reports')

My guess is that you need a trailing slash here. Without it, the
urljoin() function doesn't know 'reports' is a directory, so  it
strips 'reports' out and replaces it with the path from the database.
This is why your settings.py includes the following comment above the
MEDIA_URL setting: "Make sure to use a trailing slash if there is a
path component"

-Gul

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



Re: Is there a way to host serveral django projects under a single virtual host

2008-10-31 Thread Graham Dumpleton



On Nov 1, 4:54 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
> 31 okt 2008 kl. 16.43 skrev ilyail3:
>
>
>
>
>
> > hello people, Is there a way to host several django projects under a
> > single virtual host?
> > I know this is possible with mod_php with wildcards as server alias
>
> > and later map urls to dirs using mod_rewrite
>
> > 
> >    DocumentRoot /var/www
> >    ServerNamewww.projects
> >    ServerAlias *.projects
> >    RewriteEngine on
> >    RewriteCond %{HTTP_HOST} !^www.* [NC]
> >    RewriteCond %{HTTP_HOST} ^([^\.]+)\.projects
> >    RewriteCond /var/www/%1 -d
> >    RewriteRule ^(.*) /%1/$1 [L]
> > 
>
> > But is it possible to run django projects from a directory in a
> > similar way.
>
> > Sorry if I'm asking a question someone have asked before , couldn't
> > find anything on this topic
>
> Are you using mod_wsgi, mod_python or what?
>
> If you're using mod_wsgi: From what I gather, running multiple django  
> projects under the same VirtualHost currently has things to deal with  
> to get it working. 
> (Seehttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>   -- search for "Note that Django expects").

Yes, mod_wsgi will by default run different WSGI applications within a
VirtualHost in different sub interpreters of same process. It has the
added benefit though that you could also delegate each application in
same virtual host to different daemon process groups. That or even mix
and match them, having some delegated out to separate process at the
same time as keeping some running in the Apache child processes.

In mod_python, the default is to run all applications within a
VirtualHost (regardless of listener port), in the same sub
interpreter. For Django, because DJANGO_SETTINGS_MODULE global, this
will not work. For mod_python you need to use PythonInterpreter
directive and manually designate that applications should run in
different sub interpreters.

Thus, mod_wsgi is far more flexible than mod_python in this respect.

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



Re: Response is sent before post body arrives

2008-10-31 Thread Graham Dumpleton



On Nov 1, 8:22 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm using chunked transfer encoding and i send a post http request to
> my Django application. But when I try to read the post body, it's not
> there (request.POST.keys() returns []). according to Wireshark, I send
> the response and right after that comes the request body.
> Do you know how to wait till the body arrives?
> And why does Django not wait for it automatically?

Hmmm, seems you basically asked the same question twice. See:

 http://groups.google.com/group/django-users/browse_frm/thread/dda2008ccbc8cd65

If you are getting empty input on read, then you are using hosting
mechanism that doesn't properly filter out chunked request content as
not being supported and instead assumes that content length of request
was 0.

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



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-31 Thread Graham Dumpleton



On Nov 1, 10:06 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 1, 8:44 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Fri, Oct 31, 2008 at 1:01 PM, Naitik Shah <[EMAIL PROTECTED]> wrote:
> > > On Thu, Oct 30, 2008 at 10:58 PM, Graham Dumpleton <
> > > [EMAIL PROTECTED]> wrote:
>
> > >> In respect of having nginx in front, one of the over benefits of that
> > >> was that nginx could have been quite selective about the URLs that it
> > >> was proxying. That way if you get a SPAM bot or similar hitting the
> > >> site, it could have been blocked at nginx without even going through
> > >> to Apache/mod_wsgi, presuming that such a bot was hitting known URLs
> > >> for security holes in PHP packages or the like. One may also have been
> > >> able to filter SPAM bot traffic at nginx level through user agent or
> > >> other things. Thus, nginx could have further been used as a filter
> > >> point to limit traffic going through to Apache.
>
> > > That's interesting. I wonder if Apache could be made to reject such
> > > requests. I like the current simple setup - I want to avoid adding Nginx 
> > > to
> > > the mix :)
>
> > I looked into this approach a bit, and it seems there's more benefits - the
> > one that stood out is that slow clients will first be handled by Nginx, and
> > the request will only be handed off to Apache after Nginx is done receiving
> > it. Thus, holding the Apache process for less amount of time. I'll look into
> > this in more detail once I have the Apache setup working as I like.
>
> Yes, in theory that as well.
>
> This is where one would have thought the Apache event MPM might help,
> but from what I remember at look at code, the special event worker
> thread only deals with accepting the new connection (before handing it
> off to another thread) and later perhaps (can't remember) dealing with
> management of keep alive connections.
>
> In other words, don't believe the Apache event MPM uses the event
> worker thread to at least read in the HTTP request header before
> handing it off to another thread for processing. Thus, request has
> already been handed off to its own thread for that part of the request
> which may arrive slow, ie., the HTTP request information. I will need
> to check again though if what I remember is correct. :-)
>
> This is where nginx is better, as the event model can handle all that
> HTTP request header reading in single thread by multiplexing it based
> on availability of data. Therefore you don't suffer the Apache
> overhead of memory usage for threads sitting there waiting for slow
> data to come for HTTP request header.
>
> Anyway, before you quote me on how Apache event MPM works, I better go
> check.

I think me memory is okay. Comments in event MPM code say:

 * This MPM tries to fix the 'keep alive problem' in HTTP.
 *
 * After a client completes the first request, the client can keep the
 * connection open to send more requests with the same socket.  This
can save
 * signifigant overhead in creating TCP connections.  However, the
major
 * disadvantage is that Apache traditionally keeps an entire child
 * process/thread waiting for data from the client.  To solve this
problem,
 * this MPM has a dedicated thread for handling both the Listenting
sockets,
 * and all sockets that are in a Keep Alive status.

and looking at code it does indeed seem to send accept socket direct
into worker thread queue for processing before any data actually read.

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



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-31 Thread Graham Dumpleton



On Nov 1, 8:44 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 31, 2008 at 1:01 PM, Naitik Shah <[EMAIL PROTECTED]> wrote:
> > On Thu, Oct 30, 2008 at 10:58 PM, Graham Dumpleton <
> > [EMAIL PROTECTED]> wrote:
>
> >> In respect of having nginx in front, one of the over benefits of that
> >> was that nginx could have been quite selective about the URLs that it
> >> was proxying. That way if you get a SPAM bot or similar hitting the
> >> site, it could have been blocked at nginx without even going through
> >> to Apache/mod_wsgi, presuming that such a bot was hitting known URLs
> >> for security holes in PHP packages or the like. One may also have been
> >> able to filter SPAM bot traffic at nginx level through user agent or
> >> other things. Thus, nginx could have further been used as a filter
> >> point to limit traffic going through to Apache.
>
> > That's interesting. I wonder if Apache could be made to reject such
> > requests. I like the current simple setup - I want to avoid adding Nginx to
> > the mix :)
>
> I looked into this approach a bit, and it seems there's more benefits - the
> one that stood out is that slow clients will first be handled by Nginx, and
> the request will only be handed off to Apache after Nginx is done receiving
> it. Thus, holding the Apache process for less amount of time. I'll look into
> this in more detail once I have the Apache setup working as I like.

Yes, in theory that as well.

This is where one would have thought the Apache event MPM might help,
but from what I remember at look at code, the special event worker
thread only deals with accepting the new connection (before handing it
off to another thread) and later perhaps (can't remember) dealing with
management of keep alive connections.

In other words, don't believe the Apache event MPM uses the event
worker thread to at least read in the HTTP request header before
handing it off to another thread for processing. Thus, request has
already been handed off to its own thread for that part of the request
which may arrive slow, ie., the HTTP request information. I will need
to check again though if what I remember is correct. :-)

This is where nginx is better, as the event model can handle all that
HTTP request header reading in single thread by multiplexing it based
on availability of data. Therefore you don't suffer the Apache
overhead of memory usage for threads sitting there waiting for slow
data to come for HTTP request header.

Anyway, before you quote me on how Apache event MPM works, I better go
check.

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



Re: HttpRequest with chunked encoding is not buffered

2008-10-31 Thread Graham Dumpleton



[EMAIL PROTECTED] wrote:
> Hello,
> I'm trying to receive a possibly large XML message via HttpRequest
> (POST method) with chunked encoding. However, when I send a response,
> I found out (using Wireshark) that the response is being sent before
> the whole POST request body is available. I expected Django to be
> buffering the chunks and that the request would be complete, but
> that's apparently not happening...
>
> I'm reading the body like this:
> request.POST.values()[0]
>
> (Which is probably a wrong way, but I don't know how to do it
> otherwise.)

What hosting mechanism are you using. Anything that uses WSGI (eg,
mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
specification or mod_python support chunked transfer encoding on
request content. Certainly for mod_python and mod_wsgi, it should give
an error back before even gets to Django saying that content length
required to be set.

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



Re: Migrate app from MySQL to PostgreSQL

2008-10-31 Thread Naitik Shah
On Fri, Oct 31, 2008 at 6:29 AM, varikin <[EMAIL PROTECTED]> wrote:

>
> Check out django_extensions app,
> http://code.google.com/p/django-command-extensions/.
> It has a command, dumpscript, which creates a python script to
> populate the database. That might get ride of the incompatible types.
> I haven't tried this myself, but it is worth a shot.


Wow - I've been using runserver_plus from that app, but never noticed this.
It seems much more promising as its working at a much higher Django level
than the other options. The dumpscript gave me something back, but the
equivalent runscript against my PostgreSQL installation is not producing any
errors, nor is it restoring the data. Will keep investigating.


-Naitik

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



HttpRequest with chunked encoding is not buffered

2008-10-31 Thread [EMAIL PROTECTED]

Hello,
I'm trying to receive a possibly large XML message via HttpRequest
(POST method) with chunked encoding. However, when I send a response,
I found out (using Wireshark) that the response is being sent before
the whole POST request body is available. I expected Django to be
buffering the chunks and that the request would be complete, but
that's apparently not happening...

I'm reading the body like this:
request.POST.values()[0]

(Which is probably a wrong way, but I don't know how to do it
otherwise.)

Thank for any help.
Tomas

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



ManytoMany using intermediary table and custom db_table

2008-10-31 Thread Mark

I'm having a little trouble tracking a down a small problem. My models
(which are working) look like this (with some of the boilerplate cut
out):

class Image(models.Model):
id = models.AutoField(primary_key=True)
pub_date = models.DateTimeField(blank=True)
caption = models.TextField(blank=True)
location = models.CharField(blank=True, max_length=150)
portfolios = models.ManyToManyField(Portfolio, db_table='set_image',
blank=True)

def __unicode__(self):
return u"%s | %s" % (self.caption, self.location)
class Meta:
db_table = 'image'
ordering = ('-pub_date',)

class Portfolio(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(blank=True, max_length=150)
description = models.CharField(blank=True, max_length=300)

class Meta:
db_table = 'sets'
def __unicode__(self):
return self.name

class ImagePort(models.Model):
# Merge table to add data (Rank for ordering) to many-to-many
relationship between Image and Portfolio
portfolio = models.ForeignKey(Portfolio, blank=False, default=None)
image = models.ForeignKey(Image, blank=False, default=None)
rank = models.IntegerField(null=True, blank=True)

class Meta:
db_table = 'set_image'
ordering = ('rank',)


and in an admin.py file I have:

class ImageAdmin(admin.ModelAdmin):
ordering = ['id']
filter_horizontal = ('portfolios',)

admin.site.register(Image, ImageAdmin)

This works fine even after upgrading to 1.0. But when I follow the new
docs and change my Image model's many-to-many definition to:

portfolios = models.ManyToManyField(Portfolio, through="ImagePort",
blank=True)

I lose the many-to-many portfolios with the nifty filter_horizontal in
the Image admin. I can get the admin.TabularInline interface by
following the docs, but like most people I really prefer the nifty
javascript version. If I try to add the portfolio with something like
fields=('portfolios',) in the ImageAdmin I get a template syntax error
complaining that the key 'portfolio' is not found.

Am I doing something obviously wrong?

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



Response is sent before post body arrives

2008-10-31 Thread [EMAIL PROTECTED]

Hi,

I'm using chunked transfer encoding and i send a post http request to
my Django application. But when I try to read the post body, it's not
there (request.POST.keys() returns []). according to Wireshark, I send
the response and right after that comes the request body.
Do you know how to wait till the body arrives?
And why does Django not wait for it automatically?

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



FileField; url oddness

2008-10-31 Thread csingley

Hi, I've got a model defined like so:
"""
from django.conf import settings
from django.db import models
from django.core.files.storage import FileSystemStorage

class ReportStorage(FileSystemStorage):
@staticmethod
def filepath(instance, filename):
subdir = '/'.join((instance.account.client.username,
instance.account.number))
filename = '%s.pdf' % instance.slug
return '/'.join((subdir, filename))

report_storage = ReportStorage(location='%s/reports' %
settings.MEDIA_ROOT,
base_url=settings.MEDIA_URL
+'reports')
class Report(models.Model):
content = models.FileField(storage=report_storage,
upload_to=report_storage.filepath)
"""

However, the urls aren't being generated as expected.  Here's an
interactive session:
"""
In [1]: from apps.userhomes.models import Report

In [2]: foo = Report.objects.get(id=1)

In [3]: foo.content.url
Out[3]: u'/media/test1/111/2008q3.pdf'

In [4]: foo.content.storage.base_url
Out[4]: '/media/reports'
"""

I'd expect that 3rd output to be  u'/media/reports/
test1/111/2008q3.pdf' instead; FileSystemStorage.url() specifies that
the base_url should be used.

Can anybody give me a clue what's going on here?

TIA

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



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-31 Thread Naitik Shah
On Fri, Oct 31, 2008 at 1:01 PM, Naitik Shah <[EMAIL PROTECTED]> wrote:

> On Thu, Oct 30, 2008 at 10:58 PM, Graham Dumpleton <
> [EMAIL PROTECTED]> wrote:
>
>>
>> In respect of having nginx in front, one of the over benefits of that
>> was that nginx could have been quite selective about the URLs that it
>> was proxying. That way if you get a SPAM bot or similar hitting the
>> site, it could have been blocked at nginx without even going through
>> to Apache/mod_wsgi, presuming that such a bot was hitting known URLs
>> for security holes in PHP packages or the like. One may also have been
>> able to filter SPAM bot traffic at nginx level through user agent or
>> other things. Thus, nginx could have further been used as a filter
>> point to limit traffic going through to Apache.
>
>
> That's interesting. I wonder if Apache could be made to reject such
> requests. I like the current simple setup - I want to avoid adding Nginx to
> the mix :)
>

I looked into this approach a bit, and it seems there's more benefits - the
one that stood out is that slow clients will first be handled by Nginx, and
the request will only be handed off to Apache after Nginx is done receiving
it. Thus, holding the Apache process for less amount of time. I'll look into
this in more detail once I have the Apache setup working as I like.


-Naitik

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



Using Django

2008-10-31 Thread [EMAIL PROTECTED]

Hello,

I'm new to Django and it's taken me a while to get things setup
correctly on Dreamhost. I've done the tutorials on my local machine
prior to setting things up on Dreamhost but it seems like I'm missing
instructions on how to actually use Django. Yes, I've read the "Using
Django" section of the website but I don't even know how/where my
pages should reside. If I request http://www.mysite.com, how do I
route that to my "projects" directory where the "mysite" directory
resides, a symbolic link? - which I tried but just returns a 403
error. I'm still used to the traditional "mysite.com" directory which
contains index.php, contact.php, etc., and I don't understand how the
directory structure for Django works. It seems like the tutorials just
show you how to start a project under test conditions and show off the
built-in admin tools, without really explaining how things are setup
for an actual website. Maybe this system is over my head...

Thanks,

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



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-31 Thread Naitik Shah
On Thu, Oct 30, 2008 at 10:58 PM, Graham Dumpleton <
[EMAIL PROTECTED]> wrote:

>
> If there are definite idle periods of reasonable size, perhaps look at
> 'inactivity-timeout' option to WSGIDaemonProcess. This way daemon
> process will be restarted when doing nothing, and providing that
> preloading not configured using WSGIImportScript, then process size
> will be quite small until next needed, at which point it will load
> application again.
>
> To counter risk of daemon process growing in size because of memory
> creep in application you don't know about, also look at 'maximum-
> requests' option to WSGIDaemonProcess.


Indeed both these options sound useful. I already use MaxRequestsPerChild
for Apache, but having the same for the Python daemon process makes sense.
The inactivity-timeout will be useful since I have cronjobs that run during
low traffic hours to do random work and will benefit from more available
memory.

(My WSGIDaemonProcess line is becoming a little too long, can it be split to
multiple lines?)


> If Apache/mod_wsgi only handling dynamic content, wouldn't see that
> event MPM would make any difference. If only handling dynamic content,
> turning off keep alive on Apache may help though as unlikely one will
> get concurrent requests over same socket for dynamic web page, and so
> can give up client connection straight away and not tie up Apache
> processes/threads for period that timeout takes to trigger for keep
> alive.


Yep, Keep-Alive off makes a decent difference when I'm benchmarking a single
dynamic script with some concurrency (and the benchmarking client is
explicitly not reusing connections). And since I dont have many (any?) cases
of immediate follow up requests, Keep-Alive is not very useful for now. I am
quite amazed at how well mod_wsgi performs for my simple wsgi applications
:)


> In respect of having nginx in front, one of the over benefits of that
> was that nginx could have been quite selective about the URLs that it
> was proxying. That way if you get a SPAM bot or similar hitting the
> site, it could have been blocked at nginx without even going through
> to Apache/mod_wsgi, presuming that such a bot was hitting known URLs
> for security holes in PHP packages or the like. One may also have been
> able to filter SPAM bot traffic at nginx level through user agent or
> other things. Thus, nginx could have further been used as a filter
> point to limit traffic going through to Apache.


That's interesting. I wonder if Apache could be made to reject such
requests. I like the current simple setup - I want to avoid adding Nginx to
the mix :)


> > WSGIPythonOptimize 1
>
> Surprised if this will make much difference. Worth a try but don't
> expect it to do much. For a start, as it is a long running process,
> any benefit at process start when loading smaller .pyo files is only
> for that time and not later when handling actual requests.


I wasnt sure if this was needed or not - but as long as it doesnt do harm,
I'm inclined to keep it.


> > 
> > StartServers  30
> > MinSpareServers   30
> > MaxClients30
> > 
>
> If not using PHP on same Apache, better to use Apache worker MPM as
> then cut down on number of Apache child process and still just as
> capable at handling load of static files and proxying to mod_wsgi
> daemon processes.


PHP is indeed why you're seeing this here - but finally once I'm done with
my current migration, the last PHP site will be gone. I was planning on
switching to worker, but just yesterday realized that my distro only comes
with the prefork mpm. So if I'm going to be building a custom Apache package
anyways, maybe I should go with event. mod_wsgi is already a custom package,
so rebuilding that is a non issue.


> > Alias /media/ /data/daaku/media/
> > 
> > SetHandler None
>
> The 'SetHandler None' should not be needed here. This was a mod_python
> requirement but mod_wsgi shouldn't need it.
>

Took it out. Less is always better :)


Thanks!
-Naitik

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



Re: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-31 Thread Ross Dakin

I run prefork with mod_wsgi (embedded) and mod_php.  No troubles so
far, though I'm using MySQL with PHP and Postgres with Django, so I'm
not likely to experience the MySQL library issues Graham described.

I've read that mod_php actually doesn't like worker MPM, because come
common PHP extensions aren't thread safe.

My setup is for a general development environment... low traffic. For
something more robust I would dedicate a server to Django and run
mod_wsgi with worker MPM. That seems to be the fastest setup, from
everything I've _read_ (no experience with worker). Of course, proxy
to Apache via nginx or alternative.

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



Re: Is there a way to host serveral django projects under a single virtual host

2008-10-31 Thread Håkan Waara

31 okt 2008 kl. 16.43 skrev ilyail3:

>
> hello people, Is there a way to host several django projects under a
> single virtual host?
> I know this is possible with mod_php with wildcards as server alias
>
> and later map urls to dirs using mod_rewrite
>
> 
>DocumentRoot /var/www
>ServerName www.projects
>ServerAlias *.projects
>RewriteEngine on
>RewriteCond %{HTTP_HOST} !^www.* [NC]
>RewriteCond %{HTTP_HOST} ^([^\.]+)\.projects
>RewriteCond /var/www/%1 -d
>RewriteRule ^(.*) /%1/$1 [L]
> 
>
> But is it possible to run django projects from a directory in a
> similar way.
>
> Sorry if I'm asking a question someone have asked before , couldn't
> find anything on this topic

Are you using mod_wsgi, mod_python or what?

If you're using mod_wsgi: From what I gather, running multiple django  
projects under the same VirtualHost currently has things to deal with  
to get it working. (See 
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango 
  -- search for "Note that Django expects").

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



Re: updating a single field / attribute, is it possible? or better practices?

2008-10-31 Thread omat

Exactly. Thanks for the reference.


--
oMat


On Oct 31, 6:54 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 31, 2008 at 12:39 PM, omat <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > Is it possible to update a chosen subset of attributes of a model
> > instance?
>
> http://code.djangoproject.com/ticket/4102
>
> asks for this, I believe.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Execute a java program

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 2:21 pm, varikin <[EMAIL PROTECTED]> wrote:
> On Oct 30, 5:12 am, "[EMAIL PROTECTED]"
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > Hi everyone I am newbie to django and I am italian so excuse me for my
> > english :P
> > I have to execute a java program very simple look something like this:
>
> > public class Book {
> >     public static void main(String[] args) {
>
> >          int year = 2008;
>
> >          List list =  Booklist.fetchbook(year);
> >          Iterator it = list.iterator();
>
> >          while (it.hasNext()) {
> >              Book book = (Book) it.next();
> >              System.out.println( book.getTitle()  + " " +
> > book.getAuthor() );
> >             }
>
> > } }
>
> > and I have to retrieve 2 strings ( book.getTitle() and
> > book.getAuthor() ) for use its in django application.
> > How Can I do that? Do I have to use JVM ? How ?
>
> > thanks :)
>
> Also, take a look at Jython which is Python written on top of the JVM
> so you can call Java libraries within Python. Django 1.0 works with
> Jython.


thanks I'll try subprocess and jython but I have heard that django
with jython is slow. Is it true ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a way to host serveral django projects under a single virtual host

2008-10-31 Thread Sahil R Cooner

Of course there is :), for the VirtualHost *, means everything, instead
use names like projecta, projectb, etc...if that doesn't make sense then
the best thing to do prior to messing with your settings is to read the
documentation from apache on VirtualHost.

--neuro

On Fri, Oct 31, 2008 at 08:43:23AM -0700, ilyail3 wrote:
> 
> hello people, Is there a way to host several django projects under a
> single virtual host?
> I know this is possible with mod_php with wildcards as server alias
> 
> and later map urls to dirs using mod_rewrite
> 
> 
> DocumentRoot /var/www
> ServerName www.projects
> ServerAlias *.projects
> RewriteEngine on
> RewriteCond %{HTTP_HOST} !^www.* [NC]
> RewriteCond %{HTTP_HOST} ^([^\.]+)\.projects
> RewriteCond /var/www/%1 -d
> RewriteRule ^(.*) /%1/$1 [L]
> 
> 
> But is it possible to run django projects from a directory in a
> similar way.
> 
> Sorry if I'm asking a question someone have asked before , couldn't
> find anything on this topic
> 
> > 

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



Re: updating a single field / attribute, is it possible? or better practices?

2008-10-31 Thread Karen Tracey
On Fri, Oct 31, 2008 at 12:39 PM, omat <[EMAIL PROTECTED]> wrote:

>
> Hi all,
>
> Is it possible to update a chosen subset of attributes of a model
> instance?
>

http://code.djangoproject.com/ticket/4102

asks for this, I believe.

Karen

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



updating a single field / attribute, is it possible? or better practices?

2008-10-31 Thread omat

Hi all,

Is it possible to update a chosen subset of attributes of a model
instance?

In my case, the view function saves a model instance which was updated
in the model's custom save() method. Thus, the update by the save() is
overridden.


Pseudo code of the scenario:

class MyModel(Model):
qualified = models.BooleanField()
count = models.IntegerField()
def save(self):
self.count = self.refmodel_set.count(qualified=True)
super(...).save()

class RefModel(Model):
my_model = models.ForeignKey(MyModel)

def form_view(request, id):
my_instance = MyModel.objects.get(id=id)
ref_form = RefForm(data)
if ref_form.is_valid():
ref = ref_form.save(commit=False)
ref.my_model = my_instance
ref.save()
if ref.some_attribute:
my_instance.qualified = True
my_instance.save() # this overrides the change made in
MyModel.save()


I thought, if there is a way to save only a single attribute, without
touching others, my problem will be solved. In that case, the last two
lines would look like:

my_instance.qualified = True
my_instance.save(fields=('qualified',))


Does this makes sense?


Thanks for any comments,
oMat

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



Re: Is there a way to use the Cut Filter to only do the first instance?

2008-10-31 Thread Karen Tracey
On Fri, Oct 31, 2008 at 11:55 AM, Frank Peterson
<[EMAIL PROTECTED]>wrote:

>
> I am using the following
> {{ section.get_absolute_url|cut:"/news/" }}
> on a string that is
> /news/new-york-jets/news/
>
> I need to remove the first /news but the CUT filter removes all
> instances of it, is there a way for me to remove on the first "/news"?
>

No, there's no way to make the existing cut filter do this, and I don't see
another built-in filter that does what you ask.  However if you look at the
implementation of cut here:

http://code.djangoproject.com/browser/django/tags/releases/1.0/django/template/defaultfilters.py#L325

and the doc for Python's string replace method you can pretty easily write
your own cut_first filter.

Karen

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



Is there a way to use the Cut Filter to only do the first instance?

2008-10-31 Thread Frank Peterson

I am using the following
{{ section.get_absolute_url|cut:"/news/" }}
on a string that is
/news/new-york-jets/news/

I need to remove the first /news but the CUT filter removes all
instances of it, is there a way for me to remove on the first "/news"?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is there a way to host serveral django projects under a single virtual host

2008-10-31 Thread ilyail3

hello people, Is there a way to host several django projects under a
single virtual host?
I know this is possible with mod_php with wildcards as server alias

and later map urls to dirs using mod_rewrite


DocumentRoot /var/www
ServerName www.projects
ServerAlias *.projects
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.projects
RewriteCond /var/www/%1 -d
RewriteRule ^(.*) /%1/$1 [L]


But is it possible to run django projects from a directory in a
similar way.

Sorry if I'm asking a question someone have asked before , couldn't
find anything on this topic

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



Re: Custom change list and list_display

2008-10-31 Thread Karen Tracey
On Fri, Oct 31, 2008 at 10:24 AM, Fabio Natali
<[EMAIL PROTECTED]>wrote:

>
> Rajesh Dhawan wrote:
> [...]
> > > What's more, how can I make those callables columns sortable
> > > within the change list page? I'm working with trunk. I read this:
> > > http://code.djangoproject.com/changeset/9211 Does this mean that I
> > > can add some callable and then alphabetically order them?
> >
> > No. While you can definitely add a callable column in the change
> > list[1], you can only sort by fields that are in the database table.
>
> Ok, we can't sort on callable columns. Anyway that's a pity... I
> thought providing a straight lexicographic order was not such a big
> deal. (But I probably miss some points and misjudge the difficulty of
> the matter.)
>
>
The sorting is done at the database level (SQL ORDER BY), as is the
pagination (SQL OFFSET & LIMIT), so it is efficient (DBs are optimized to do
these things efficiently).  In order to sort by something not in the
database, Django would need to retrieve all rows, do the sort (calling your
callable for each row in the DB), and then limit the result according to the
page you are viewing.  This would be prohibitively expensive for large
tables.

Karen

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



Re: Custom change list and list_display

2008-10-31 Thread Fabio Natali

Karen Tracey wrote:
[...]
> > Ok, we can't sort on callable columns. Anyway that's a pity...

> The sorting is done at the database level (SQL ORDER BY), as is the
> pagination (SQL OFFSET & LIMIT), so it is efficient (DBs are optimized to do
> these things efficiently).

Karen thank you very much for your explanation, this is very kind of
you. I suspected there could be such kind of reason but I didn't
figure it out clearly.

See ya, Fabio.

-- 
Fabio Natali

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



Re: Custom change list and list_display

2008-10-31 Thread Fabio Natali

Rajesh Dhawan wrote:
[...]
> > What's more, how can I make those callables columns sortable
> > within the change list page? I'm working with trunk. I read this:
> > http://code.djangoproject.com/changeset/9211 Does this mean that I
> > can add some callable and then alphabetically order them?
> 
> No. While you can definitely add a callable column in the change
> list[1], you can only sort by fields that are in the database table.

Ok, we can't sort on callable columns. Anyway that's a pity... I
thought providing a straight lexicographic order was not such a big
deal. (But I probably miss some points and misjudge the difficulty of
the matter.)

Thanks again, Fabio.

-- 
Fabio Natali

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



Re: inspect a model's field's option's values

2008-10-31 Thread Mark Wolgemuth

That's exactly what I'm looking for.
I'll probably try adding that feature to the model base class or as a
mixin.

@classmethod
def get_field_option_by_name(self, fieldname, optionname):
field = self._meta.get_field_by_name(fieldname)[0]
return getattr(fieldname, optionname)

possibly with the default thing also.

On Oct 30, 12:18 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 30 oct, 14:26, Mark Wolgemuth <[EMAIL PROTECTED]> wrote:
>
>
>
> > It seems like I'm missing something, but here's what I'm trying to do:
>
> > In creating a Form object, I'm setting size limit validation
> > (max_length). I'd like to recover the value for that from the
> > corresponding Model's Field's max_length. So basically I want a symbol
> > lookup that will inspect in the options of a field I have defined for
> > a model, without having an instance of the model, just it's type.
>
> > This is to avoid the 2 having to share a common separately defined
> > constant, or just using an integer that I have to coordinate in both
> > places, or in place of always using auto forms.
>
> > eg
>
> > class MyModel(Model):
> >      myfield = CharField(max_length=128)
>
> > --
>
> > class MyForm(Form):
> >      myfield = CharField(max_length=**GET.FROM.MODEL**)
>
> def get_model_field_option(model, field, option, default=None):
>     field = model._meta.get_field_by_name(field)[0]
>     return getattr(field, option, default)
>
> class MyForm(Form):
>      myfield = CharField(
>          max_length=get_model_field_option(MyModel, 'myfield',
> 'max_length', 100)
>          )
>
> Caveat : Not sure it works on all possible options for all possible
> fields - testing left as an exercise to to OP !-)
>
> HTH
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



browser setting takes over /i18n/setlang?language=english

2008-10-31 Thread Genis Pujol Hamelink
Hello,

I'm checking out the i18N features and apparently the browser setting takes
over always, if I try to select the language via the link it doesn't work,
it just falls back to whatever language is set in the browser (i.e. u click
and nothing happens, no error messages, nothing).

If I change the language setting in the browser all pages are translated
correctly but no via de language link on the page.

Any ideas? Can I force django to skip the browser setting and listen only to
what is set via setlang?

Or is this wrong:

 English 


(django version 1.0 svn, browser firefox 3.0.3)

kind regards,


-- 
Genís

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



Re: Migrate app from MySQL to PostgreSQL

2008-10-31 Thread varikin



On Oct 30, 1:57 pm, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> I ran into issues with this approach as well - first uniqueness constraints
> were failing, which I managed to fix manually. Next I got ContentType
> matching query issues, which I have not fixed yet.
>
> I was hoping to come up with a generic migration process since I have a few
> other sites on MySQL. But this is my first foray into PostgreSQL, so maybe I
> should just take a simpler approach and write a task specific migration
> script until I'm convinced I should move all my sites to PostgreSQL.
>
> -Naitik
>
> On Thu, Oct 30, 2008 at 12:59 AM, Brot <[EMAIL PROTECTED]> wrote:
>
> > This doesn't work as expected. I tried the migration with dumpdata
> > month ago.
> > The problem is, that mysql and postgres writes another, incompatible
> > boolean values. I believe sqlite and postgres has the same problem!
> > I reworked the dumpdata output-file. In my case this was possible,
> > because the amount of data was not too big
>
> > On 30 Okt., 08:44, David Christiansen <[EMAIL PROTECTED]> wrote:
> > > Why not just dump the data using manage.py dumpdata, switch your
> > > settings file to point to the new DB, run syncdb, and then use
> > > manage.py loaddata to get it all back?  That should be pretty easy.
>
> > > -David Christiansen
>
> > > On Oct 30, 2:39 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
>
> > > > I looked around but didn't find anything obvious or simple. This is a
> > live
> > > > Django app with data in MySQL which I want to migrate to PostgreSQL.
> > > > Suggestions? (Before I do my own thing :))
>
> > > > -Naitik

Check out django_extensions app, 
http://code.google.com/p/django-command-extensions/.
It has a command, dumpscript, which creates a python script to
populate the database. That might get ride of the incompatible types.
I haven't tried this myself, but it is worth a shot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why is my string not auto escaped?

2008-10-31 Thread Rajesh Dhawan

>
> > > So if these built in filters are marking my strings safe, inspite of
> > > unsafe data being passed in, should they not handle escaping as well?
>
> > The problem seems to be that your filter function doesn't mark itself
> > with an is_safe attribute (defaulting it to False). So try marking
> > your filter with is_safe=True which means that your filter doesn't
> > introduce any HTML unsafe characters by itself (not including the ones
> > that are already in the input):
>
> > filterxx.is_safe = True
>
> > Also, it's easier for people to follow a discussion thread if you
> > don't top post your responses.
>
> > -RD
>
> I don't think setting is_safe is the solution, in fact is sounds like
> the exact opposite.

It might sound confusing, but is_safe=True is a way for you to
indicate to Django that your filter does not introduce any unwanted
characters. See point #1 in the below doc for a more thorough
explanation:

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping


> Shabda *wants* Django to escape the results.

Here's an excerpt from the docs for that case:

"1. Your filter does not introduce any HTML-unsafe characters (<, >,
', " or &) into the result that were not already present. In this
case, you can let Django take care of all the auto-escaping handling
for you. All you need to do is put the is_safe attribute on your
filter function and set it to True, like so:

This attribute tells Django that if a "safe" string is passed into
your filter, the result will still be "safe" and if a non-safe string
is passed in, Django will automatically escape it, if necessary."

-RD

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



Re: Execute a java program

2008-10-31 Thread varikin



On Oct 30, 5:12 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi everyone I am newbie to django and I am italian so excuse me for my
> english :P
> I have to execute a java program very simple look something like this:
>
> public class Book {
>     public static void main(String[] args) {
>
>          int year = 2008;
>
>          List list =  Booklist.fetchbook(year);
>          Iterator it = list.iterator();
>
>          while (it.hasNext()) {
>              Book book = (Book) it.next();
>              System.out.println( book.getTitle()  + " " +
> book.getAuthor() );
>             }
>
> } }
>
> and I have to retrieve 2 strings ( book.getTitle() and
> book.getAuthor() ) for use its in django application.
> How Can I do that? Do I have to use JVM ? How ?
>
> thanks :)

Also, take a look at Jython which is Python written on top of the JVM
so you can call Java libraries within Python. Django 1.0 works with
Jython.


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



Re: Why is my string not auto escaped?

2008-10-31 Thread varikin



On Oct 30, 6:58 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> On Oct 30, 1:30 am, shabda <[EMAIL PROTECTED]> wrote:
>
> > So if these built in filters are marking my strings safe, inspite of
> > unsafe data being passed in, should they not handle escaping as well?
>
> The problem seems to be that your filter function doesn't mark itself
> with an is_safe attribute (defaulting it to False). So try marking
> your filter with is_safe=True which means that your filter doesn't
> introduce any HTML unsafe characters by itself (not including the ones
> that are already in the input):
>
> filterxx.is_safe = True
>
> Also, it's easier for people to follow a discussion thread if you
> don't top post your responses.
>
> -RD

I don't think setting is_safe is the solution, in fact is sounds like
the exact opposite. Shabda *wants* Django to escape the results.
Instead, try calling django.utils.html.escape() in your filterxx like
so:

return linebreaks(urlize(escape(data.value)))

This will replace <,>,&,etc with the , , , etc.


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



populating forms using models

2008-10-31 Thread Vokial

Hi
I'm working on a registration form which is based, among the others,
on this model:

class City(models.Model):
prov_name =
models.CharField(verbose_name='Provincia',max_length=50)

(obviously i'm writing down just the field i'm interested in to save
some space..)

In the form i have to put a select field for the cities
(form.forms.ModelChoiceField with a queryset on City) and also a
select field for prov_name, in order to populate the list of choices..

Surely a different model (Provinces, and then a foreignkey on City
prov_name) would be easier to manage but i can't alter the schema of
the database i'm using, so i have to find workarounds.. And i can't do
a modelChoiceField based on prov_name because there's no primary key,
it's just a field..

Do someone have an idea on how to handle this?

Thank you a lot!


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



Re: User.email

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 1:32 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> On Oct 31, 11:01 am, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Oct 31, 9:51 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> > wrote:
>
> > > Hi,
>
> > > I've this model:
>
> > > from django.contrib.auth.models import User
>
> > > class Player(models.Model):
> > >     first_name = models.CharField(max_length=30)
> > >     last_name = models.CharField(max_length=40)
> > >     email = models.EmailField()
> > >     user = models.ForeignKey(User, blank=True, null=True)
>
> > > I try to set the email of the Player with the email of the User:
>
> > > class Player(models.Model):
> > >     first_name = models.CharField(max_length=30)
> > >     last_name = models.CharField(max_length=40)
> > >     email = models.EmailField(User.email)
> > >     user = models.ForeignKey(User, blank=True, null=True)
>
> > > but I've this error:
>
> > >     email = models.EmailField(User.email)
> > > AttributeError: type object 'User' has no attribute 'email'
>
> > > Can I set the Player model with the email that automatically take the
> > > value from the User that I choice:
>
> > > example:
>
> > > User: username='tommy' email='[EMAIL PROTECTED]"
>
> > > Player: if I choice the user=tommy the email" automatically take the
> > > value of the User -> [EMAIL PROTECTED]@gmail.com"
>
> > > Alfredo
>
> > Well, no, you can't do this in the way that you've tried above. I
> > suppose you could override the save method to populate the model with
> > the value of the email.
>
> > But why would you want to? You already have a link from your Player to
> > the associated User. So whenever you need the email, you just look in
> > the related object:
>
> > my_player.user.email
>
> > --
> > DR.
>
> User don't have a email field.
> Look here:http://www.djangobook.com/en/1.0/chapter12/#cn222
>
> for storing additional information for user :)


ops excuse me user have got a email field.
So I agree with Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User.email

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 11:01 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 31, 9:51 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hi,
>
> > I've this model:
>
> > from django.contrib.auth.models import User
>
> > class Player(models.Model):
> >     first_name = models.CharField(max_length=30)
> >     last_name = models.CharField(max_length=40)
> >     email = models.EmailField()
> >     user = models.ForeignKey(User, blank=True, null=True)
>
> > I try to set the email of the Player with the email of the User:
>
> > class Player(models.Model):
> >     first_name = models.CharField(max_length=30)
> >     last_name = models.CharField(max_length=40)
> >     email = models.EmailField(User.email)
> >     user = models.ForeignKey(User, blank=True, null=True)
>
> > but I've this error:
>
> >     email = models.EmailField(User.email)
> > AttributeError: type object 'User' has no attribute 'email'
>
> > Can I set the Player model with the email that automatically take the
> > value from the User that I choice:
>
> > example:
>
> > User: username='tommy' email='[EMAIL PROTECTED]"
>
> > Player: if I choice the user=tommy the email" automatically take the
> > value of the User -> [EMAIL PROTECTED]@gmail.com"
>
> > Alfredo
>
> Well, no, you can't do this in the way that you've tried above. I
> suppose you could override the save method to populate the model with
> the value of the email.
>
> But why would you want to? You already have a link from your Player to
> the associated User. So whenever you need the email, you just look in
> the related object:
>
> my_player.user.email
>
> --
> DR.


User don't have a email field.
Look here:
http://www.djangobook.com/en/1.0/chapter12/#cn222

for storing additional information for user :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with pyExcelerator and response

2008-10-31 Thread Steve Holden

Try replacing

workbook.save('output.xls')
return response

with

workbook.save('output.xls')
response.write(open('output.xls', 'b').read())
return response

regards
 Steve

laspal wrote:
> So how can I fix it.
> I am not able to fix it.
> Thanks
>
> On Oct 30, 4:26 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> laspalwrote:
>> 
>>> Any one can help me out.
>>> Thanks.
>>>   
>>> On Oct 29, 11:41 am,laspal<[EMAIL PROTECTED]> wrote:
>>>   
 Hi,
 I am trying to create Excel file usingpyExceleratorbut my problem is
 I am not able
 to attach file to response.
 
 code :
 workbook = Workbook()
 worksheet = workbook.add_sheet('My Test Sheet')
 
 worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
 worksheet.write(1,1, 'Hello World!', font_style('left', 1,
 'black'))
 worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
 
 response = HttpResponse( mimetype='application/vnd.ms-excel')
 response['Content-Disposition'] = 'attachment;
 filename=output.xls'
 workbook.save('output.xls')
 
return response.
 
 I am able to generate output.xl file but without any data.
 Can anyone help me out
 Thanks.
 
>> Correction: the "Content-Disposition" header is fine, but you do need to
>> write the file contents to the response.
>>
>> regards
>>  Steve
>> --
>> Steve Holden+1 571 484 6266   +1 800 494 3119
>> Holden Web LLC  http://www.holdenweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with pyExcelerator and response

2008-10-31 Thread laspal

So how can I fix it.
I am not able to fix it.
Thanks

On Oct 30, 4:26 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> laspalwrote:
> > Any one can help me out.
> > Thanks.
>
> > On Oct 29, 11:41 am,laspal<[EMAIL PROTECTED]> wrote:
> >> Hi,
> >> I am trying to create Excel file usingpyExceleratorbut my problem is
> >> I am not able
> >> to attach file to response.
>
> >> code :
> >> workbook = Workbook()
> >> worksheet = workbook.add_sheet('My Test Sheet')
>
> >> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
> >> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
> >> 'black'))
> >> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>
> >> response = HttpResponse( mimetype='application/vnd.ms-excel')
> >> response['Content-Disposition'] = 'attachment;
> >> filename=output.xls'
> >> workbook.save('output.xls')
>
> >>return response.
>
> >> I am able to generate output.xl file but without any data.
> >> Can anyone help me out
> >> Thanks.
>
> Correction: the "Content-Disposition" header is fine, but you do need to
> write the file contents to the response.
>
> regards
>  Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database API from external tools?

2008-10-31 Thread megrez80

I'm trying to accomplish the same thing: use django standalone.

After getting DJANGO_SETTINGS_MODULE set correctly so that it finds my
settings.py, I get:

  File "C:\Python25\Lib\site-packages\django\db\models\base.py", line
51, in __new__
kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range


Any ideas?

Ken


On Oct 26, 10:19 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Russell Keith-Magee wrote:
> > On Mon, Oct 27, 2008 at 6:05 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote:
>
> >> Russell Keith-Magee wrote:
>
> >>> On Sat, Oct 25, 2008 at 3:55 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote:
>
>  My question is how to package up and deploy the Django python code for
> externaltools to access the database? I'm hoping to have the Django app
>  sitting on the web server, with the source tree inaccessible to a bunch
>  of workstations. ...
>
> >>> If you just want the Django database API, then put the Django code
> >>> (i.e., django.*) on the workstations, and just write your tools to
> >>> import that code, setting up DJANGO_SETTINGS_MODULE as required.
>
> >>> If you also want your model definitions, then you're going to have to
> >>> deploy those too...
> >>> ...the model layer will work fine if the views are missing -
> >>> strictly, the only part of your code that should need to exist on the
> >>> workstation are the model definitions. Managing an extraction of a
> >>> partial checkout of your project code is left as an exercise for the
> >>> reader...
> >>> *Obviously, the easiest way to get all the required code is to do a
> >>> full checkout of your web application on the workstation...*
>
> >> Ok, thanks.
> >> I just wanted to confirm that duplicating the web app out to the
> >> workstations just so they can access the database API was the expected
> >> course of action in this scenario.
> >> It feels dirty to me!
>
> > No - that isn't what I said at all.
>
> > What I said is that you will need _pieces_ of the web app -
> > specifically the model   definitions, plus the main configuration
> > file. I expect that the model definitions will also have some
> > dependencies, but I can't tell what those are without seeing your
> > code.
>
> > The _easiest_ way to know you have satisfied all internal dependencies
> > is to copy the full web app. However, this is not the _only_ way, and
> > if you're willing to handle the configuration management issues, you
> > could provide a partial checkout and achieve the same outcome.
>
> Here's a specific example of a piece of code that uses a web app's
> models. It should get you started - just dive in and write some code!
> The tricky bit is providing the settings without using a "settings"
> module. I can't remember who I got this code from, but the kudos belongs
> to them, not me. Enjoy.
>
> regards
>  Steve
>
> from django.conf import settings
> settings.configure( DATABASE_ENGINE="postgresql_psycopg2",
>                     DATABASE_NAME ="PyTeach",
>                     DATABASE_USER='django',
>                     DATABASE_PASSWORD='djangopw',
>                     DATABASE_HOST='localhost',
>                     DATABASE_PORT='',
>                     INSTALLED_APPS=('info', 'invoicing', 'training'))
> from invoicing.models import (Address, Organization, Person, Project, Task)
> # I've chopped a lot of code that created and saves instances of other
> models
> hweb = Organization(
>     name="Holden Web, LLC",
>     notes="""A tidy little company that works with Django""")
> hweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User.email

2008-10-31 Thread Daniel Roseman

On Oct 31, 9:51 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I've this model:
>
> from django.contrib.auth.models import User
>
> class Player(models.Model):
>     first_name = models.CharField(max_length=30)
>     last_name = models.CharField(max_length=40)
>     email = models.EmailField()
>     user = models.ForeignKey(User, blank=True, null=True)
>
> I try to set the email of the Player with the email of the User:
>
> class Player(models.Model):
>     first_name = models.CharField(max_length=30)
>     last_name = models.CharField(max_length=40)
>     email = models.EmailField(User.email)
>     user = models.ForeignKey(User, blank=True, null=True)
>
> but I've this error:
>
>     email = models.EmailField(User.email)
> AttributeError: type object 'User' has no attribute 'email'
>
> Can I set the Player model with the email that automatically take the
> value from the User that I choice:
>
> example:
>
> User: username='tommy' email='[EMAIL PROTECTED]"
>
> Player: if I choice the user=tommy the email" automatically take the
> value of the User -> [EMAIL PROTECTED]@gmail.com"
>
> Alfredo


Well, no, you can't do this in the way that you've tried above. I
suppose you could override the save method to populate the model with
the value of the email.

But why would you want to? You already have a link from your Player to
the associated User. So whenever you need the email, you just look in
the related object:

my_player.user.email

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



User.email

2008-10-31 Thread Alfredo Alessandrini

Hi,

I've this model:

from django.contrib.auth.models import User

class Player(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField()
user = models.ForeignKey(User, blank=True, null=True)

I try to set the email of the Player with the email of the User:

class Player(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField(User.email)
user = models.ForeignKey(User, blank=True, null=True)


but I've this error:

email = models.EmailField(User.email)
AttributeError: type object 'User' has no attribute 'email'

Can I set the Player model with the email that automatically take the
value from the User that I choice:

example:

User: username='tommy' email='[EMAIL PROTECTED]"

Player: if I choice the user=tommy the email" automatically take the
value of the User -> [EMAIL PROTECTED]@gmail.com"



Alfredo

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



Re: Adding properties to models at run-time.

2008-10-31 Thread Daniel Roseman

On Oct 30, 10:13 pm, Alex G <[EMAIL PROTECTED]> wrote:
> Thanks for the reply, DR.
>
> How would I use the generic relationship without the backward link?
>
> I have the normal auth.user class, and I have the my.user class that
> extends it and has a polymorphic link pointing at auth.user.  The
> problem occurs when I collect a login/password, because I can't lookup
> my.user without the backward link, that is I can't
> my.user.filter(account__username = x, account__password = y) because
> polymorphic links don't allow this.  I also can't move in reverse, the
> auth.user.authenticate(username, password) function returns an
> auth.user, and I am unclear as to how I would get a my.user from this
> information without calling for my.user.objects.all() and comparing
> the link (which seems terribly, terribly inefficient...).  Is there a
> way to start with the target (auth.user) and get to my.user backward
> via the contenttype?

Something like (where 'dj_user' is the instance of
contrib.auth.models.User):

User.objects.get(account_id=dj_user.id,
account_polymorphic_link=ContentType.objects.get_for_model(dj_user))
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-31 Thread Håkan Waara

31 okt 2008 kl. 04.23 skrev Graham Dumpleton:

>
>
>
> On Oct 31, 10:14 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
>> Hi folks,
>>
>> I'm in the process of for the first time deploying a django site that
>> (unfortunately) needs to share its Apache with an existing PHP site.
>>
>> I've been reading a bunch about mod_wsgi and in many places there are
>> mentions that setting up apache with mpm-worker (basically
>> multithreaded mode) will not work if you're also hosting a PHP site  
>> on
>> the same Apache; Apache will crash, and the world will collapse...
>>
>> What I haven't been able to find out is if it's possible/worth it to
>> use mod_wsgi (efficiently) in this situation at all, and if so how to
>> do it?
>>
>> Does anyone have other suggestions on how to avoid mod_python in this
>> situation? Should I have a look at nginx for example?
>>
>> Any hints appreciated!
>
> It is not necessary to be running Apache worker MPM to run mod_wsgi,
> it will work quite happily in Apache prefork MPM, just like mod_python
> can. Also note that if you have problems with mod_wsgi, using
> mod_python will not help as it can be impacted by exactly the same
> problems.
>
> Now, which MPM you use is not the problem you seem to think it is. The
> real problem is generally going to be mismatches in what versions of
> shared libraries that PHP uses compared to what various Python modules
> require. The main culprit for this is MySQL as PHP generally uses a
> non reentrant variant of MySQL client libraries where as Python MySQL
> module generally uses a reentrant variant of the library. Result of
> this can be Apache crashing.
>
> Other problems can also arise if you are using Debian and the broken
> Python 2.4 that Debian released. Specifically, Debian folks fiddled
> with the hash module code in Python 2.4 and caused a conflict between
> it and a hash module in PHP. This can cause problems with session IDs
> being generated incorrectly and causing session mechanisms to fail, or
> could also crash Apache.
>
> These issues and others can be found described in:
>
>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
>
> Now, although mod_wsgi can be used with Apache prefork MPM and you can
> run your Django application in embedded mode, because prefork means
> more Apache child processes, you might not find it desirable that your
> fat Django application then causes Apache as a whole to use up so much
> memory. In this situation, don't run your Django in mod_wsgi embedded
> mode, instead create a mod_wsgi daemon mode process groups and
> delegate Django to run in that instead. Use one multithreaded daemon
> mode process, or if your Django application isn't thread safe, a small
> number of single threaded processes.
>
> For some quick examples of embedded versus daemon mode configuration
> see:
>
>  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> You should also go through other documentation on the mod_wsgi site
> properly as well though. Don't assume that just reading one page, or
> some ones blog on how they did it, or relying on answers to questions
> you get from irc channels is going to be sufficient. This is why the
> documentation exists.

Thank you for this extremely informative post, Graham!

Your heads up on the hash issue was also most appreciated -- it's very  
likely I'd run into it otherwise, because I'm running python2.4 on  
debian (etch). I might as well have to update to a newer Python version.

/Håkan


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



Re: access request.user in clean method of ModelForm

2008-10-31 Thread Michel Thadeu Sabchuk

Hi Merrick,

> How can I access request.user in a clean method of a ModelForm?
>
> class UserEmailForm(ModelForm):
> ...
>

You can instantiate your form passing the request or the user as
argument:

class UserEmailForm(ModelForm):
def __init__(self, *args, **kw):
self.request = kw.pop('request')
super(UserEmailForm, self).__init__(*args, **kw)

def clean_some_field(self):
print self.request.user
...

form = UserEmailForm(request.POST, request=request)

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



Re: 500 displayed instead of 404

2008-10-31 Thread janedenone



On 29 Okt., 14:00, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> > Thanks to all who answered, now I'll go looking for the person who
> > messed with the development machine.
>
> Everybody can make mistakes. The root of the problem is (or was)
> that you don't see tracebacks if settings.DEBUG=False.

The issue only occurred when DEBUG was set to False (with DEBUG =
True, the templates were never used).

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



access request.user in clean method of ModelForm

2008-10-31 Thread Merrick

How can I access request.user in a clean method of a ModelForm?

I have the following code in forms.py:

===
#profle email form
class UserEmailForm(ModelForm):
class Meta:
model = User
fields = ['email',]

def clean_email(self):
email_submitted = self.cleaned_data.get('email')
email_exists =
User.objects.filter(email=email_submitted).exclude(username=request.user.username).count()

if email_exists:
raise forms.ValidationError('That email address is in
use')
else:
return email
===

When I attempt to pull up the form, I get this error:

===
NameError at /profile/update

global name 'request' is not defined

Request Method: POST
Request URL:http://dev.twiturl.com/profile/update
Exception Type: NameError
Exception Value:

global name 'request' is not defined
===

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



Access request.user in a clean method of a ModelForm

2008-10-31 Thread Merrick

I have the code below:
===
class UserEmailForm(ModelForm):
class Meta:
model = User
fields = ['email',]

def clean_email(self):
email_submitted = self.cleaned_data.get('email')
email_exists =
User.objects.filter(email=email_submitted).exclude(username=request.user.username).count()

if email_exists:
raise forms.ValidationError('That email address is in
use')
else:
return email
===

And when I try to request the form with my browser I get the following
error:

===
NameError at /profile/update

global name 'request' is not defined

Request Method: POST
Request URL:http://mydomain.com/profile/update
Exception Type: NameError
Exception Value:

global name 'request' is not defined

Exception Location: /var/virtualhosts/twiturl_com/redirect/forms.py
in clean_email, line 18
===

How do I access request.user in the clean_email method of the
UserEmailForm ModelForm?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query subset

2008-10-31 Thread Russell Keith-Magee

On Fri, Oct 31, 2008 at 4:08 PM, Tonne <[EMAIL PROTECTED]> wrote:
>
> So, what I've done is use Model.objects.values() to limit the returned
> values, which is not ideal as I'm losing the objectness of the
> queryset.
>
> I've worked around the loss Queryset.get_absolute_url by using a less
> than elegant semi-hardcoded url.
>
> So if I'm missing a blindingly obvious way of limiting a query to
> nominated fields so that I can still keep the benefits of a queryset,
> please let me know.

Right at the moment, there is no easy way to retrieve a subset of the
fields on a model _and_ retain the 'modelness' of the data. values()
querysets returns dictionaries, normal querysets return model
instances.

It sounds like ticket #5420 [1] describes the feature you are looking
for; there has been some work on this ticket, but it isn't available
in the trunk yet.

[1] http://code.djangoproject.com/ticket/5420

> Also, is using Model.objects.values() to limit the fields returned
> actually more efficient than Model.objects.all() in terms of database
> hits?

As always, the answer is "it depends", but generally speaking, if you
have a model with a lot of columns (especially a lot of large text
columns), a values() queryset will be more efficient.

The efficiency gains are due to the reduction in the amount of data
that is being retrieved from the database, and the volume of data that
is transmitted. If your database has to do less paging to return
results, and the volume of data that is transmitted is lower, the
results will be retrieved faster. However, if each database record
fits on a single page, or the protocol overhead associated with
returning a row is comparable in size to the row itself, the
efficiency gains will be minimal.

Also, the efficiency gains of using values() will be largely negated
if you end up doing multiple values() calls to retrieve the rest of
the data. If you're going to need all the data anyway, it may be
faster to live with the initial performance hit.

Yours,
Russ Magee %-)

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



Re: Query subset

2008-10-31 Thread Marcelo Ramos

On Fri, Oct 31, 2008 at 5:08 AM, Tonne <[EMAIL PROTECTED]> wrote:
>
> So, what I've done is use Model.objects.values() to limit the returned
> values, which is not ideal as I'm losing the objectness of the
> queryset.
>
> I've worked around the loss Queryset.get_absolute_url by using a less
> than elegant semi-hardcoded url.
>
> So if I'm missing a blindingly obvious way of limiting a query to
> nominated fields so that I can still keep the benefits of a queryset,
> please let me know.

You are right about not having the full functionality of the objects
and I don't know
about a way to keep it while restricting the fields retrieved by the query.

> Also, is using Model.objects.values() to limit the fields returned
> actually more efficient than Model.objects.all() in terms of database
> hits?

Not in terms of database hits, but yes in terms of the "size" of the
retrieved data. If you are avoiding
a lot of fields the difference in traffic size from the database can be big.

Regards.

-- 
Marcelo Ramos

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



Re: Query subset

2008-10-31 Thread Tonne

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



Re: fetching images from database

2008-10-31 Thread Marcelo Ramos

On Fri, Oct 31, 2008 at 4:06 AM, please smile <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>   I have uploaded some images in a folder and also saved  the image name
> into  data base table.
> Now I need to fetch and display all the images to my client side web page .
> How can I do this .Please help.
> Thanks

If you use an ImageField to store the images then you can easily show them with
the url() method of each image object in your templates.

Look at http://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield and
http://docs.djangoproject.com/en/dev/topics/files/#using-files-in-models
for more info.

Regards.

-- 
Marcelo Ramos

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



Re: Query subset

2008-10-31 Thread Tonne

So, what I've done is use Model.objects.values() to limit the returned
values, which is not ideal as I'm losing the objectness of the
queryset.

I've worked around the loss Queryset.get_absolute_url by using a less
than elegant semi-hardcoded url.

So if I'm missing a blindingly obvious way of limiting a query to
nominated fields so that I can still keep the benefits of a queryset,
please let me know.

Also, is using Model.objects.values() to limit the fields returned
actually more efficient than Model.objects.all() in terms of database
hits?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query subset

2008-10-31 Thread Marcelo Ramos

On Fri, Oct 31, 2008 at 4:37 AM, Tonne <[EMAIL PROTECTED]> wrote:
>
> I have spent hours looking in the docs and one this list for an answer
> to this problem:
>
> I have a model that has, for example, 20 fields.
>
> On my site's homepage, where I'd like to offer a preview version of
> the object, I'd need to retrieve only say, half of those fields to be
> displayed.
>
> My dilemma is whether to simply use a Model.objects.all() query and
> ignore the unnecessary data in the template, or find a more efficient
> way to call only the data I need.
>
> Perhaps my model design is flawed and I should separate out the data
> that is not common to the list and detail version of the content, or
> perhaps I should have a model method that returns only the data fields
> I need, etc.

There is nothing wrong with having a model with 20 fields if you keep
the DRY (Don't Repeat Yourself) principle.
I mean, if you are not sharing a subset of those fields with another
model then it is ok.

I think you need the values() method. It receives the fields you want
to get as positional parameters (restricting
the select sql query only to those fields).

You can read the docs
http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
for further information.

Regards.

-- 
Marcelo Ramos

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



Query subset

2008-10-31 Thread Tonne

I have spent hours looking in the docs and one this list for an answer
to this problem:

I have a model that has, for example, 20 fields.

On my site's homepage, where I'd like to offer a preview version of
the object, I'd need to retrieve only say, half of those fields to be
displayed.

My dilemma is whether to simply use a Model.objects.all() query and
ignore the unnecessary data in the template, or find a more efficient
way to call only the data I need.

Perhaps my model design is flawed and I should separate out the data
that is not common to the list and detail version of the content, or
perhaps I should have a model method that returns only the data fields
I need, etc.

Forgive me, as I'm very new to this, but I'm stumped. Any suggestions
would be gratefully received.


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



Re: Help regarding Login form in client side (front end) in Django.

2008-10-31 Thread Steve Holden

sadeesh Arumugam wrote:
> Hi Friends,
>
>  I want to create a login form in client side, anybody please send me
> the Sample login page for the client side coding..
>
Are you reading the answers to your questions before sending them out again?

regards
 Steve


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



Help regarding Login form in client side (front end) in Django.

2008-10-31 Thread sadeesh Arumugam
Hi Friends,

 I want to create a login form in client side, anybody please send me the
Sample login page for the client side coding..

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



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-31 Thread Graham Dumpleton



On Oct 31, 4:09 pm, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> > Also indicate how much traffic each site gets and whether any would
> > potentially be idle for periods, as can then look at inactivity
> > timeouts etc.
>
> As embarrassing as it sounds, I don't have good numbers available yet. There
> are definite idle periods on certain virtual hosts.

If there are definite idle periods of reasonable size, perhaps look at
'inactivity-timeout' option to WSGIDaemonProcess. This way daemon
process will be restarted when doing nothing, and providing that
preloading not configured using WSGIImportScript, then process size
will be quite small until next needed, at which point it will load
application again.

To counter risk of daemon process growing in size because of memory
creep in application you don't know about, also look at 'maximum-
requests' option to WSGIDaemonProcess.

> > Rather than event MPM, would suggest using nginx as a front end, with
> > nginx serving requests for static files and then proxying other
> > requests through to Apache/mod_wsgi. This is because nginx is arguably
> > better at serving static files and maintaining many open connections
> > with keep alive. The Apache/mod_wsgi instance would then only be
> > handling dynamic requests and all connections would come from local
> > nginx. Even if keep alive working there, depending on how optimised
> > nginx is, it can possibly reuse the connections over time for requests
> > from different originating clients in a more efficient way, thereby
> > keeping the memory overhead in Apache which generally arises from
> > maintaining open connections from lots of different clients.
>
> I considered nginx, but I've been playing with S3 and I think I'm going to
> use that as a poor mans edge system for my static content. But I'll keep
> this in mind. Would using a event mpm help if I didnt have to serve static
> content or need Keep-Alive?

If Apache/mod_wsgi only handling dynamic content, wouldn't see that
event MPM would make any difference. If only handling dynamic content,
turning off keep alive on Apache may help though as unlikely one will
get concurrent requests over same socket for dynamic web page, and so
can give up client connection straight away and not tie up Apache
processes/threads for period that timeout takes to trigger for keep
alive.

In respect of having nginx in front, one of the over benefits of that
was that nginx could have been quite selective about the URLs that it
was proxying. That way if you get a SPAM bot or similar hitting the
site, it could have been blocked at nginx without even going through
to Apache/mod_wsgi, presuming that such a bot was hitting known URLs
for security holes in PHP packages or the like. One may also have been
able to filter SPAM bot traffic at nginx level through user agent or
other things. Thus, nginx could have further been used as a filter
point to limit traffic going through to Apache.

> WSGIPythonOptimize 1

Surprised if this will make much difference. Worth a try but don't
expect it to do much. For a start, as it is a long running process,
any benefit at process start when loading smaller .pyo files is only
for that time and not later when handling actual requests.

> 
>     StartServers          30
>     MinSpareServers       30
>     MaxClients            30
> 

If not using PHP on same Apache, better to use Apache worker MPM as
then cut down on number of Apache child process and still just as
capable at handling load of static files and proxying to mod_wsgi
daemon processes.

>     Alias /media/ /data/daaku/media/
>     
>         SetHandler None

The 'SetHandler None' should not be needed here. This was a mod_python
requirement but mod_wsgi shouldn't need it.

Graham

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



fetching images from database

2008-10-31 Thread please smile
Hi All,

  I have uploaded some images in a folder and also saved  the image name
into  data base table.
Now I need to fetch and display all the images to my client side web page .
How can I do this .Please help.
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---