Re: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Aspersieman

Lic. José M. Rodriguez Bacallao wrote:
> I will recommend Arch, is simple and powerful.
>
> On Dec 11, 2007 1:22 PM, Joe <[EMAIL PROTECTED]> wrote:
>   
>> To make things easy, you could download VMware Server - run that on
>> your windows box and install the prebuilt appliances. That'd make it
>> easy to try out a few linux versions. VMware is free as are the
>> appliances.
>>
>> I use ubuntu primarily.
>>
>> j
>>
>>
>> On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
>> 
>>> Hello,
>>>
>>> till now I've been experimenting with Django (development version)
>>> under Win2k. But Windows sucks. So I dare to make my first steps with
>>> Linux. Most of you will surely say I won't regret this decision ;-).
>>> But since I haven't any experience with Linux yet, I want to choose a
>>> distribution that is best suited for someone coming from the Windows-
>>> world AND suited to establish a Django development environment. Well,
>>> I'm not even sure if there will be any great difference between
>>> several distributions regarding these aspects. Any comment is welcome.
>>>
>>> Regards,
>>> Andreas
>>>
>>>   
>
>
>
>   
I second the Arch suggestion - it's awesome!

-- 

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle.



--~--~-~--~~~---~--~~
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: Strange error, trying to deploy Django with mod_wsgi

2007-12-11 Thread Graham Dumpleton

On Dec 12, 3:18 pm, Michael Best <[EMAIL PROTECTED]> wrote:
> yml wrote:
> > Hello Steve,
>
> > Sometimes ago when I first try to use mod_wsgi I have written a wiki
> > page there:
> >*http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
> > It is a step by step procedure that I have followed to configure
> > mod_wsgi. It might help you to get your application up and running
> > with mod_wsgi.
>
> > Good luck
>
> I've tried my best to get this working on Linux (Centos 5), but I find
> that my Apache vhost just hangs and never returns any pages.
>
> Any tips would be great.

Probably better to go to:

  http://groups.google.com/group/modwsgi

and post question there as sounds more specific to mod_wsgi than
Django.

Ensure that you have first tried simple hello world example from
mod_wsgi configuration guidelines:

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

If using daemon mode, run same example in daemon mode as well to make
sure that works before even attempting to set up Django.

Also look at:

  http://code.google.com/p/modwsgi/wiki/InstallationIssues
  http://code.google.com/p/modwsgi/wiki/ApplicationIssues

Especially take note of shared library conflicts described in that
document.

Make sure you have set Apache LogLevel directive to 'debug' to capture
as much log output as possible so you can provide information when
requested.

The official mod_wsgi/Django documentation is actually at:

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

Even then, there can be more to it than that depending on how you are
trying to set it up.

In going to other list, make sure you provide as much information as
possible, such as mod_wsgi version, Apache configuration for setting
up mod_wsgi that you used, relevant messages from Apache error log
from time of restart up to and including the request you made.

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: Accessing Multiple Databases

2007-12-11 Thread [EMAIL PROTECTED]

There is a Multiple Database Branch which is not under active
development...and doesn't have some of the new stuff in the
trunk...but I'm using it in one of my projects...works pretty good for
the most part.

http://code.djangoproject.com/wiki/MultipleDatabaseSupport

On Dec 11, 2:48 pm, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
> I read through all the relevant documentation but I couldn't find any
> info on an issue I am about to face: accessing multiple tables in
> different databases with Django.
>
> Here's a quick example:
> My Django app (MyApp) has r/w access to the MyApp database on
> MySQLserver1, and all of MyApp models live within here. I now need to
> access a pre-existing database/table on MySQLserver2 to bring in some
> data relevant to MyApp.
>
> My ultimate question is: does Django support accessing models that live
> in/on different databases/servers within one app? If so, how do I do
> this? If not, what should I be doing?
>
> Thanks,
> Derek
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Country, State and City data

2007-12-11 Thread Chris Moffitt
We have country and admin area (i.e. state/province) included in Satchmo.

You can see the models here -
http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/l10n

The actual data is an XML file in the fixtures directory.

Geonames - http://www.geonames.org/ is a big open source database with a lot
more info in it.  There is also info about how to download and install in
MySql databases.

-Chris

--~--~-~--~~~---~--~~
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: Strange error, trying to deploy Django with mod_wsgi

2007-12-11 Thread Michael Best

yml wrote:
> Hello Steve,
> 
> Sometimes ago when I first try to use mod_wsgi I have written a wiki
> page there:
>* http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
> It is a step by step procedure that I have followed to configure
> mod_wsgi. It might help you to get your application up and running
> with mod_wsgi.
> 
> Good luck

I've tried my best to get this working on Linux (Centos 5), but I find
that my Apache vhost just hangs and never returns any pages.

Any tips would be great.

-Mike


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

2007-12-11 Thread James Bennett

On Dec 11, 2007 7:57 PM, Goldy <[EMAIL PROTECTED]> wrote:
> My Django database was created using sqlite3 and therefore produced a
> file called mydb.py.
> I was wondering if this file could be connected to and examined
> interactively by sqlite3 as if i had inserted the tables myself?

Why wouldn't you be able to? It's just a SQLite database; as long as
you have the right version of the client library, what sort of problem
would you 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
-~--~~~~--~~--~--~---



not really a django problem, just fishing here--

2007-12-11 Thread Jason Witherspoon

Hey everyone--

I've been trying to run Xapian alongside my Django app for lo, many  
moons now.

Here's the problem I run into:  Xapian is compiled to work w/a Python  
that's been configured for ucs4 support (this is a manner of handling  
unicode).  Won't work w/ucs2, far as I can tell.

When I try recompiling my Python to work w/Xapian, it breaks my  
psycopg2, which was compiled for ucs2 support.

Okay, no problem, I blitz every instance/egg of psycopg2 & install it  
fresh on top of my new ucs4-compliant Python.

Which lends some bizarre results-- in my best-case scenario (after  
several days of trial & error), I could get the psycopg2 module to  
load fine from IDLE, but it nonetheless still yielded non-stop  
"undefined symbol: PyUnicodeUCS4_[whatever]" errors when I tried to  
access my Django setup.

The only place I can find these PyUnicodeUCS[2/4] modules/whatevers  
(?) is in Jython, so I clean installed that for the heck of it.  No  
dice.

Anyone run across anything like this?  After some hairiness I've  
successfully returned to a working Python ucs2 configuration.  And  
I've asked on Xapian-discuss if a usc2-build exists, which would  
solve the problem nicely.  And wouldn't it be nice if Python just  
handled both ucs2 & ucs4, depending on what was required?  Yeah, I  
know, dream on

Any help much appreciated, and I actually know a lot more about this  
stuff than I'd prefer to now, so if this sounds comparable to a  
problem you've been having feel free to hit me backchannel & I can  
share what I know

--~--~-~--~~~---~--~~
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: Import RSS headlines from feeds into django based pages.

2007-12-11 Thread Peter Baumgartner

> I want to add in a django page some rss feeds from another websites,
> like headlines from news portals. how can I do that without
> javascript, java and inline frames?
>

http://www.djangosnippets.org/snippets/384/

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



a better DateTime widget

2007-12-11 Thread James Turk

I was wondering if anyone had experience with building a better
DateTimeWidget, I've built my own and am looking to clean it up and
make it available to the general public perhaps with some advanced
formatting options.

Are there any DateTimeWidgets in common use that use selects instead
of a text field?

Would this be useful to others, also do you think this is something
that could perhaps be contributed back into django?


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



Re: Views that don't return anything

2007-12-11 Thread James Turk

Any HTTP request is going to send a status code on return.  I'd
recommend returning a blank page or something just so that the server
can return a 200-OK.

On Dec 11, 9:04 pm, "Doug Penny" <[EMAIL PROTECTED]> wrote:
> I am trying to create a view that processes some data, but doesn't
> return anything.  The data is being submitted from within a
> client-side, desktop app and should be completely transparent to the
> user.  I currently do not have a return statement in the view and am
> getting a HTTP 500 status code on the console.  Is there anyway to
> tell Django that I don't want to return anything for a view without
> getting an error on the console?  Thanks for the help.
>
> Sincerely,
> Doug Penny
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Views that don't return anything

2007-12-11 Thread Doug Penny

I am trying to create a view that processes some data, but doesn't
return anything.  The data is being submitted from within a
client-side, desktop app and should be completely transparent to the
user.  I currently do not have a return statement in the view and am
getting a HTTP 500 status code on the console.  Is there anyway to
tell Django that I don't want to return anything for a view without
getting an error on the console?  Thanks for the help.

Sincerely,
Doug Penny

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



Database

2007-12-11 Thread Goldy

My Django database was created using sqlite3 and therefore produced a
file called mydb.py.
I was wondering if this file could be connected to and examined
interactively by sqlite3 as if i had inserted the tables myself?
--~--~-~--~~~---~--~~
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: about tagging app and tags cloud

2007-12-11 Thread Kellen

There's a bug:
http://code.google.com/p/django-tagging/issues/detail?id=54

For which there is a patch, which changes in tagging/utils.py:
-thresholds = [math.pow(max_weight - min_weight + 1,
float(i) / float(steps)) \
+thresholds = [min_weight + math.pow(max_weight -
min_weight, float(i) / float(steps)) \

On Dec 11, 10:00 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> I'm controling the font size with CSS, that is not the problem, the
> problem is with the code for tags cloud that it doesn't generate the
> font_size attr for some tags.
>
> On Dec 11, 2007 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Just control the default font size with a little CSS? (presuming
> > you're using this for [X]HTML output)
>
> > On Dec 11, 8:26 pm, "Lic. José M. Rodriguez Bacallao"
>
> > <[EMAIL PROTECTED]> wrote:
> > > hi folks, I need to generate a tags cloud for a model and I'm using
> > > the tagging app from google code. I do something like this:
>
> > > cloud = Tag.objects.cloud_for_model(NewsEntry, 6)
>
> > > and generate the html cloud based in the "font_size" attr from the
> > > tags list "cloud". The problem come when I realize that some of the
> > > tags in that list (cloud) doesn't contain a "font_size" attr> I was
> > > looking inside the code of the tagging app and I saw that when the
> > > "count" attr of the tag is less than any of the values of threshold
> > > list it doesn't add the "font_size" attr, so, how can I generate the
> > > tags cloud?
>
> > > --
> > > Lic. José M. Rodriguez Bacallao
> > > Cupet
> > > -
> > > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
> > > mismo.
>
> > > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > > por profesionales
> > > -
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
--~--~-~--~~~---~--~~
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: Admin

2007-12-11 Thread Goldy

Got it thanks!

On Dec 11, 10:58 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> On Dec 11, 5:38 pm, Goldy <[EMAIL PROTECTED]> wrote:
>
> > Thank you, where would i insert, verbose_name_plural = "breweries"
> > into ?
>
> In the Meta inner class. See below...
>
>
>
> > class Brewery (models.Model):
> > name = models.CharField(maxlength=60)
> > status = models.CharField(maxlength=8)
> > address = models.CharField(maxlength=60)
> > postcode = models.CharField(maxlength=8)
> > county = models.CharField(maxlength=40)
> > phone = models.IntegerField(maxlength=11)
> > fax = models.IntegerField(maxlength=11)
> > website = models.URLField()
> > email = models.CharField(maxlength=50)
>
> > def __str__(self):
> > return self.name
>
>   class Meta:
>   verbose_name_plural = "breweries"
--~--~-~--~~~---~--~~
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: Country, State and City data

2007-12-11 Thread Alex Ezell
Why not let them freehand it and then geocode it, so you have a standard way
to search it?
Of course, not knowing how you will use it, I could be making no sense :)

/alex

On Dec 11, 2007 3:59 PM, <[EMAIL PROTECTED]> wrote:

>
> I'm building a django site that requires the user to select their
> geographical location.
>
> Does anyone knows where can I get this country/state/city data in a
> format that can be imported into MySQL?
>
> Thanks in advance,
> Carlos
> >
>

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



django REST: update tables

2007-12-11 Thread crybaby

I have a view which allows users to upload pictures and add tags,
description to them.  I have to update two tables: post and img

If I want to do this by REST, how do you do this?  Is REST only suited
for manipulating one resource(one table) at a time?
--~--~-~--~~~---~--~~
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: Admin

2007-12-11 Thread Rajesh Dhawan



On Dec 11, 5:38 pm, Goldy <[EMAIL PROTECTED]> wrote:
> Thank you, where would i insert, verbose_name_plural = "breweries"
> into ?

In the Meta inner class. See below...

>
> class Brewery (models.Model):
> name = models.CharField(maxlength=60)
> status = models.CharField(maxlength=8)
> address = models.CharField(maxlength=60)
> postcode = models.CharField(maxlength=8)
> county = models.CharField(maxlength=40)
> phone = models.IntegerField(maxlength=11)
> fax = models.IntegerField(maxlength=11)
> website = models.URLField()
> email = models.CharField(maxlength=50)
>
> def __str__(self):
> return self.name

  class Meta:
  verbose_name_plural = "breweries"


--~--~-~--~~~---~--~~
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 model fields not working?

2007-12-11 Thread [EMAIL PROTECTED]

Never mind, I see it's to do with database backends.

On Dec 11, 10:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> OK, well now, for some reason whenever I use a custom field Django
> just ignores it when running syncdb. If I ask it for the raw SQL
> output I can see that the field is being omitted entirely. Even if I
> do something simple like:
>
> class TestField(models.TextField):
>  pass
>
> Does anyone know what I am doing wrong?
>
> On Dec 11, 9:04 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
>
> > On Dec 11, 2007 3:42 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > When I try to run syncdb on a model which uses the PickledObjectField
> > > (see my sample model athttp://dpaste.com/hold/27713/), I get this
> > > traceback:-
>
> > Your problem is that you're importing the PickledObjectField into your
> > class's namespace. So when Django processes your form definition, it's
> > actually getting two attributes:
>
> > * lookups (instantiated, which will work fine)
> > * PickledObjectField (uninstantiated, which will cause errors)
>
> > Move the import statement to the top of your models.py file, where it
> > belongs, and you should find that the error goes away.
>
> > There are no doubt other things you'll run into, but I'll at least
> > give you a chance to work them out on your own. :)
>
> > -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: Admin

2007-12-11 Thread Goldy

Thank you, where would i insert, verbose_name_plural = "breweries"
into ?

class Brewery (models.Model):
name = models.CharField(maxlength=60)
status = models.CharField(maxlength=8)
address = models.CharField(maxlength=60)
postcode = models.CharField(maxlength=8)
county = models.CharField(maxlength=40)
phone = models.IntegerField(maxlength=11)
fax = models.IntegerField(maxlength=11)
website = models.URLField()
email = models.CharField(maxlength=50)

def __str__(self):
return self.name

class Admin:
list_display = ('name', 'status', 'address', 'county',
'phone', 'fax', 'website', 'email')
list_display_links = ('name', 'status')
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Graham Dumpleton

On Dec 12, 6:21 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi again,
>
> > 3. I'm using prefork MPM on apache with maxclients set to 1000.
>
> Apart from Joe's excellent profiling suggestion, I would recommend
> reducing maxclients to a much lower value (like say 100) and then
> increasing it gradually.
>
> From your description of the sluggish response of your web server, it
> looks like the machine may be swapping to disk. Each of your clients
> fires up a Python VM taking up several tens of MB of RAM.

To clarify on this comment. Each of the 'clients' does not fire up a
Python VM.

The Python framework as a whole is initialised only once per Apache
child process. This initialisation as a side effect will always create
the main Python interpreter instance for the Apache child process.

Unless you use PythonInterpreter directive to force site to always run
in the main Python interpreter instance, then by default an additional
Python sub interpreter instance will be created per virtual host. The
per virtual host sub interpreter instance will be created the first
time a request to mod_python for that virtual host is received.

When any interpreter instance is created within an Apache child
process, that interpreter instance will then persist for the life of
that process and will be used in handling all requests which map to
that interpreter instance.

A Python interpreter instance when first created and before any web
application is loaded should only add a few hundred kilobytes,
although mod_python adds on top of that with its dispatch code, it is
not tens of MBs though. Thus to say that 'Python VM taking up several
tens of MB of RAM' isn't accurate. If you are seeing this sort of
memory usage from just loading mod_python, then you have a Python
installation which doesn't provide a shared library for Python and
which also may include debug symbols.

Now, when a Django site instance is loaded, typically this can add
about 5MB per process. This value will increase over time based on
your application and how it uses memory based on database queries and
internal operations. Yes this can get up to tens of MBs, but that is
from the Django application and not mod_python or Python itself.

> Even if each
> VM takes up just 20MB (it's probably more than that), a thousand
> clients will eat up 20GB, forcing your machine to swap.

This can be a problem if using prefork, so dropping max clients to a
level more realistic for the amount of memory available is a good
idea. If memory is still an issue, then validating that your
particular Django application is thread safe would be worthwhile and
switch to worker MPM for Apache instead.

Although worker MPM uses multithreading, claims that the GIL would be
a problem is not the big issue some would say it is. This is because
Apache is a multiprocess web server so there is no restriction on
making good use of multiple processes and cores.

As far as memory overhead goes, mod_wsgi uses less base level memory
than mod_python. The per request overhead of mod_wsgi is also less
than mod_python, so if you really wanted to squeeze as much as
possible out of what you got, mod_wsgi should be better. That said,
realistically though the bottlenecks appear to be in the application
or database rather than underlying web server adapter.

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: Custom model fields not working?

2007-12-11 Thread [EMAIL PROTECTED]

OK, well now, for some reason whenever I use a custom field Django
just ignores it when running syncdb. If I ask it for the raw SQL
output I can see that the field is being omitted entirely. Even if I
do something simple like:

class TestField(models.TextField):
 pass

Does anyone know what I am doing wrong?

On Dec 11, 9:04 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Dec 11, 2007 3:42 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > When I try to run syncdb on a model which uses the PickledObjectField
> > (see my sample model athttp://dpaste.com/hold/27713/), I get this
> > traceback:-
>
> Your problem is that you're importing the PickledObjectField into your
> class's namespace. So when Django processes your form definition, it's
> actually getting two attributes:
>
> * lookups (instantiated, which will work fine)
> * PickledObjectField (uninstantiated, which will cause errors)
>
> Move the import statement to the top of your models.py file, where it
> belongs, and you should find that the error goes away.
>
> There are no doubt other things you'll run into, but I'll at least
> give you a chance to work them out on your own. :)
>
> -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
-~--~~~~--~~--~--~---



Country, State and City data

2007-12-11 Thread weissblitz

I'm building a django site that requires the user to select their
geographical location.

Does anyone knows where can I get this country/state/city data in a
format that can be imported into MySQL?

Thanks in advance,
Carlos
--~--~-~--~~~---~--~~
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 model fields not working?

2007-12-11 Thread [EMAIL PROTECTED]

You're a saint, you know that?

On Dec 11, 9:04 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Dec 11, 2007 3:42 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > When I try to run syncdb on a model which uses the PickledObjectField
> > (see my sample model athttp://dpaste.com/hold/27713/), I get this
> > traceback:-
>
> Your problem is that you're importing the PickledObjectField into your
> class's namespace. So when Django processes your form definition, it's
> actually getting two attributes:
>
> * lookups (instantiated, which will work fine)
> * PickledObjectField (uninstantiated, which will cause errors)
>
> Move the import statement to the top of your models.py file, where it
> belongs, and you should find that the error goes away.
>
> There are no doubt other things you'll run into, but I'll at least
> give you a chance to work them out on your own. :)
>
> -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: Custom model fields not working?

2007-12-11 Thread Marty Alchin

On Dec 11, 2007 3:42 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> When I try to run syncdb on a model which uses the PickledObjectField
> (see my sample model at http://dpaste.com/hold/27713/), I get this
> traceback:-

Your problem is that you're importing the PickledObjectField into your
class's namespace. So when Django processes your form definition, it's
actually getting two attributes:

* lookups (instantiated, which will work fine)
* PickledObjectField (uninstantiated, which will cause errors)

Move the import statement to the top of your models.py file, where it
belongs, and you should find that the error goes away.

There are no doubt other things you'll run into, but I'll at least
give you a chance to work them out on your own. :)

-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: about tagging app and tags cloud

2007-12-11 Thread Lic. José M. Rodriguez Bacallao
I'm controling the font size with CSS, that is not the problem, the
problem is with the code for tags cloud that it doesn't generate the
font_size attr for some tags.

On Dec 11, 2007 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Just control the default font size with a little CSS? (presuming
> you're using this for [X]HTML output)
>
> On Dec 11, 8:26 pm, "Lic. Jos� M. Rodriguez Bacallao"
>
> <[EMAIL PROTECTED]> wrote:
> > hi folks, I need to generate a tags cloud for a model and I'm using
> > the tagging app from google code. I do something like this:
> >
> > cloud = Tag.objects.cloud_for_model(NewsEntry, 6)
> >
> > and generate the html cloud based in the "font_size" attr from the
> > tags list "cloud". The problem come when I realize that some of the
> > tags in that list (cloud) doesn't contain a "font_size" attr> I was
> > looking inside the code of the tagging app and I saw that when the
> > "count" attr of the tag is less than any of the values of threshold
> > list it doesn't add the "font_size" attr, so, how can I generate the
> > tags cloud?
> >
> > --
> > Lic. Jos� M. Rodriguez Bacallao
> > Cupet
> > -
> > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
> > mismo.
> >
> > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > por profesionales
> > -
> >
>



-- 
Lic. Jos� M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

--~--~-~--~~~---~--~~
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: about tagging app and tags cloud

2007-12-11 Thread [EMAIL PROTECTED]

Just control the default font size with a little CSS? (presuming
you're using this for [X]HTML output)

On Dec 11, 8:26 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> hi folks, I need to generate a tags cloud for a model and I'm using
> the tagging app from google code. I do something like this:
>
> cloud = Tag.objects.cloud_for_model(NewsEntry, 6)
>
> and generate the html cloud based in the "font_size" attr from the
> tags list "cloud". The problem come when I realize that some of the
> tags in that list (cloud) doesn't contain a "font_size" attr> I was
> looking inside the code of the tagging app and I saw that when the
> "count" attr of the tag is less than any of the values of threshold
> list it doesn't add the "font_size" attr, so, how can I generate the
> tags cloud?
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom model fields not working?

2007-12-11 Thread [EMAIL PROTECTED]

Hey everyone,

I've asked a little in the Django IRC, but nobody seems to be able to
help. I'm trying to implement a custom model field, and I really can't
figure out why I keep getting errors. My code for my fields module is
at http://dpaste.com/hold/27712/

When I try to run syncdb on a model which uses the PickledObjectField
(see my sample model at http://dpaste.com/hold/27713/), I get this
traceback:-

Macintosh:sandbox Oliver$ cd /Django/sandbox && python manage.py
syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/Django Source/django/core/management/__init__.py", line 272,
in execute_manager
utility.execute()
  File "/Django Source/django/core/management/__init__.py", line 219,
in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Django Source/django/core/management/base.py", line 70, in
run_from_argv
self.execute(*args, **options.__dict__)
  File "/Django Source/django/core/management/base.py", line 83, in
execute
self.validate()
  File "/Django Source/django/core/management/base.py", line 110, in
validate
num_errors = get_validation_errors(s, app)
  File "/Django Source/django/core/management/validation.py", line 28,
in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/Django Source/django/db/models/loading.py", line 126, in
get_app_errors
self._populate()
  File "/Django Source/django/db/models/loading.py", line 55, in
_populate
self.load_app(app_name, True)
  File "/Django Source/django/db/models/loading.py", line 70, in
load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/Django/sandbox/../sandbox/geo/models.py", line 247, in

class TestModel(models.Model):
  File "/Django Source/django/db/models/base.py", line 62, in __new__
new_class.add_to_class(obj_name, obj)
  File "/Django Source/django/db/models/base.py", line 184, in
add_to_class
value.contribute_to_class(cls, name)
TypeError: Error when calling the metaclass bases
unbound method contribute_to_class() must be called with
PickledObjectField instance as first argument (got ModelBase instance
instead)
Macintosh:sandbox Oliver$

Can anyone point me in the right direction?

Thanks so much,
Oliver
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



RSS...my parameters are not correct

2007-12-11 Thread Greg

Hello,
I'm trying to get my RSS feed items to link to the right url, however
I'm having trouble.  I was orginally having my blogs appear in my RSS
feed.  When I clicked on one of them I would get the error:

' Invalid feed parameters. Slug u'latest' is valid, but other
parameters, or lack thereof, are not. '

However, after changing some of my code my blog entries are not even
showing up in my RSS feed.  Here is what I have so far.



urls.py

from mysite.app.models import LatestEntries, LatestEntriesByCategory

feeds = {
'latest': LatestEntries,
'categories': LatestEntriesByCategory,
}

urlpatterns = patterns('',
(r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
)

///

models.py

from django.contrib.syndication.feeds import Feed

class LatestEntries(Feed):
title = "MySite.com News"
link = "Not Sure what goes here"
description = "Updates on changes and additions to Mysite.com."

class LatestEntriesByCategory(Feed):
def get_object(self, bits):
if len(bits) < 1:
raise ObjectDoesNotExist
return Blog.objects.get(slug=bits[-1])

def title(self, obj):
return "My blog for %s" % obj.name

def link(self, obj):
return obj.get_absolute_url()

def description(self, obj):
return "Blog entries recently posted in category %s" %
obj.name

def items(self, obj):
return Blog.objects.filter(blogslug=obj.slug).order_by('-
created_at')[:10]

class Blog(models.Model):
title = models.CharField(maxlength=200)
blogslug = models.SlugField(prepopulate_from=["title"])
content = models.TextField(maxlength=5000)

def get_absolute_url(self):
return "/app/feeds/latest/%i/" % self.id

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



about tagging app and tags cloud

2007-12-11 Thread Lic. José M. Rodriguez Bacallao
hi folks, I need to generate a tags cloud for a model and I'm using
the tagging app from google code. I do something like this:

cloud = Tag.objects.cloud_for_model(NewsEntry, 6)

and generate the html cloud based in the "font_size" attr from the
tags list "cloud". The problem come when I realize that some of the
tags in that list (cloud) doesn't contain a "font_size" attr> I was
looking inside the code of the tagging app and I saw that when the
"count" attr of the tag is less than any of the values of threshold
list it doesn't add the "font_size" attr, so, how can I generate the
tags cloud?

-- 
Lic. José M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

--~--~-~--~~~---~--~~
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: Django Application Without Source?

2007-12-11 Thread gordyt

I had thought the .pyc files were supposed to be portable...

On Dec 10, 2:29 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> And if I recall correctly, .pyc files are version dependent, machine
> independent, but don't quote me on that :)

I did find this post

http://www.python.org/search/hypermail/python-1994q1/0308.html

...by Guido where he writes:

"You're not doing anything wrong -- if .pyc turn out to be non-
portable
between SCO and Sparc, *I* have done something wrong."

But of course your other point about .pyc file disassembly is spot
on..

--gordy

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread James Bennett

On Dec 11, 2007 1:28 PM, Richard Coleman <[EMAIL PROTECTED]> wrote:
> I have maxclients set to 1000, but the number of apache processes never
> gets close to that value.  I've played around with various settings for
> maxclient, but as long as I don't set it too low, this never comes into
> play.

Just a possibility:

If you're launching huge numbers of requests, but all from the same
machine (e.g., the one running ab), your request-generating machine
may be saturating its own bandwidth, which could cause Apache
processes on the web nodes to stall as they wait for you to be able to
receive data, which in turn leads to requests piling up and increased
load on the web node (but not on the DB node, which doesn't notice
anything unusual).

Not saying that's necessarily what's happening, but it's something to
look into. Also, 300 req./sec. for something you apparently haven't
done much profiling on is pretty damned impressive in my book.

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



Re: Catching 413 response

2007-12-11 Thread Jeremy Dunck

I think you want tramline.
Or you want ticket #2070

Sorry you've received no helpful response in the meantime.

On Dec 7, 2007 8:58 AM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> Did anybody manage to catch in Django 413 response (request entity too
> large), thrown by http servers eg. when size of uploaded file exceeds
> limit? I cann't find any way to communicate this response to application.

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Jeremy Dunck

On Dec 11, 2007 1:39 PM, Richard Coleman <[EMAIL PROTECTED]> wrote:
...
> >
> I think a large part of my question really comes down to "Is 300
> requests per second reasonable for an uncached django site on a single
> machine?".  Maybe it is.
>
> We are looking at using the memcached API in our code, and I'm sure we
> will get a speedup there.  But before we start down that route, I wanted
> to make sure we weren't doing any silly on the raw site.
>
> I think my next step is to use the profiler and find out why the site is
> so CPU intensive.
>
> Thanks for all the help.

Again I suggest a hello-world view as a baseline, but if you really
are doing 7000 queries per second, perhaps you're also constructing a
lot of ORM objects; there's some overhead to the signalling (pre/post
init, pre/post 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: Performance of a django website

2007-12-11 Thread Karen Tracey
On Dec 11, 2007 1:49 PM, Richard Coleman <[EMAIL PROTECTED]> wrote:

> 1. Static content and dynamic are on the same server (that will change
> on production).  But they are on different apache virtual.  Mod_python
> is turned off for the static stuff.  Hitting only a static page is very
> fast (6500 requests per second).  Hitting the dynamic side is slow (300
> requests per second).
>
> 2. It's gigE between the web server and mysql server, on a dedicated
> switch.  The database is working pretty hard (7000 selects per second),
> but doesn't seem to be the bottleneck.  The webserver is hammered
> (typing any command takes a long time).
>

DB handling 7000 selects/sec while web server is serving 300 pages/sec
implies each page request is generating >20 select requests.  Does that seem
reasonable to you based on the content of the page you are serving?  (It
seems high to me.)  Brian Morton provided a pointer to the doc for
select_related, which could help to reduce the number of selects.  Even if
the database is keeping up, so many round-trips talking to it for a single
page request is going to add up.

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: Performance of a django website

2007-12-11 Thread Richard Coleman

Forest Bond wrote:
>>> - How are you running your Django app? Mod_python? FastCGI?
>>> - What web server are you using?
>>> - What's the nature of the dynamic Django request you are measuring?
>>> How many DB queries does it make? Is DEBUG mode off?
>>> - What kind of numbers do you get when you serve a simple and small
>>> HTML file statically from your Web server without Django?
>>> - What kind of numbers do you get when the Django view you are
>>> benchmarking goes directly to a simple template (i.e. no DB queries)?
>>> - Are you using memcache?
>>>   
>> 1. mod_python
>> 2. apache 2.2.4
>> 3. I'm using funkload and ab to measure the requests per second of one 
>> of the base pages within the dynamic part of the website
>> 4. When I hit a static page in the same way (using ab), I get 6500 
>> requests per second.
>> 5. This is without memcached, or any other caching.
>> 
>
> I'm not all that qualified to comment as I've never done this sort of testing,
> but I do wonder if the performance you are seeing may not be all that
> unreasonable, given that no caching is currently being performed?  Using
> memcached has been known to improve performance dramatically.
>
> -Forest
>   
I think a large part of my question really comes down to "Is 300 
requests per second reasonable for an uncached django site on a single 
machine?".  Maybe it is.

We are looking at using the memcached API in our code, and I'm sure we 
will get a speedup there.  But before we start down that route, I wanted 
to make sure we weren't doing any silly on the raw site.

I think my next step is to use the profiler and find out why the site is 
so CPU intensive.

Thanks for all the help.

Richard Coleman
[EMAIL PROTECTED]

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



Accessing Multiple Databases

2007-12-11 Thread Derek Steinkamp

I read through all the relevant documentation but I couldn't find any 
info on an issue I am about to face: accessing multiple tables in 
different databases with Django.

Here's a quick example:
My Django app (MyApp) has r/w access to the MyApp database on 
MySQLserver1, and all of MyApp models live within here. I now need to 
access a pre-existing database/table on MySQLserver2 to bring in some 
data relevant to MyApp.

My ultimate question is: does Django support accessing models that live 
in/on different databases/servers within one app? If so, how do I do 
this? If not, what should I be doing?

Thanks,
Derek


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



Re: Admin

2007-12-11 Thread Rajesh Dhawan

> I have a table ending in 'ery', however in the admin it is spelt 'ys',
> if course this is wrong it should end in 'ies'.
> Is it possible to change this?

http://www.djangoproject.com/documentation/model-api/#verbose-name-plural

-Rajesh
--~--~-~--~~~---~--~~
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: Admin

2007-12-11 Thread Marty Alchin

http://www.djangoproject.com/documentation/model-api/#verbose-name-plural

On Dec 11, 2007 2:37 PM, Goldy <[EMAIL PROTECTED]> wrote:
>
> I have a table ending in 'ery', however in the admin it is spelt 'ys',
> if course this is wrong it should end in 'ies'.
> Is it possible to change this?
> >
>

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



Re: Performance of a django website

2007-12-11 Thread Jeremy Dunck

On Dec 11, 2007 1:21 PM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> Hi again,
>
> > 3. I'm using prefork MPM on apache with maxclients set to 1000.
>
> Apart from Joe's excellent profiling suggestion, I would recommend
> reducing maxclients to a much lower value (like say 100) and then
> increasing it gradually.

Please make  'hello world' view to simplify the troubleshooting.

If it's still "only" 300 r/s without hitting the DB, the problem is
much smaller.

You haven't listed your ab parameters; if you're using maxclients so
high, perhaps you're paying the process startup cost (nearly) each
time, so consider setting startservers high.  In general, if you have
a dedicated web server, setting startservers near maxclients isn't a
bad way to go.

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



Admin

2007-12-11 Thread Goldy

I have a table ending in 'ery', however in the admin it is spelt 'ys',
if course this is wrong it should end in 'ies'.
Is it possible to change this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: docs for the new ModelForm() class

2007-12-11 Thread John M

No, I don't need anything added, I'm just slow and didn't see the link
at the end of the newforms doc, dh.

Thanks everyone, I love this group, took only 2min to get an answer!!

John

On Dec 11, 11:32 am, "Joseph Kocherhans" <[EMAIL PROTECTED]>
wrote:
> On 12/11/07, John M <[EMAIL PROTECTED]> wrote:
>
>
>
> > I love newforms, and as soon as I 'master' form_for_instance/model,
> > you guys come out with something totally awesome, sub-classing
> > something called ModelForm, wow.
>
> > now, where do i get 'docs' for this?  Would the developer group be
> > best,I've found some good stuff there, and a few examples here and
> > there.
>
> What do you want in addition to the official 
> docs?http://www.djangoproject.com/documentation/modelforms/If there's
> somethings specific that *isn't* covered, just ask on django-users.
>
> Please don't post questions to the developer list though. Most of us
> read django-users as well, and that's where questions belong. The
> developer list is for discussing the development of Django itself.
>
> Joseph
--~--~-~--~~~---~--~~
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: docs for the new ModelForm() class

2007-12-11 Thread Joseph Kocherhans

On 12/11/07, John M <[EMAIL PROTECTED]> wrote:
>
> I love newforms, and as soon as I 'master' form_for_instance/model,
> you guys come out with something totally awesome, sub-classing
> something called ModelForm, wow.
>
> now, where do i get 'docs' for this?  Would the developer group be
> best,I've found some good stuff there, and a few examples here and
> there.

What do you want in addition to the official docs?
http://www.djangoproject.com/documentation/modelforms/ If there's
somethings specific that *isn't* covered, just ask on django-users.

Please don't post questions to the developer list though. Most of us
read django-users as well, and that's where questions belong. The
developer list is for discussing the development of Django itself.

Joseph

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Richard Coleman

Rajesh Dhawan wrote:
>> 3. I'm using prefork MPM on apache with maxclients set to 1000.
>> 
>
> Apart from Joe's excellent profiling suggestion, I would recommend
> reducing maxclients to a much lower value (like say 100) and then
> increasing it gradually.
>
> From your description of the sluggish response of your web server, it
> looks like the machine may be swapping to disk. Each of your clients
> fires up a Python VM taking up several tens of MB of RAM. Even if each
> VM takes up just 20MB (it's probably more than that), a thousand
> clients will eat up 20GB, forcing your machine to swap.
>
> -Rajesh
>
>   

The machine is definitely not swapping.  It has 16 gig of ram, and top 
never shows more than 7 gig of ram in use when I do the load testing.

I have maxclients set to 1000, but the number of apache processes never 
gets close to that value.  I've played around with various settings for 
maxclient, but as long as I don't set it too low, this never comes into 
play.

Richard Coleman
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: docs for the new ModelForm() class

2007-12-11 Thread Rajesh Dhawan

> I love newforms, and as soon as I 'master' form_for_instance/model,
> you guys come out with something totally awesome, sub-classing
> something called ModelForm, wow.
>
> now, where do i get 'docs' for this?  Would the developer group be
> best,I've found some good stuff there, and a few examples here and
> there.

This is already linked from the main newforms doc:

http://www.djangoproject.com/documentation/modelforms/

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Forest Bond
Hi,

On Tue, Dec 11, 2007 at 01:37:36PM -0500, Richard Coleman wrote:
> Rajesh Dhawan wrote:
> >> When I stress test the dynamic part of the site, I am only getting about
> >> 300 requests per second on my test setup.  This is using two Dell 1950's
> >> (one for web, one for mysql database).  These are very powerful machines
> >> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
> >
> > - How are you running your Django app? Mod_python? FastCGI?
> > - What web server are you using?
> > - What's the nature of the dynamic Django request you are measuring?
> > How many DB queries does it make? Is DEBUG mode off?
> > - What kind of numbers do you get when you serve a simple and small
> > HTML file statically from your Web server without Django?
> > - What kind of numbers do you get when the Django view you are
> > benchmarking goes directly to a simple template (i.e. no DB queries)?
> > - Are you using memcache?
> 
> 1. mod_python
> 2. apache 2.2.4
> 3. I'm using funkload and ab to measure the requests per second of one 
> of the base pages within the dynamic part of the website
> 4. When I hit a static page in the same way (using ab), I get 6500 
> requests per second.
> 5. This is without memcached, or any other caching.

I'm not all that qualified to comment as I've never done this sort of testing,
but I do wonder if the performance you are seeing may not be all that
unreasonable, given that no caching is currently being performed?  Using
memcached has been known to improve performance dramatically.

Profiling never hurts, but there's nothing wrong with doing the easy stuff
first, right?

-Forest
-- 
Forest Bond
http://www.alittletooquiet.net


signature.asc
Description: Digital signature


Re: docs for the new ModelForm() class

2007-12-11 Thread Karen Tracey
ModelForm is documented here:

http://www.djangoproject.com/documentation/modelforms/

On Dec 11, 2007 2:22 PM, John M <[EMAIL PROTECTED]> wrote:

>
> I love newforms, and as soon as I 'master' form_for_instance/model,
> you guys come out with something totally awesome, sub-classing
> something called ModelForm, wow.
>
> now, where do i get 'docs' for this?  Would the developer group be
> best,I've found some good stuff there, and a few examples here and
> there.
>
> Thanks
>
> John
> >
>

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



docs for the new ModelForm() class

2007-12-11 Thread John M

I love newforms, and as soon as I 'master' form_for_instance/model,
you guys come out with something totally awesome, sub-classing
something called ModelForm, wow.

now, where do i get 'docs' for this?  Would the developer group be
best,I've found some good stuff there, and a few examples here and
there.

Thanks

John
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Brian Morton

http://www.djangoproject.com/documentation/db-api/#select-related

On Dec 11, 1:18 pm, Joe <[EMAIL PROTECTED]> wrote:
> I've found the largest memory hog to be the native way related tables
> are setup.
>
> Check class definitions with related tables and edit as such:
>
> class ...(models.Mode):
> relatedtable= models.ForeignKey(RelatedTable, core=True,
> raw_id_admin=True)
>
> The raw_id_admin=True prevents django from pulling up all related
> records when the object is loaded etc. While I would have expected
> this to only affect the admin side, it had a huge impact on the public
> side of our site. Memory consumption went from +500mb to 20-30mb.
>
> Joe
>
> On Dec 11, 12:53 pm, Richard Coleman <[EMAIL PROTECTED]>
> wrote:
>
> > At work, we are developing a commercial website based on Django.  It's a
> > fairly dynamic site (think social networking).  I am doing the initial
> > load testing to estimate the number of servers we will need for the
> > production site.  The production site will be load balanced using a pair
> > of BigIP boxes.
>
> > When I stress test the dynamic part of the site, I am only getting about
> > 300 requests per second on my test setup.  This is using two Dell 1950's
> > (one for web, one for mysql database).  These are very powerful machines
> > (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>
> > I've done all the standard performance tuning I find when reading
> > through various websites about django tuning.  Is this the performance I
> > should expect.
>
> > When I'm running the load test, the CPU on the web server gets
> > completely buried (even with 8 cores).  The mysql server doesn't seem
> > loaded at all.  Any suggestions on how to find the bottlenecks?
>
> > I'm running Ubuntu 7.10 (server, 64 bit version).  Django from a very
> > recent trunk.
>
> > Thanks for any advice.
>
> > Richard Coleman
> > [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Rajesh Dhawan

Hi again,

> 3. I'm using prefork MPM on apache with maxclients set to 1000.

Apart from Joe's excellent profiling suggestion, I would recommend
reducing maxclients to a much lower value (like say 100) and then
increasing it gradually.

>From your description of the sluggish response of your web server, it
looks like the machine may be swapping to disk. Each of your clients
fires up a Python VM taking up several tens of MB of RAM. Even if each
VM takes up just 20MB (it's probably more than that), a thousand
clients will eat up 20GB, forcing your machine to swap.

-Rajesh
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Brian Morton

Sorry, just saw your earlier post about debug being turned off.  I
would say it is definitely time to start profiling your code.

On Dec 11, 2:11 pm, Brian Morton <[EMAIL PROTECTED]> wrote:
> Joseph raises a good point.  I only recently discovered what a
> performance killer DEBUG mode can be when it comes to queries.  It
> will cause your client machine (the web server in this case) to run
> out of memory after a lengthy process (such as data loading).  Are you
> profiling in DEBUG mode?
>
> On Dec 11, 1:54 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
>
> > Definitely take that specific dynamic page and profile it - see what's
> > happening and why its slow. That's clearly your first bottleneck to
> > work on from the data you've provided.
>
> > There's a wiki page on that very process 
> > here:http://code.djangoproject.com/wiki/ProfilingDjangoandthere's
> > additionally some information you can get when you enable DEBUG to see
> > how long the SQL queries are taking for that dynamic page. There's a
> > nice snippet to help there athttp://www.djangosnippets.org/snippets/93/
>
> > -joe
>
> > On Dec 11, 2007 10:49 AM, Richard Coleman <[EMAIL PROTECTED]> wrote:
>
> > > Brian Morton wrote:
> > > > Are you serving static content from the same apache instance?  Also,
> > > > what kind of network connectivity do you have between your web and
> > > > mysql servers?  It sounds like apache might need some tuning in terms
> > > > of thread parameters.  Have you enabled caching yet?  Turn on the
> > > > cache framework site-wide and set your expiration period to 1 minute
> > > > or something like that.  You can go back and only enable it for views
> > > > that you want cached later.
>
> > > 1. Static content and dynamic are on the same server (that will change
> > > on production).  But they are on different apache virtual.  Mod_python
> > > is turned off for the static stuff.  Hitting only a static page is very
> > > fast (6500 requests per second).  Hitting the dynamic side is slow (300
> > > requests per second).
>
> > > 2. It's gigE between the web server and mysql server, on a dedicated
> > > switch.  The database is working pretty hard (7000 selects per second),
> > > but doesn't seem to be the bottleneck.  The webserver is hammered
> > > (typing any command takes a long time).
> > > 3. I'm using prefork MPM on apache with maxclients set to 1000.
>
> > > We are starting to experiment with caching, but I want to improve the
> > > raw performance of the site as well.
>
> > > Richard Coleman
> > > [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 FileField.delete_file to remove unused images

2007-12-11 Thread Marty Alchin

There are several things you need to know, so I'll lay them out.

1) You can get any Field instance from a class by using the
model._meta.get_field() method. Instead of your list comprehension,
just use the following line:

picfield = p._meta.get_field('picture')

2) If you read the comments in delete_file(), you'll see the
following: "If the file exists and no other object of this type
references it, delete it from the filesystem." Your problem is that
the Person "p" still references the file, so delete_file() won't
delete it. You'd need to put something like this before the
delete_file() call in order to get it to work properly:

p.picture = ''
p.save()

3) Saving an object with a new filename alters the corresponding field
in the database record. What this means is that you can somewhat
ignore the previous item, and simply put delete_file() at the *end* of
your script, instead of before the file saving code. That way, by the
time it runs, the Person "p" will already have a different filename,
and delete_file() won't find it, and will happily delete the file for
you.

4) save_FOO_file() automatically saves the model instance with the new
filename. Right now, you're calling p.save() after
p.save_picture_file(), which results in two hits to the database for
absolutely no reason. save_picture_file() calls save() internally, so
don't bother doing it again.

5) With those changes, your code should look something like this:

class PersonForm(forms.Form):
# ...
picture = forms.ImageField(required=False)
# ...
def save(self):
# ...
p = Person.objects.get(pk=pk)
file, content = (self.cleaned_data['picture'].filename,
self.cleaned_data['picture'].content)

p.save_picture_file(file, content)
p._meta.get_field('picture').delete_file(p)

6) Deleting files will get much easier soon, and it will even be a bit
simpler to do what you're looking to do, without having to build all
this into your form logic. So most of the things I've just covered
will change, but for the better.

-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: Performance of a django website

2007-12-11 Thread Brian Morton

Joseph raises a good point.  I only recently discovered what a
performance killer DEBUG mode can be when it comes to queries.  It
will cause your client machine (the web server in this case) to run
out of memory after a lengthy process (such as data loading).  Are you
profiling in DEBUG mode?

On Dec 11, 1:54 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
> Definitely take that specific dynamic page and profile it - see what's
> happening and why its slow. That's clearly your first bottleneck to
> work on from the data you've provided.
>
> There's a wiki page on that very process 
> here:http://code.djangoproject.com/wiki/ProfilingDjangoand there's
> additionally some information you can get when you enable DEBUG to see
> how long the SQL queries are taking for that dynamic page. There's a
> nice snippet to help there athttp://www.djangosnippets.org/snippets/93/
>
> -joe
>
> On Dec 11, 2007 10:49 AM, Richard Coleman <[EMAIL PROTECTED]> wrote:
>
>
>
> > Brian Morton wrote:
> > > Are you serving static content from the same apache instance?  Also,
> > > what kind of network connectivity do you have between your web and
> > > mysql servers?  It sounds like apache might need some tuning in terms
> > > of thread parameters.  Have you enabled caching yet?  Turn on the
> > > cache framework site-wide and set your expiration period to 1 minute
> > > or something like that.  You can go back and only enable it for views
> > > that you want cached later.
>
> > 1. Static content and dynamic are on the same server (that will change
> > on production).  But they are on different apache virtual.  Mod_python
> > is turned off for the static stuff.  Hitting only a static page is very
> > fast (6500 requests per second).  Hitting the dynamic side is slow (300
> > requests per second).
>
> > 2. It's gigE between the web server and mysql server, on a dedicated
> > switch.  The database is working pretty hard (7000 selects per second),
> > but doesn't seem to be the bottleneck.  The webserver is hammered
> > (typing any command takes a long time).
> > 3. I'm using prefork MPM on apache with maxclients set to 1000.
>
> > We are starting to experiment with caching, but I want to improve the
> > raw performance of the site as well.
>
> > Richard Coleman
> > [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Lic. José M. Rodriguez Bacallao
I will recommend Arch, is simple and powerful.

On Dec 11, 2007 1:22 PM, Joe <[EMAIL PROTECTED]> wrote:
>
> To make things easy, you could download VMware Server - run that on
> your windows box and install the prebuilt appliances. That'd make it
> easy to try out a few linux versions. VMware is free as are the
> appliances.
>
> I use ubuntu primarily.
>
> j
>
>
> On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > till now I've been experimenting with Django (development version)
> > under Win2k. But Windows sucks. So I dare to make my first steps with
> > Linux. Most of you will surely say I won't regret this decision ;-).
> > But since I haven't any experience with Linux yet, I want to choose a
> > distribution that is best suited for someone coming from the Windows-
> > world AND suited to establish a Django development environment. Well,
> > I'm not even sure if there will be any great difference between
> > several distributions regarding these aspects. Any comment is welcome.
> >
> > Regards,
> > Andreas
> >
>



-- 
Lic. Jos� M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

--~--~-~--~~~---~--~~
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 ordering on related objects

2007-12-11 Thread Rajesh Dhawan

>
> when I do A.objects.all() I want to sort by title. But when
> B.foo_set.all() I would like to always order by A.number.
>
> It seems like a custom manager is the path here, but there does not
> appear to be a way to define one when defining the relationship.

Actually, there is. The related manager created by Django uses your
custom manager as its base class. You can exploit that fact in the
custom manager for your child object. Something like this should do
the trick:

class FooManager(models.Manager):
def get_query_set(self):
base_queryset = super(FooManager, self).get_query_set()
if "related.RelatedManager" in str(self.__class__):
# We were called through our Parent's related set
ordered_query = base_queryset.order_by('number')
else:
# We were called directly
ordered_query = base_queryset.order_by('title')
return ordered_query

And, of course, add "objects = FooManager()" to the Foo class.

-Rajesh D.
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Joseph Heck

Definitely take that specific dynamic page and profile it - see what's
happening and why its slow. That's clearly your first bottleneck to
work on from the data you've provided.

There's a wiki page on that very process here:
http://code.djangoproject.com/wiki/ProfilingDjango and there's
additionally some information you can get when you enable DEBUG to see
how long the SQL queries are taking for that dynamic page. There's a
nice snippet to help there at
http://www.djangosnippets.org/snippets/93/

-joe


On Dec 11, 2007 10:49 AM, Richard Coleman <[EMAIL PROTECTED]> wrote:
>
> Brian Morton wrote:
> > Are you serving static content from the same apache instance?  Also,
> > what kind of network connectivity do you have between your web and
> > mysql servers?  It sounds like apache might need some tuning in terms
> > of thread parameters.  Have you enabled caching yet?  Turn on the
> > cache framework site-wide and set your expiration period to 1 minute
> > or something like that.  You can go back and only enable it for views
> > that you want cached later.
> >
> >
> 1. Static content and dynamic are on the same server (that will change
> on production).  But they are on different apache virtual.  Mod_python
> is turned off for the static stuff.  Hitting only a static page is very
> fast (6500 requests per second).  Hitting the dynamic side is slow (300
> requests per second).
>
> 2. It's gigE between the web server and mysql server, on a dedicated
> switch.  The database is working pretty hard (7000 selects per second),
> but doesn't seem to be the bottleneck.  The webserver is hammered
> (typing any command takes a long time).
> 3. I'm using prefork MPM on apache with maxclients set to 1000.
>
> We are starting to experiment with caching, but I want to improve the
> raw performance of the site as well.
>
>
> Richard Coleman
> [EMAIL PROTECTED]
>
> >
>

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Richard Coleman

Brian Morton wrote:
> Are you serving static content from the same apache instance?  Also,
> what kind of network connectivity do you have between your web and
> mysql servers?  It sounds like apache might need some tuning in terms
> of thread parameters.  Have you enabled caching yet?  Turn on the
> cache framework site-wide and set your expiration period to 1 minute
> or something like that.  You can go back and only enable it for views
> that you want cached later.
>
>   
1. Static content and dynamic are on the same server (that will change 
on production).  But they are on different apache virtual.  Mod_python 
is turned off for the static stuff.  Hitting only a static page is very 
fast (6500 requests per second).  Hitting the dynamic side is slow (300 
requests per second).

2. It's gigE between the web server and mysql server, on a dedicated 
switch.  The database is working pretty hard (7000 selects per second), 
but doesn't seem to be the bottleneck.  The webserver is hammered 
(typing any command takes a long time).
3. I'm using prefork MPM on apache with maxclients set to 1000.

We are starting to experiment with caching, but I want to improve the 
raw performance of the site as well.

Richard Coleman
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Brian Morton

Are you serving static content from the same apache instance?  Also,
what kind of network connectivity do you have between your web and
mysql servers?  It sounds like apache might need some tuning in terms
of thread parameters.  Have you enabled caching yet?  Turn on the
cache framework site-wide and set your expiration period to 1 minute
or something like that.  You can go back and only enable it for views
that you want cached later.

On Dec 11, 12:53 pm, Richard Coleman <[EMAIL PROTECTED]>
wrote:
> At work, we are developing a commercial website based on Django.  It's a
> fairly dynamic site (think social networking).  I am doing the initial
> load testing to estimate the number of servers we will need for the
> production site.  The production site will be load balanced using a pair
> of BigIP boxes.
>
> When I stress test the dynamic part of the site, I am only getting about
> 300 requests per second on my test setup.  This is using two Dell 1950's
> (one for web, one for mysql database).  These are very powerful machines
> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>
> I've done all the standard performance tuning I find when reading
> through various websites about django tuning.  Is this the performance I
> should expect.
>
> When I'm running the load test, the CPU on the web server gets
> completely buried (even with 8 cores).  The mysql server doesn't seem
> loaded at all.  Any suggestions on how to find the bottlenecks?
>
> I'm running Ubuntu 7.10 (server, 64 bit version).  Django from a very
> recent trunk.
>
> Thanks for any advice.
>
> Richard Coleman
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Eric Walstad

If you don't already use them:

Firebug:
http://www.getfirebug.com/
will show you how long each component of the page takes from request to 
response and shows you what components are returned in parallel (among 
other really cool features).  This can help identify your bottleneck. 
For example, if your images are taking longer than expected while the 
page itself returns quickly then you may want to serve images with a 
dedicated web server, like lighttpd.

Yahoo's 'yslow' tool gives your page a 'grade' and offers advice on how 
to improve your grade.  It also has other handy bits (JSLint, Empty vs. 
Primed cache comparisons).
http://developer.yahoo.com/yslow/

The grades are based on their 'Rules for High Performance Websites':
http://developer.yahoo.com/performance/index.html#rules

Hm, funny, their yslow page scores a 'D' :)

Joseph Heck wrote:
> Add on to Rajesh's list -
> 
> what pages are you requesting and have you profiled them to understand
> what's taking long?
> 
> -joe
> 
> On Dec 11, 2007 10:08 AM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>> Hi Richard,
>>
>>> When I stress test the dynamic part of the site, I am only getting about
>>> 300 requests per second on my test setup.  This is using two Dell 1950's
>>> (one for web, one for mysql database).  These are very powerful machines
>>> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>> - How are you running your Django app? Mod_python? FastCGI?
>> - What web server are you using?
>> - What's the nature of the dynamic Django request you are measuring?
>> How many DB queries does it make? Is DEBUG mode off?
>> - What kind of numbers do you get when you serve a simple and small
>> HTML file statically from your Web server without Django?
>> - What kind of numbers do you get when the Django view you are
>> benchmarking goes directly to a simple template (i.e. no DB queries)?
>> - Are you using memcache?
>>
>> -Rajesh D

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Richard Coleman

Richard Coleman wrote:
> Rajesh Dhawan wrote:
>   
>>> When I stress test the dynamic part of the site, I am only getting about
>>> 300 requests per second on my test setup.  This is using two Dell 1950's
>>> (one for web, one for mysql database).  These are very powerful machines
>>> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>>> 
>>>   
>> - How are you running your Django app? Mod_python? FastCGI?
>> - What web server are you using?
>> - What's the nature of the dynamic Django request you are measuring?
>> How many DB queries does it make? Is DEBUG mode off?
>> - What kind of numbers do you get when you serve a simple and small
>> HTML file statically from your Web server without Django?
>> - What kind of numbers do you get when the Django view you are
>> benchmarking goes directly to a simple template (i.e. no DB queries)?
>> - Are you using memcache?
>>
>> -Rajesh D
>>   
>> 
>
> 1. mod_python
> 2. apache 2.2.4
> 3. I'm using funkload and ab to measure the requests per second of one 
> of the base pages within the dynamic part of the website
> 4. When I hit a static page in the same way (using ab), I get 6500 
> requests per second.
> 5. This is without memcached, or any other caching.
>   

I forgot to mention these:

6. django debug turned off
7. mod_python debug turn off
8. django template debugging turned off
9. apache maxclient cranked up to 1000 (although it never gets close to 
that many processes).

Richard Coleman
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Richard Coleman

Rajesh Dhawan wrote:
>> When I stress test the dynamic part of the site, I am only getting about
>> 300 requests per second on my test setup.  This is using two Dell 1950's
>> (one for web, one for mysql database).  These are very powerful machines
>> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>> 
>
> - How are you running your Django app? Mod_python? FastCGI?
> - What web server are you using?
> - What's the nature of the dynamic Django request you are measuring?
> How many DB queries does it make? Is DEBUG mode off?
> - What kind of numbers do you get when you serve a simple and small
> HTML file statically from your Web server without Django?
> - What kind of numbers do you get when the Django view you are
> benchmarking goes directly to a simple template (i.e. no DB queries)?
> - Are you using memcache?
>
> -Rajesh D
>   

1. mod_python
2. apache 2.2.4
3. I'm using funkload and ab to measure the requests per second of one 
of the base pages within the dynamic part of the website
4. When I hit a static page in the same way (using ab), I get 6500 
requests per second.
5. This is without memcached, or any other caching.

Richard Coleman
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Jeremy Dunck

On Dec 11, 2007 12:18 PM, Joe <[EMAIL PROTECTED]> wrote:
>
> I've found the largest memory hog to be the native way related tables
> are setup.
>
> Check class definitions with related tables and edit as such:
>
> class ...(models.Mode):
> relatedtable= models.ForeignKey(RelatedTable, core=True,
> raw_id_admin=True)
>
> The raw_id_admin=True prevents django from pulling up all related
> records when the object is loaded etc. While I would have expected
> this to only affect the admin side, it had a huge impact on the public
> side of our site. Memory consumption went from +500mb to 20-30mb.
>

You must be using manipulators in oldforms.  Try newforms.

--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Joe

To make things easy, you could download VMware Server - run that on
your windows box and install the prebuilt appliances. That'd make it
easy to try out a few linux versions. VMware is free as are the
appliances.

I use ubuntu primarily.

j

On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
> Hello,
>
> till now I've been experimenting with Django (development version)
> under Win2k. But Windows sucks. So I dare to make my first steps with
> Linux. Most of you will surely say I won't regret this decision ;-).
> But since I haven't any experience with Linux yet, I want to choose a
> distribution that is best suited for someone coming from the Windows-
> world AND suited to establish a Django development environment. Well,
> I'm not even sure if there will be any great difference between
> several distributions regarding these aspects. Any comment is welcome.
>
> Regards,
> Andreas
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Joe

I've found the largest memory hog to be the native way related tables
are setup.

Check class definitions with related tables and edit as such:

class ...(models.Mode):
relatedtable= models.ForeignKey(RelatedTable, core=True,
raw_id_admin=True)

The raw_id_admin=True prevents django from pulling up all related
records when the object is loaded etc. While I would have expected
this to only affect the admin side, it had a huge impact on the public
side of our site. Memory consumption went from +500mb to 20-30mb.

Joe

On Dec 11, 12:53 pm, Richard Coleman <[EMAIL PROTECTED]>
wrote:
> At work, we are developing a commercial website based on Django.  It's a
> fairly dynamic site (think social networking).  I am doing the initial
> load testing to estimate the number of servers we will need for the
> production site.  The production site will be load balanced using a pair
> of BigIP boxes.
>
> When I stress test the dynamic part of the site, I am only getting about
> 300 requests per second on my test setup.  This is using two Dell 1950's
> (one for web, one for mysql database).  These are very powerful machines
> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>
> I've done all the standard performance tuning I find when reading
> through various websites about django tuning.  Is this the performance I
> should expect.
>
> When I'm running the load test, the CPU on the web server gets
> completely buried (even with 8 cores).  The mysql server doesn't seem
> loaded at all.  Any suggestions on how to find the bottlenecks?
>
> I'm running Ubuntu 7.10 (server, 64 bit version).  Django from a very
> recent trunk.
>
> Thanks for any advice.
>
> Richard Coleman
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Joseph Heck

Add on to Rajesh's list -

what pages are you requesting and have you profiled them to understand
what's taking long?

-joe

On Dec 11, 2007 10:08 AM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> Hi Richard,
>
> >
> > When I stress test the dynamic part of the site, I am only getting about
> > 300 requests per second on my test setup.  This is using two Dell 1950's
> > (one for web, one for mysql database).  These are very powerful machines
> > (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)
>
> - How are you running your Django app? Mod_python? FastCGI?
> - What web server are you using?
> - What's the nature of the dynamic Django request you are measuring?
> How many DB queries does it make? Is DEBUG mode off?
> - What kind of numbers do you get when you serve a simple and small
> HTML file statically from your Web server without Django?
> - What kind of numbers do you get when the Django view you are
> benchmarking goes directly to a simple template (i.e. no DB queries)?
> - Are you using memcache?
>
> -Rajesh D
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Ramdas S

Go for Ubuntu.

RS

On Dec 11, 5:48 pm, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
> Thanks for so many replies and the helpful links. Ubuntu really seems
> to be a good solution as far as I can tell by now. I'll give it a try.
> At least now I know what I will do on Christmas :-)
--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread Rajesh Dhawan

Hi Richard,

>
> When I stress test the dynamic part of the site, I am only getting about
> 300 requests per second on my test setup.  This is using two Dell 1950's
> (one for web, one for mysql database).  These are very powerful machines
> (3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)

- How are you running your Django app? Mod_python? FastCGI?
- What web server are you using?
- What's the nature of the dynamic Django request you are measuring?
How many DB queries does it make? Is DEBUG mode off?
- What kind of numbers do you get when you serve a simple and small
HTML file statically from your Web server without Django?
- What kind of numbers do you get when the Django view you are
benchmarking goes directly to a simple template (i.e. no DB queries)?
- Are you using memcache?

-Rajesh D


--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-11 Thread l5x

I think that some info about your web-server could be important.
--~--~-~--~~~---~--~~
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 FileField.delete_file to remove unused images

2007-12-11 Thread l5x

I didn't use delete_file, but if you can't solve this you can write
your own code for that using signals (pre_delete or post_delete).
More: http://code.djangoproject.com/wiki/Signals

Anyway I'm also curious how to do that without signals.
--~--~-~--~~~---~--~~
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 FileField.delete_file to remove unused images

2007-12-11 Thread ER Yost

I am working on a project with the following:

class Person(models.Model):
# ...
picture = models.ImageField(...)

I'd like to give each Person the ability to delete images, and I'd
like to remove deleted pictures from the filesystem once a person has
deleted them. From what I can tell, the delete_file function in the
FileField class (http://code.djangoproject.com/browser/django/trunk/
django/db/models/fields/__init__.py, line 767) will do that for me.
However, I haven't gotten it to work. Here's a chunk of the code I'm
working with...

class PersonForm(forms.Form):
# ...
picture = forms.ImageField(required=False)
# ...
def save(self):
# ...
p = Person.objects.get(pk=pk)
file, content = (self.cleaned_data['picture'].filename,
self.cleaned_data['picture'].content)

# I'm most confused on how to get the instance of ImageField
class to operate on
# this is the best thing I could come up with
picfield = [f for f in p.__class__._meta.fields if f.name ==
'picture'][0]
picfield.delete_file(p)
p.save_picture_file(file, content)
p.save()
# return None

Django doesn't argue with the syntax, but it also won't delete the
file from the filesystem. My main assumptions are that:
delete_file accepts the instance of the model containing the
ImageField (in this example, Person)
I have the steps (get field, delete file, save new file, save
person instance) in the right order
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Performance of a django website

2007-12-11 Thread Richard Coleman

At work, we are developing a commercial website based on Django.  It's a 
fairly dynamic site (think social networking).  I am doing the initial 
load testing to estimate the number of servers we will need for the 
production site.  The production site will be load balanced using a pair 
of BigIP boxes.

When I stress test the dynamic part of the site, I am only getting about 
300 requests per second on my test setup.  This is using two Dell 1950's 
(one for web, one for mysql database).  These are very powerful machines 
(3.0ghz Xeons, 8 cores each, 16 gig of ram, 15k SAS drives, etc.)

I've done all the standard performance tuning I find when reading 
through various websites about django tuning.  Is this the performance I 
should expect.

When I'm running the load test, the CPU on the web server gets 
completely buried (even with 8 cores).  The mysql server doesn't seem 
loaded at all.  Any suggestions on how to find the bottlenecks?

I'm running Ubuntu 7.10 (server, 64 bit version).  Django from a very 
recent trunk.

Thanks for any advice.

Richard Coleman
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: Django Application Without Source?

2007-12-11 Thread Matthew Wensing
Jython.


On 12/11/07 11:08 AM, "Hugh Bien" <[EMAIL PROTECTED]> wrote:

> Ttry using pyobfuscate.  It works really well with python 2.3 (run it using
> python 2.3 and only use it on python 2.3 compatible code).
> 
> - Hugh
> 
> On 12/10/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>> 
>> try java, or C or even BF
>> 
>> On 11-Dec-07, at 10:32 AM, [EMAIL PROTECTED] wrote:
>> 
>>> >
>>> > Shoot, so maybe Python just isn't the language for this kind of
>>> > project. I'm not really concerned with making it bullet-proof to
>>> > decompilation, just not so glaringly obvious as opening up the source
>>> > files :)
>>> >
>>> > On Dec 10, 3:29 pm, "Jay Parlar" < [EMAIL PROTECTED]> wrote:
 >> On Dec 10, 2007 2:43 AM, [EMAIL PROTECTED]
 >>
 >> < [EMAIL PROTECTED]  > wrote:
 >>
> >>> Or perhaps I'm reading into this too much. If I distribute the .pyc
> >>> files minus the .py files, would that work? Is this machine-
> >>> independent (IE: I "compile" the source on an x86, it'll be ok on
> >>> a 64-
> >>> bit or other architecture?)
 >>
 >> Anyone who *really* wanted to get at your code could do a decent job
 >> of disassembling the .pyc files, there's not a lot going on in those.
 >> In fact, I believe there used to be a commercial service that would
 >> take .pyc files, and automatically convert them to .py
 >>
 >> And if I recall correctly, .pyc files are version dependent, machine
 >> independent, but don't quote me on that :)
 > >
>> 
>> --
>> 
>> regards
>> kg
>> http://lawgon.livejournal.com
>> http://nrcfosshelpline.in/web/
>> Foss Conference for the common man: http://registration.fossconf.in/web/
>> 
>> 
>> 
>> 
>> 
>> >> 
>> 



--~--~-~--~~~---~--~~
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: Django Application Without Source?

2007-12-11 Thread Hugh Bien
Ttry using pyobfuscate.  It works really well with python 2.3 (run it using
python 2.3 and only use it on python 2.3 compatible code).
- Hugh

On 12/10/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
> try java, or C or even BF
>
> On 11-Dec-07, at 10:32 AM, [EMAIL PROTECTED] wrote:
>
> >
> > Shoot, so maybe Python just isn't the language for this kind of
> > project. I'm not really concerned with making it bullet-proof to
> > decompilation, just not so glaringly obvious as opening up the source
> > files :)
> >
> > On Dec 10, 3:29 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> >> On Dec 10, 2007 2:43 AM, [EMAIL PROTECTED]
> >>
> >> <[EMAIL PROTECTED]> wrote:
> >>
> >>> Or perhaps I'm reading into this too much. If I distribute the .pyc
> >>> files minus the .py files, would that work? Is this machine-
> >>> independent (IE: I "compile" the source on an x86, it'll be ok on
> >>> a 64-
> >>> bit or other architecture?)
> >>
> >> Anyone who *really* wanted to get at your code could do a decent job
> >> of disassembling the .pyc files, there's not a lot going on in those.
> >> In fact, I believe there used to be a commercial service that would
> >> take .pyc files, and automatically convert them to .py
> >>
> >> And if I recall correctly, .pyc files are version dependent, machine
> >> independent, but don't quote me on that :)
> > >
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
> Foss Conference for the common man: http://registration.fossconf.in/web/
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Best way to make content in templates

2007-12-11 Thread l5x

Isn't it just putting variable into template? I don't know if I
understand you correctly but for example:

models.py

Image(models.Model)
name = CharField(...)
location = ImageField(...)

YourModel(models.Model)
image = ForeignKey(Image)
user = ForeignKey(User)

(...)

index.html:



views.py:

(...)
from django.template import RequestContext
def my_request_context():
my_model = MyModel.objects.get(user=request.user)
# you can get the Image : my_model.image
return my_model # or my_model.image

and then use it when you need (rememer to add it to
TEMPLATE_CONTEXT_PROCESSORS in settings, and to call the request
context everytime you need it in views in 'render_to_response')

But I don'f now if it is what you need.

You should focus on http://www.djangoproject.com/documentation/templates_python/
(everything is written there)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Best way to make content in templates

2007-12-11 Thread [EMAIL PROTECTED]

Hi folks,

I am new to Django and I want to know which is the best approach to
create content in templates for example:
- I need to call a logo image for the website, the logo location in
the system is referenced in a field of a model.

I want to display the logo by getting it from the system after
consulting the DB.

Can you tell me what's the best approach?

Thank you 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: Import RSS headlines from feeds into django based pages.

2007-12-11 Thread Tim Riley

http://www.feedparser.org/



On Dec 11, 2007 9:29 AM, Alessandro <[EMAIL PROTECTED]> wrote:
>
> I want to add in a django page some rss feeds from another websites,
> like headlines from news portals. how can I do that without
> javascript, java and inline frames?
>
> --
> Alessandro Ronchi
> Skype: aronchi
> http://www.alessandroronchi.net - Il mio sito personale
> http://www.soasi.com - Sviluppo Software e Sistemi Open Source
>
> >
>

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



Import RSS headlines from feeds into django based pages.

2007-12-11 Thread Alessandro

I want to add in a django page some rss feeds from another websites,
like headlines from news portals. how can I do that without
javascript, java and inline frames?

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net - Il mio sito personale
http://www.soasi.com - Sviluppo Software e Sistemi Open Source

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



Import RSS feeds in django pages

2007-12-11 Thread Alessandro Ronchi

I want to add in a django page some rss feeds from another websites,
like headlines from news portals. how can I do that without
javascript, java and inline frames?

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net - Il mio sito personale
http://www.soasi.com - Sviluppo Software e Sistemi Open Source

--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread l5x

Thank you Malcolm, you are very helpful today :)
--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-11 Thread Andreas Pfrengle

Thanks for so many replies and the helpful links. Ubuntu really seems
to be a good solution as far as I can tell by now. I'll give it a try.
At least now I know what I will do on Christmas :-)
--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread Malcolm Tredinnick


On Tue, 2007-12-11 at 04:39 -0800, l5x wrote:
[...]
> change it to:
> 
> def __unicode__(self):
> return smart_unicode(self.ticket_numb)

You were going so well on the "good advice" front up until here... :-)

A __unicode__() method if one of the few places where smart_unicode() is
inappropriate. You should use force_unicode() if you need that function
(in the case at hand, we can save time and just call unicode() directly,
but that's beside the point here).

The reason for preferring/requiring force_unicode() here is if the thing
you are converting is a delayed translation --- something marked with
ugettext_lazy(), for example. The smart_unicode() method leaves a lazy
translation as a lazy translation object, whereas force_unicode() forces
the object to a unicode string. This is why you usually want to call
smart_unicode(): it won't prematurely convert lazy translations to their
string form. However, a __unicode__ method is one place where you
absolutely *must* return a string, not something that might grow up to
be a string one day. So you should use force_unicode() there.

All this is, of course, a moot point if you know the thing you're
converting isn't a lazy translation, which is often the case in a
model's __unicode__(), but it's a good habit to get into in any case.

Regards,
Malcolm

-- 
Monday is an awful way to spend 1/7th of your life. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: creating user and profile in just one form

2007-12-11 Thread l5x

I suppose that you should also check if the username isn't already
taken.
--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread Ivan Levchenko

Thanks to Malcolm for helping me out, and thanks l5x for the help too!

On Dec 11, 2007 2:40 PM, l5x <[EMAIL PROTECTED]> wrote:
>
> Oops, Malcolm answered first :)
>
> >
>



-- 
Best Regards,

Ivan Levchenko
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread l5x

Oops, Malcolm answered first :)
--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread Ivan Levchenko

omg, i feel so dumb... =)

Thats probably what i deserve for blindly following the tutorial and
not thinking =)

On Dec 11, 2007 2:32 PM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
>
> On Tue, 2007-12-11 at 04:21 -0800, [EMAIL PROTECTED] wrote:
> [...]
>
> > Exception Type: TypeError at /admin/trak/ticket/add/
> > Exception Value: coercing to Unicode: need string or buffer, int found
>
> That error usually means you're trying to return something that isn't a
> string from a __str__ or __unicode__ method. Sure enough ...
>
>
> [...]
> > class Ticket(models.Model):
> > class Admin:
> > pass
> > def __unicode__(self):
> > return self.ticket_numb
>
> > def was_submitted_today(self):
> > return self.create_date.date() == datetime.date.today()
> > summary = models.TextField()
> > date_created = models.DateTimeField('date created')
> > status = models.ForeignKey(Status)
> > ticket_text = models.TextField()
> > submitter_name = models.ForeignKey(Submitter)
> > ticket_numb = models.IntegerField().
>
> Since 'ticket_numb' is an integer, you cannot return it unadorned form
> __unicode__. Return unicode(self.ticket_numb) instead.
>
> Regards,
> Malcolm
>
> --
> Two wrongs are only the beginning.
> http://www.pointy-stick.com/blog/
>
>
> >
>



-- 
Best Regards,

Ivan Levchenko
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread l5x

I don't know if it could help, but anyway you should:

1) add the following line at the beggining of models.py

# -*- coding: utf8 -*-

2) change the order of stuff in models, at first fields: CharField
etc, then classes (Admin, Meta) and methods at the end (__unicode__
etc).
3) add after 'coding', at the beggining:

from django.utils.encoding import smart_unicode

3) on model Ticket:

def __unicode__(self):
return self.ticket_numb

change it to:

def __unicode__(self):
return smart_unicode(self.ticket_numb)

I suppose that's the reason. You are returning Integer (ticket_numb is
integer) in __unicode__ when django expects unicode string.

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



Re: creating user and profile in just one form

2007-12-11 Thread Simone Cittadini

Joe ha scritto:
> I've done this but with a manually built form.
>
> You can just add the extra form fields to the template, then reference
> those extra fields in your view.
>   
 Yes, after trying with inline options to no result, I've resolved too 
in using the fields instead of the form to have more granularity :


This is the template :


[..]
Password: {{ f_user.password }}
Clid: {{ f_customer.clid }}
[..]



And the view:

[..]
if request.method == 'POST':
user = User(username=request.POST['username'])
user.set_password(request.POST['password'])
user.save()
customer = CustomerProfile(user=user,
   clid=request.POST['clid'])
customer.save()
[..]


It's not that inelegant in the end ... probably it can get better with 
the fields meta-option of ModelForm


> j
>
> On Dec 10, 5:15 am, Simone Cittadini <[EMAIL PROTECTED]> wrote:
>   
>> I have this code to add a new user :
>>
>> class CustomerForm(ModelForm):
>>
>> class Meta:
>> model = CustomerProfile
>>
>> def add(request):
>> [..]
>> if request.method == 'POST':
>> form = CustomerForm(customer, request.POST)
>> f.save()
>> else:
>> form = CustomerForm(customer)
>> return render_to_response('customer/add.html', locals(),
>> RequestContext(request, {}))
>> [..]
>>
>> which automagically creates a web form where you choose among existing
>> users as one of the CustomerProfile fields.
>>
>> Now since my app as to be (subnormal)user-friendly I want the code to
>> render just one form with name/password fields among the profile ones,
>> and no existing users choice-list, is it possible ?
>> 
> >
>
>   


--~--~-~--~~~---~--~~
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: just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread Malcolm Tredinnick


On Tue, 2007-12-11 at 04:21 -0800, [EMAIL PROTECTED] wrote:
[...]

> Exception Type: TypeError at /admin/trak/ticket/add/
> Exception Value: coercing to Unicode: need string or buffer, int found

That error usually means you're trying to return something that isn't a
string from a __str__ or __unicode__ method. Sure enough ...


[...]
> class Ticket(models.Model):
> class Admin:
> pass
> def __unicode__(self):
> return self.ticket_numb

> def was_submitted_today(self):
> return self.create_date.date() == datetime.date.today()
> summary = models.TextField()
> date_created = models.DateTimeField('date created')
> status = models.ForeignKey(Status)
> ticket_text = models.TextField()
> submitter_name = models.ForeignKey(Submitter)
> ticket_numb = models.IntegerField().

Since 'ticket_numb' is an integer, you cannot return it unadorned form
__unicode__. Return unicode(self.ticket_numb) instead.

Regards,
Malcolm

-- 
Two wrongs are only the beginning. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



just starting out with django along with the tutorial - getting a type error

2007-12-11 Thread [EMAIL PROTECTED]

Hi All,

I'm just starting out with django. I want to get familiar with it to
do some inhouse development for myself. I'm following along the
tutorial, but using my own data and examples - i'm trying to create a
very simple request-ticket system. I have got up to the admin
interface part of the tutorial, and i tried to use the admin interface
to add a ticket, but i got the following error:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/trak/ticket/add/
Django Version: 0.97-pre-SVN-unknown
Python Version: 2.5.1
Installed Applications:
   ['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'mysite.trak',
 'django.contrib.admin']
Installed Middleware:
   ('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/
decorators.py" in _checklogin
  56. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/
main.py" in add_stage
  266. LogEntry.objects.log_action(request.user.id,
ContentType.objects.get_for_model(model).id, pk_value,
force_unicode(new_object), ADDITION)
File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
force_unicode
  51. s = unicode(s)

Exception Type: TypeError at /admin/trak/ticket/add/
Exception Value: coercing to Unicode: need string or buffer, int found



Here is a copy of my models.py file:

from django.db import models
import datetime

# Create your models here.
class Status(models.Model):
class Admin:
pass
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name


class Submitter(models.Model):
class Admin:
pass
name = models.CharField(max_length=200)
email = models.EmailField()
def __unicode__(self):
return self.name

class Ticket(models.Model):
class Admin:
pass
def __unicode__(self):
return self.ticket_numb
def was_submitted_today(self):
return self.create_date.date() == datetime.date.today()
summary = models.TextField()
date_created = models.DateTimeField('date created')
status = models.ForeignKey(Status)
ticket_text = models.TextField()
submitter_name = models.ForeignKey(Submitter)
ticket_numb = models.IntegerField().

As soon as I fill in the form to add a  ticket and click the save
button, i get a django error. The funny thing is that it gets added to
the database:

mysql> select * from trak_ticket;
++-+-+---+-
+---+-+
| id | summary | date_created| status_id | ticket_text |
submitter_name_id | ticket_numb |
++-+-+---+-
+---+-+
|  5 | asdf| 2007-12-11 14:19:05 | 1 | asdf
| 1 |   1 |
++-+-+---+-
+---+-+

Whats up with it?

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



Re: cannot import ModelForm

2007-12-11 Thread l5x

Once again, you were right Malcolm.
Python was importing the old django version, so I did:
python setup.py install

in the trunk and now it's working.

Thank you everyone for your suggestions.

Ps. I'm really happy that ModelForm exists, it's very useful.
--~--~-~--~~~---~--~~
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: parameters getting modified

2007-12-11 Thread annacoder

Hi,
 Thanks for the input.

 Its all because of my misunderstanding of how the URL is handled by
apache.
 Apache does not allow multiple slashes in the path portion of the
URL.
 (It seems there are some security underpinnings, which I did not
understand).
 And there seems to be no way to turn it off.

  My idea was to let someone do, www.xyz.com/post/URL,
 to take the user to a form preloaded with the URL (so the user can
just copy past the url he wants and put it in place of URL in the
above link).

 Since, this is not possible, I have resorted to,
 www.xyz.com/post/?URL, since in this case URL becomes part of the
parameter portion.

Thanks,
Venkat


On Dec 11, 4:06 am, l5x <[EMAIL PROTECTED]> wrote:
> If the example from Rajesh isn't working maybe you should do sth like
> that:
>
> /post// ?
>
> For example:
>
> /post/http/google.com
>
> Then join it 'http' + '://' + 'google.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
-~--~~~~--~~--~--~---