Re: Arithmetic operations in a templete

2007-09-13 Thread James Bennett

On 9/13/07, Scott Anderson <[EMAIL PROTECTED]> wrote:
> What I'm hoping, however, is that this missive was moot, because you'll
> say, "no, Scott, you should just do *this*:", followed by an elegant and
> reasonable solution that I, as a relative newcomer to Django, have not
> yet considered. Here's to your reply, and cheers!

OK, here you go:

Use another template system, either site-wide or for the cases where
the Django template system isn't doing what you need. It's not hard to
do this, and it opens up the possibility of using any or all of the
vast number of Python template systems available.

The Django template system, at this point, will almost certainly
*never* include the type of functionality you're asking for, so use
another template system that does or that's more willing to bend its
philosophy to suit what you want. If you like the rest of the Django
template system I'd suggest you try Jinja, which started as a fork of
Django's template system and so is nearly feature-for-feature
identical, but adds arbitrary Python expressions.


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



ATTN: Moving djangoproject.com to a new server!

2007-09-13 Thread Jacob Kaplan-Moss

Howdy folks --

I'm about to move djangoproject.com (and subdomains) to a new server.
The short version of the changes:

DNS should update within the hour, but if it doesn't, you'll want to
put this in your /etc/hosts (or equivalent)::

64.207.133.18 djangoproject.com
64.207.133.18 www.djangoproject.com
64.207.133.18 code.djangoproject.com
64.207.133.30 media.djangoproject.com

If there are problems, please email me directly at
<[EMAIL PROTECTED]>. Or find me in #django-sprint tonight or
tomorrow.

That's all you need to know, but if you're curious for more details, a
few follow.

So this was motivated by our discovery that djangoproject.com had
become our second-highest-trafficked site -- around 8 million hits a
month -- and had outgrown the two-years-past-EOL server we had it on.

So when a hosting provider offered us a free, beefy box to run the
site on, we were thrilled and took them up on it immediately.

You'll notice that I'm not saying which provider (though if you look
at DNS it should be pretty obvious). I'd like to explain at more
length why we're moving and properly thank the associated parties, so
please do me a favor and wait until the official announcement to ask
questions about the logistics of the move. I'll try to have that
announcement up shortly after the move is done. Watch the blog.

There are some really awesome things this move brings with it, but
I'll also keep those under my hat until the official announcement,
too.

Thanks for your understanding; I hope I don't fuck it up too badly :P

Jacob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-13 Thread Scott Anderson

On Thu, 2007-08-23 at 21:59 +0800, Russell Keith-Magee wrote:
[...]
> Generally speaking - you don't.
> 
> This is by design. Django tries very hard to prevent you from putting
> logic into a template. Logic and calculations belong in the view; the
> template shouldn't have any need for calculations. If you maintain
> this strict separation, it becomes possible to change the template
> without altering the view, and vice versa.
> 
> To this end, the Django template language is not, nor will ever be a
> Turing complete programming language. We have specifically avoided
> adding arithmetic operations, etc.
> There are a few very basic math filters - but they exist only to
> support display-based calculations. How many pixels wide does this DIV
> need to be, given the size of its component parts - that sort of
> thing.
> 
> If you think you need to do arithmetic in a template - think really
> hard about what you are doing. Are you actually trying to change a
> display feature, or are you changing the information that is being
> displayed? If it is the latter, the calculation should be in the view.

Hello,

Interestingly (to me, at least), I'm having issues with this very design
decision right now. Please bear with me, because this is a rather long
response.

While in general I agree with the whole "logic in views and display in
templates" idea, there are some very practical situations in which this
simply becomes a pedantic pain. And while in general Django is a very
nicely practical (yet still elegant) framework, I have to say I dislike
this approach quite a bit.

Here's why:

Let's say I have a set of objects, let's call them Parrots. Each Parrot
has an id, natch.

Now in my template, I'm building a list of these Parrots, and each row
in the list has a button that selects that Parrot when clicked. In
general, in the Javascript and HTML, this looks like this:

Button.create = function(id, label) {
  some script to turn that DOM element into a DHTML button
}


  
  Button.create('parrotButton-1', 'Choose me!');
Hi, I'm the Parrot named Moe, and I'm #1!


  
  Button.create('parrotButton-2', 'Choose me!');
Hi, I'm the Parrot named Schmoe, and I'm #2!


And so on.

The template might look like this:

{% for parrot in parrots %}

  
  Button.create('parrotButton-2',{% trans 'Choose me!')
Hi, I'm the Parrot named {{parrot.name}}, and I'm #{{ parrot.id }}!

{% endfor %}

All well and good. But now let's say I'm an appropriately (read:
responsibly) lazy programmer, and I wish to make a template tag that
outputs button code with a particular ID.

Easy, you say! {% myButton theId, 'Choose me!' %}, with the appropriate
Python code (and parsers, and so on) behind it.

As far as "Choose me!" goes, I can do the ugettext translation in the
tag, of course. However... the obvious problem becomes this: how do I
get "parrotButton-1" into theId? I don't want to hardcode
"parrotButton-" in the Python code, because when I have a list of tree
sloths on the same page, that won't make much sense (nor will it work if
we have both Parrot #1 and Sloth #1 on the same page). 

I could write (or find) a tag that concatenates two strings, and places
the result in the context:

{% cat currentId "parrotButton-" parrot.id %}
{% myButton currentId %}

But what happens when I add other spanky new parameters to my button
tag, like "buttonText" and "buttonClass" and so on? Now I have to first
run a bunch of (possibly) specialized tags to put the values in the
context, and then call the myButton tag.

This reminds me horribly of the Bad Old Days of JSP, which I am
desperately trying to forget.

Ah, you say, but you're doing this wrong! Put this into your view code!

And here (finally) we get to my response to this thread: why on earth
would I put *template specific* code into my view? Now, instead of
having only some Javascript and a template that knows how to manipulate
it by creating the appropriate HTML, I have some Javascript, a template,
and a view that all have to know that the Javascript wants
"parrotButton-" + parrot.id... not only is this a pain, but it's a bad
idea. DRY and all that. Not only not only that, but I also have to
iterate my Parrots twice: once to set a bunch of constructed button IDs
somewhere, and once in the template to print them all out.

However, I don't *want* code in my view that knows about what my
Javascript and my HTML are doing in the first place. The string
"parrotButton-" + parrot.id has absolutely nothing to do with the data.
The view should keep its hands out of this. This is not logic, it's not
a calculation other than in the most remotest sense, and I'd really,
really like to keep this particular construction as close to where it is
used as possible. I also don't want a function on the Parrot itself that
knows to create "parrotButton-" + self.id... that's just silly. In fact,
my view code really shouldn't care if it's using an HTML template with
"Choose me!" buttons, an Excel template with a "Choose me!" 

Re: can't inherit from models?

2007-09-13 Thread Russell Keith-Magee

On 9/14/07, mthorley <[EMAIL PROTECTED]> wrote:
>
> Please some one explain to me why I can't do this, or what
> __metaclass__ hack I have to pull to get it to work? I searched google
> and the list and saw a lot of old (7/2006) pages and discussions about
> this, but nothing current.

Model inheritance is a 'coming soon' feature. The wiki contains
details of how we envisage inheritance will work, but it hasn't been
implemented as yet.

Yours,
Russ Magee %-)

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



Re: django & trac on the same lighttpd?

2007-09-13 Thread Graham Dumpleton

On Sep 14, 1:31 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I did it on Apache with mod-python.  The problem I ran into was that I
> couldn't deploy Django to the root of my site and still serve up other
> content.  I ended up having trac and my Django site sitting in
> subdirectories, /trac and /home respectively.  If I want I can use mod-
> rewrite or something to send a request for / to /home and then
> browsing will be normal at that point.

That sort of thing can be done using mod_python and without using
mod_rewrite, although it does get a bit messy because of how in
general one has to use Location directory to configure Django to run
under mod_python.

FWIW, it is much simpler to do when using mod_wsgi. As example, see
configuration below, which shows combining of Django and Trac plus
serving up of designated static files. I have used daemon mode of
mod_wsgi here so that Django and Trac will run in separate processes
to Apache child processes.

WSGIDaemonProcess django threads=25
WSGIDaemonProcess trac processes=2 threads=10 maximum-requests=500

Alias /favicon.ico /usr/local/mysite/static/favicon.ico

AliasMatch /([^/]*.css) /usr/local/mysite/static/styles/$1


Order deny,allow
Allow from all


WSGIScriptAlias /trac /usr/local/trac/mysite/apache/trac.wsgi


WSGIProcessGroup trac
Order deny,allow
Allow from all


Alias /media/ /usr/local/django/mysite/media/


Order deny,allow
Allow from all


WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi


WSGIProcessGroup django
Order deny,allow
Allow from all


Using mod_rewrite one could probably get even trickier by providing a
rewrite rule that explicitly checked first to see if a static file
existed in static document root and allowing that to override things
and not trigger Django as a consequence. That way you could just dump
arbitrary static files in document root and they would take
precedence.

For more information on mod_wsgi configuration see:

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

Graham

> On Sep 13, 5:19 am, est <[EMAIL PROTECTED]> wrote:
>
> > Could I install django onwww.xxx.comwhiletrac nicely onwww.xxx.com/trac/
> > ?
>
> > My lighttpd.conf is something like this but it is not working
>
> > $HTTP["host"] == "labs.dormforce.net" {
> > server.document-root = "/srv/dormlabs/django-projects/
> > labtest"
> > fastcgi.server = (
> > "/django-projects.fcgi" => (
> > "main" => (
> > # Use host / port instead of socket
> > for TCP fastcgi
> > # "host" => "127.0.0.1",
> > # "port" => 3033,
> > "socket" => "/home/est/django-
> > projects.sock",
> > "check-local" => "disable",
> > )
> > ),
> > )
> > alias.url = (
> > "/media/" => "/srv/dormlabs/django-projects/media/",
> > )
>
> > url.rewrite-once = (
> > "^(/media.*)$" => "$1",
> > "^/favicon\.ico$" => "/media/favicon.ico",
> > "^(/.*)$" => "/django-projects.fcgi$1",
> > )
>
> > }
>
> > $HTTP["url"] =~ "^/trac/.*$" {
>
> > fastcgi.server += ("/trac" =>
> > ("trac" =>
> > (
> > "socket" => "/tmp/trac-fastcgi.sock",
> > "bin-path" => "/opt/trac-0.10.4/share/trac/cgi-
> > bin/trac.fcgi",
> > "check-local" => "disable",
> > "bin-environment" =>  ("TRAC_ENV" =>
> > "/srv/dormlabs/trac")
> > )
> > )
> > )


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Admin page says a ForeignKey("self", null=True) field is required

2007-09-13 Thread Martin Taylor

Found the solution myself:

It seems that you must have both "null=True" and "blank=True" to get
the desired behavior of "not required" for the "Parent" field.  My
modified model has this line now:

Parent = models.ForeignKey("self", null=True, blank=True,
verbose_name="ParentFolder")


On Sep 13, 4:32 pm, Martin Taylor <[EMAIL PROTECTED]> wrote:
> I've created a very simple Django app to model a tree (like a file
> system directory tree).  Here's the model.py file:
>
> from django.db import models
> #
> # Define constants used to control sizes of DB fields
> #
> MAX_NAME =  100  # Maximum size of an object's Name field
> #
> # Create your models here.
> #
> class Folder(models.Model) :
> """
> This class models the Folder tree.
> """
> #
> # Field definitions
> #
> Parent = models.ForeignKey("self", null=True, verbose_name="Parent
> Folder")
> Name   = models.CharField(maxlength=MAX_NAME)
> #
> # Meta options
> #
> class Meta :
> db_table = "Folder"
> #
> # Admin options
> #
> class Admin :
> pass
>
> When I try to add my first Folder in the Admin pages it says:
>  "Please correct the error below.
> * This field is required."
> for the Parent field.
>
> Obviously the first folder in the folder tree, or any top level
> folder, will not have a Parent.  I don't really want to create an
> artificial top level Parent like "root". Any explanation of why this
> is happening and what to do to fix it would be greatly appreciated.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



can't inherit from models?

2007-09-13 Thread mthorley

Please some one explain to me why I can't do this, or what
__metaclass__ hack I have to pull to get it to work? I searched google
and the list and saw a lot of old (7/2006) pages and discussions about
this, but nothing current.

from django.db import models
from django.contrib.auth.models import User and DjangoUser

class MyUser(DjangoUser):
  new_property = models.IntegerField()

I saw this at django snippets, http://www.djangosnippets.org/snippets/317/,
but it is less straight forward than the above, and didn't work for me
anyway.

I also tried something like this, but it didn't work either.

class MyUser(DjangoUser):
  def __new__(cls, name, bases, attrs):
new_class = super(MyUser, cls).__new__(cls, name, bases, attrs)
new_class.add_to_class('new_propery', models.IntegerField())
return new_class

I am using django 0.96, and am aware that I could just use profiles,
but that doesn't work as well in this particular application. If any
one has done this or knows what I'm doing wrong, I would be forever
greatful--ok maybe not forever, but greatful at least till I'm thru
with this project!

Thanks


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



content types question

2007-09-13 Thread [EMAIL PROTECTED]

Helo all,

I have been working with middleware and I need to get a content_type
to be returned so that I can store it in a table. No matter what part
of the site I go to I can't get a content_type to be returned in my
headers: 'CONTENT_TYPE': None, What triggers this to return an actual
number that I can use? and I am using process_response in my
middleware class.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 + sqlalchemy = ?

2007-09-13 Thread Ken Kuhlman

Sorry, my interest in Django is too abstracted for that.  I've got
enough vested interest to want to keep track of the situation, but not
enough to make the push myself.  I'm sure you know the drill.

I've done a little more digging since my post, and found Adam Gomaa's
excellent blog entry [1] on the topic, and your interesting reply [2].

So, the better questions for me to ask (now that I know to ask them)
are:  where can I find details on the status of "1.  The move to the
newforms library," and  "2. A major refactoring of the query
system"?   Are these primary topics of the upcoming sprint?  (Sorry if
these are FAQs -- I don't keep up on the django list).

Thanks for the reply!
-Ken

[1] http://adam.gomaa.us/blog/sqlalchemy-with-django/
[2] http://www.b-list.org/weblog/2007/sep/04/orm-wars/


On Sep 12, 1:13 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 9/12/07, KenKuhlman<[EMAIL PROTECTED]> wrote:
>
> > What is the state of SQLAlchemy integration with Django?  I saw somewhere
> > that it was possible to use them together, but the author didn't provide any
> > details, and the SQLAlchemy branch of Django hasn't had any commits since
> > late last year.
>
> The state is "if someone steps up and writes the code, good on them".
> Are you volunteering?
>
> --
> "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: Django Admin page says a ForeignKey("self", null=True) field is required

2007-09-13 Thread James Bennett

On 9/13/07, Martin Taylor <[EMAIL PROTECTED]> wrote:
> Obviously the first folder in the folder tree, or any top level
> folder, will not have a Parent.  I don't really want to create an
> artificial top level Parent like "root". Any explanation of why this
> is happening and what to do to fix it would be greatly appreciated.

http://www.djangoproject.com/documentation/model-api/#null

"you will also need to set blank=True if you wish to permit empty
values in forms, as the null parameter only affects database storage
(see blank, below)."


-- 
"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: ERROR: permission denied for relation

2007-09-13 Thread [EMAIL PROTECTED]

I finally found my own answer. I am running on django 91 but strangely
enough when I imported a new model into my database my default user
was assigned access to that table instead of the user that I had
assigned to it.  So I went into postgres and changed that and all is
well. anyone know why this happened?

Thanks,

On Sep 12, 2:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Any Ideas on this??
>
> Thanks
>
> On Sep 11, 4:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi I am getting this error when I try to do this:
>
> > get_list = some_table.get_list(where=['user_id=%s' %
> > request.user.id])
>
> > I get this error: (and assuming the users are logged in)
>
> > ERROR: permission denied for relation
>
> > Any Ideas?
>
> > Thanks


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



Re: form_for_instance + user profile

2007-09-13 Thread MikeHowarth

Well I thought I had this working but it turns out it was previous
form I had set up manually.

At the moment I'm getting no form returned at all, from reading the
documentation I'm struggling to see what I'm doing wrong.

My UserProfile model is sat in eshop.shop.models, I'm referencing this
in settings.py like so:

#Use the shop profile model
AUTH_PROFILE_MODULE = 'shop.UserProfile'

Model looks like this:

class UserProfile(models.Model):

title = models.CharField(maxlength=10)
user = models.ForeignKey(User, unique=True)

View looks like this:

user = get_object_or_404(User, id=12)
user_profile = user.get_profile()

UserForm = form_for_instance(user_profile)

if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/url/on_success/')
else:
form = UserForm()

return render_to_response(template_name, {'form': form},
context_instance=RequestContext(request))

Can anyone spot the glaringly obvious mistake I'm struggling to see??


On Sep 12, 8:28 pm, MikeHowarth <[EMAIL PROTECTED]> wrote:
> Yep all working now!
>
> On Sep 12, 8:11 pm, RajeshD <[EMAIL PROTECTED]> wrote:
>
> > > Basic example:
>
> > > user = User.objects.get(id=1)
> > > user_profile = user.get_profile()
>
> > This should work if you have settings.AUTH_PROFILE_MODULE pointing to
> > your UserProfile model. 
> > See:http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



reverse select_related()

2007-09-13 Thread Michael Elsdoerfer

I am using a unique=True foreign key relationship to model inheritance, as
suggested by the documentation. Say a TypedItem model that has a FK to
BaseItem.

Now I am in a situation where it would be really nice to be able to access
the typed item from within the base item, e.g. the one row in
BaseItem.typeditem_set. Unfortunately, for a large number of BaseItems, that
quickly starts to be come suboptimal, as the db is queried at least once for
each, and select_related() only works the other way round, e.g. will not
cache the reverse set.

Any ideas on how to approach this?

Thanks,

Michael


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ifequal function not working?

2007-09-13 Thread jake elliott

hi john -

John M wrote:
> {% ifequal selected_id recordset.id %}   never seems to work.
> 
> where selected_id = 1
> recordset has ID from 1 - 10

just a guess - are selected_id and recordset.id really the same type?
{% ifequal %} will not match for example '1' == 1

best,
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Admin page says a ForeignKey("self", null=True) field is required

2007-09-13 Thread Martin Taylor

I've created a very simple Django app to model a tree (like a file
system directory tree).  Here's the model.py file:

from django.db import models
#
# Define constants used to control sizes of DB fields
#
MAX_NAME =  100  # Maximum size of an object's Name field
#
# Create your models here.
#
class Folder(models.Model) :
"""
This class models the Folder tree.
"""
#
# Field definitions
#
Parent = models.ForeignKey("self", null=True, verbose_name="Parent
Folder")
Name   = models.CharField(maxlength=MAX_NAME)
#
# Meta options
#
class Meta :
db_table = "Folder"
#
# Admin options
#
class Admin :
pass


When I try to add my first Folder in the Admin pages it says:
 "Please correct the error below.
* This field is required."
for the Parent field.

Obviously the first folder in the folder tree, or any top level
folder, will not have a Parent.  I don't really want to create an
artificial top level Parent like "root". Any explanation of why this
is happening and what to do to fix it would be greatly appreciated.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ifequal function not working?

2007-09-13 Thread Alex Koshelev

Hmm... What is `recordset`? QuerySet? QuerySet doesn't have id
attribute.
{% for recod in recodeset %}

{% ifequal record.id selected_id %}
Selected!
{% endifequal %}

{% endfor %}


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



How to automatically apply a method to all fields in newforms subclass?

2007-09-13 Thread Nimrod A. Abing

Hello,

I have several forms that I subclass from a subclass of newforms:

# newforms is aliased as forms
class StrippedFieldsForm(forms.Form)
def strip_field(self, field, error_message):
if (self.clean_data.get(field)):
data = self.clean_data[field].strip()
if (0 == len(data)):
raise forms.ValidationError(error_message)
else:
return data
else:
return ''

class DerivedForm(StrippedFieldsForm):
# ... fields go here ...

# ... for each field I have to do ...
def clean_field1(self):
return self.strip_field('field1', 'Field 1 contains only whitespace.')
def clean_field2(self):
return self.strip_field('field2', 'Field 2 contains only whitespace.')

This gets tedious as there are forms with 10 or more fields.

My question is, is there another way to apply strip_field to *all* or
a select list of fields automatically? My last resort is to override
form.clean() for StrippedFieldsForm.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: ifequal function not working?

2007-09-13 Thread John M

the ID is the primary key ID generated by django on models.

basically, it's not the syntax im having issue with, i think the
selected_id is being passed / parsed as a string not an intenger like
ID is.

J

On Sep 13, 12:45 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Hmm... What is `recordset`? QuerySet? QuerySet doesn't have id
> attribute.
> {% for recod in recodeset %}
>
> {% ifequal record.id selected_id %}
> Selected!
> {% endifequal %}
>
> {% endfor %}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Validating dynamically generated fields (guess i'll need a metaclass)

2007-09-13 Thread Doug B

Could you just use a collection of forms with different prefixes
(which posted back via a hidden field generated by your script)?
add  to each of your
element sets.

class RoomShared(Form):
room_type = IntegerField(widget=Select(choices=BEDROOM_TYPES))
room_price = IntegerField()
is_shared = BooleanField(required=False)

You'd have to change the html of your elements a bit, since you are
appending the identifier and prefix does the opposite.
name = "789-room_price" instead of name="room_price_789" for example

invalid=[]
valid[]
prefixes = request.POST.getlist('form_prefixes')
pforms={}
for p in prefixes:
pforms[p]=RoomShared(request.POST,prefix=p)
if pforms[p].is_valid():
valid.append(p)
else:
invalid.append(p)
do(stuff)
...




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 interface, search fields for many-to-many relationships

2007-09-13 Thread Alice

I'm running into trouble using the admin interface's search feature,
probably due to the default way that tables are being joined. I have
an Actor and a Group, and a many-to-many relationship between them.
(So Actors can be in multiple Groups, and Groups can have multiple
Actors). For the Group object, I'd like the admin interface to search
by the Group's name or by the lastname of an Actor, so I specify these
in the admin class's search_fields. This works ok when I enter the
lastname of an Actor in the search line. But, if I use a Group's name
in the search line, I see a number of repeated results equal to the
number of Actors in the group. (This also gets zero results if the
Group has no Actors, even if the Group name matches the search line.)

Any tips for making the admin interface search pull up only distinct
Groups and not care if a Group has no Actors if the Group name matches
the search? Or should I be trying some other approach altogether?

This seems to be the same thing as described in this previous question
(at the end of the discussion), but I didn't see a solution there.
http://groups.google.com/group/django-users/browse_thread/thread/b0866749612aaeae/135d13ce40c33aa7?lnk=gst=admin+search=2#135d13ce40c33aa7


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



Re: How to automatically apply a method to all fields in newforms subclass?

2007-09-13 Thread Doug B

I think you can make a custom form field to do your validation check
for you.

def StrippedField(forms.CharField):
def clean(self,value):
#do your validation here


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Signals not working correctly

2007-09-13 Thread RajeshD



On Sep 13, 11:13 am, Greg <[EMAIL PROTECTED]> wrote:
> Hello,
> I'm trying to use signals so that when a Publication gets deleted from
> within the Admin it will 'assert False, "Here"'  (This will obviously
> change at a later date).  Currently, when I delete a Publication (in
> the django admin) no assert statement is raised.  So I guess that
> means that my dispatcher.connect is not getting called.  Anybody know
> what I'm doing wrong?

Try moving the dispatcher.connect statement to your models.py.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



ifequal function not working?

2007-09-13 Thread John M

I have a view / template where im passing in a queryset and a value of
what the current selected record, and am tring to setup a option
pulldown to show the selected record.

My problem is that I can't get the passed in selected record to match
the ID of the queryset.

for example:

{% ifequal selected_id recordset.id %}   never seems to work.

where selected_id = 1
recordset has ID from 1 - 10


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ANN: django-admin-uploads (media browser for django admin)

2007-09-13 Thread Peter Baumgartner

On 9/13/07, Dmitry Shevchenko <[EMAIL PROTECTED]> wrote:
> Oh, and i think that it would be a great idea to provide some way to show
> uploaded data only for specific item (e.g. article, news).

Not on my priority list, but it's open-source, have at 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: ANN: django-admin-uploads (media browser for django admin)

2007-09-13 Thread Dmitry Shevchenko
Oh, and i think that it would be a great idea to provide some way to show
uploaded data only for specific item (e.g. article, news).

2007/9/13, Dmitry Shevchenko <[EMAIL PROTECTED]>:
>
> Wow, Peter, thank you very-very much, it's exactly what i've been looking
> for, great work! :)
>
>
> 2007/9/13, Peter Baumgartner <[EMAIL PROTECTED] >:
> >
> >
> > http://code.google.com/p/django-admin-uploads/
> > File/media browser for Django admin interface. Designed to insert
> > images and files into textareas in the admin interface with a simple
> > GUI interface.
> >
> > Just posted this on Google Code. Thought some of you might find it
> > helpful.
> >
> > --
> > Pete
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ANN: django-admin-uploads (media browser for django admin)

2007-09-13 Thread Dmitry Shevchenko
Wow, Peter, thank you very-very much, it's exactly what i've been looking
for, great work! :)


2007/9/13, Peter Baumgartner <[EMAIL PROTECTED]>:
>
>
> http://code.google.com/p/django-admin-uploads/
> File/media browser for Django admin interface. Designed to insert
> images and files into textareas in the admin interface with a simple
> GUI interface.
>
> Just posted this on Google Code. Thought some of you might find it
> helpful.
>
> --
> Pete
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: tinymce popups in the admin interface

2007-09-13 Thread patrickk

you might wanna take a look at:
http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki

there are some screenhosts including tinymce. we didn´t do all the
buttons, because we don´t need them. we also re-styled the admin a
bit. if that´s what you´re looking for, just drop me an email.

patrick


On 13 Sep., 19:35, Thomas Badran <[EMAIL PROTECTED]> wrote:
> Any one have some nice css/theme for making tiny mce look like the rest
> of the admin interface. It integrates so nicely anyway, and would be
> awesome to have it look the same.
>
> Thanks
>
> Tom


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



ANN: django-admin-uploads (media browser for django admin)

2007-09-13 Thread Peter Baumgartner

http://code.google.com/p/django-admin-uploads/
File/media browser for Django admin interface. Designed to insert
images and files into textareas in the admin interface with a simple
GUI interface.

Just posted this on Google Code. Thought some of you might find it helpful.

-- 
Pete

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Validating dynamically generated fields (guess i'll need a metaclass)

2007-09-13 Thread [EMAIL PROTECTED]

Hi all,

I'm adding elements to the DOM so i will not know the number of
elements the HTML form will be having beforehand, hence cannot define
a form class with the exact number of fields i need.

Once the form is POSTed i'm creating a Form instance and setattr-ing
the fields to it.

The problem is that the form.is_valid() is always valid even when no
values are POSTed.

My code is here:
http://dpaste.com/19502/

Should i create a metaclass to have the RoomShared() generated with
the correct number of fields? Or is there a better way?

Thanks,
Lorenzo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Deleting the relations and not the objects?

2007-09-13 Thread Xan

hi,

Suppose for example that we have:

class Aclass(models.Model):
be = models.ForeignKey('B')
ce = models.ManytoManyfield('C')

class B(models.Model):
   [...]

class C(models.Model):
  [...]

Suppose that with admin interface, I put:
be = b1 (b1 is B)
ce has c1, c2, c3 objects (c1, c2 and c3 are in C)

in an object p (p in Aclass)

I want to delete the relation that ce has c1 without deleting c1.
How can I do that with shell?

Do you understand that I want? If I run:
p = Aclass.objects.get(pk=1) # p is the object I have
p.be.all()
   b1
p.ce.all()
   c1, c2, c3

I want that p.ce.all() will be empty set, but c1, c2 and c3 exits as
intances of class C


Thanks in advance,
Xan.


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



Is Britney Spears washed up?

2007-09-13 Thread Juicy Hilton
 Has Britney killed off her career?



*Britney Spears is back in the news. This time, the pop singer is making
headlines because of a lackluster performance during last night's MTV Video
Music Awards. We're not qualified to critique her performance, so we'll rely
on others to beat her up:

**The Washington Post: Dressed in sequined black underpants and bra, an
out-of-shape Spears moved tentatively around the stage, getting totally
outgrooved by her backup dancers and badly lip-syncing her way through the
song whose main lyric was "Gimme, gimme, gimme, gimme." More Details

*

* *

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



tinymce popups in the admin interface

2007-09-13 Thread Thomas Badran

Any one have some nice css/theme for making tiny mce look like the rest
of the admin interface. It integrates so nicely anyway, and would be
awesome to have it look the same.

Thanks

Tom


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



two apps in project using comments. Skip 'posted.html'?

2007-09-13 Thread hotani

First off, this is only working at all because one app is using free
comments while the other is using the standard non-free comment
system. Which means they can use separate templates (free_preview.html
vs preview.html). This is all great until I come to the common
template, 'posted.html'.

Without getting into hacking 'comments.py', is there a way to either
A: bypass the template altogether (preferred. It's useless!), or B:
somehow pass to the template which app the comment is coming from?

If I were to hack comments.py, I'm thinking about having the free
comment function point to a separate template like say,
'free_posted.html'.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Signals not working correctly

2007-09-13 Thread Greg

Hello,
I'm trying to use signals so that when a Publication gets deleted from
within the Admin it will 'assert False, "Here"'  (This will obviously
change at a later date).  Currently, when I delete a Publication (in
the django admin) no assert statement is raised.  So I guess that
means that my dispatcher.connect is not getting called.  Anybody know
what I'm doing wrong?

 views.py

from mysite.test.models import Publication
from django.db.models import signals
from django.dispatch import dispatcher
from mysite.rugs.sig import thesignal

dispatcher.connect(thesignal, signal=signals.post_delete,
sender=Publication)

 sig.py

def thesignal(sender, instance, signal, *args, **kwargs):
assert False, "Here"

 models.py

class Publication(models.Model):
title = models.CharField(maxlength=30)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Signals not working correctly

2007-09-13 Thread Greg

Hello,
I'm trying to use signals so that when a Publication gets deleted from
within the Admin it will 'assert False, "Here"'  (This will obviously
change at a later date).  Currently, when I delete a Publication (in
the django admin) no assert statement is raised.  So I guess that
means that my dispatcher.connect is not getting called.  Anybody know
what I'm doing wrong?

 views.py

from mysite.test.models import Publication
from django.db.models import signals
from django.dispatch import dispatcher
from mysite.rugs.sig import thesignal

dispatcher.connect(thesignal, signal=signals.post_delete,
sender=Publication)

 sig.py

def thesignal(sender, instance, signal, *args, **kwargs):
assert False, "Here"

 models.py

class Publication(models.Model):
title = models.CharField(maxlength=30)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Question about Django+Feedjack

2007-09-13 Thread Chandra

Hi,

I have installed Django and then feedjack, everything went on fine.

I created a site and subscribed to some feeds.

When I run the feedjack_update.py script it is grabbing all the posts
from feeds and posts are visible in the admin interface.

But I couldn't see any posts in the main site. It is still showing 0
posts.

This looks to me like some configuration problem. Can any one help in
identifying the problem. I have even configured the cache option also.

Thanks & Regards
Chandra


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 deployment à lá Capistrano

2007-09-13 Thread rex

Hello.

I'd be interested in helping with writing a Capistrano replacement for
Django in python (not a port!).
I'm relatively new to django sites, but quite an old hand at python.

Regarding names... surely this is the least important part of a
project like this  :)

My 2c though:   dojango! That's what it's doing.. it's doing my django
site... so i don't have to stuff around in an ssh session for 100
years to get the thing working :) Flame away.

Alex

Ps: Chris:  estas en españa? verdad?

On Sep 10, 3:05 am, qwerty <[EMAIL PROTECTED]> wrote:
> Well, I'm interesed in the project and as first idea from the bainstrom is
> the name: Capistrano's url ishttp://www.capify.org/, why can we call it
> capipy, the py at the end is a clasic (tm) of projects coded in Python.
>
> Another good idea is to review the concept of the tool to draw what it
> should and what it should not do:
>
> "automating django's deployment tasks" sounds like a good start for me.
>
> --
> Angel
>
> 2007/9/8, Chris Hoeppner <[EMAIL PROTECTED]>:
>
>
>
> > Hi there,
>
> > This is just to make it a bit more obvious. I've decided to make up a
> > python application similar to Capistrano, for Django.
>
> > I plan it to be similar in the sense of "it uses the same goal, and a
> > few same ideas", and it's not going to be a port of Capistrano to
> > Python.
>
> > I've called this project Djangostrano, though I'll come up with a better
> > name before the folks at 37signals run storms of fury on me :)
>
> > If anyone has done some steps in this direction, please let me know, as
> > we could join forces. Also, if anyone is *interested* in contributing a
> > bit, don't hesitate to contact me.
>
> > A few fundamental guidelines lay already, but I'm still in the
> > brainstorming stage. This is the right stage for anyone to join me.
>
> > I'll be glad to hear from you.
> > --
>
> > Saludos,
>
> > Chris Hoeppner,
> > Passionate about on-line interaction
> >  627 471 720
> >  [EMAIL PROTECTED]
> > www.pixware.org
>
> > -BEGIN PGP SIGNATURE-
> > Version: GnuPG v1.4.6 (GNU/Linux)
>
> > iD8DBQBG4uAdSyMaQ2t7ZwcRAt1NAKDMwg2Pt4PNNO3E3WcxGCJ7T82QAgCgx+25
> > hUzCBlmfaOU4xpcEIO67b2g=
> > =T5O4
> > -END PGP SIGNATURE-


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 & trac on the same lighttpd?

2007-09-13 Thread Chris Moffitt
Yes, you can absolutely have trac and django on the same instance.  When you
say it doesn't work, what is happening?

-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: django-voting question

2007-09-13 Thread [EMAIL PROTECTED]

Thanks Samuel. I tried that, too, but all p.X seemed to return was the
index of the tuple (1, 2, etc).

On Sep 12, 2:54 pm, Samuel Adam <[EMAIL PROTECTED]> wrote:
> Try this :
>
> {% for p in posts %}
> {{ p.0 }}
> {{ p.1 }}
> {% endfor %}
>
> :P


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



Re: how to access the host-name in settings.py

2007-09-13 Thread Alex Koshelev

Where is no way to find host name in settings module. To solve the
problem you can split your settings.py file into host-specified-
settings.py and settings.py
Into settings.py:
from host-specified-settings import *

So you can have one settings.py but many host-specified files at
different servers.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 - Password field and manipulators

2007-09-13 Thread cschand

I have a login form. The model follows

class Login(models.Model):
user_name = models.CharField(max_length=20)
password = models.CharField(max_length=20)

In my view i am trying to create a login form using manipulator

def login(request):
manipulator = Login.AddManipulator()
form = forms.FormWrapper(manipulator, {}, {})
return render_to_response( 'login.html', {'form': form})

>From my template login i can make login and password as input field.
it is working fine

My Question is
 Can I change the input field for password as passwordfield?

Thanks in advance


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



Re: mod_python memory consumption and tuning issues

2007-09-13 Thread Graham Dumpleton

On Sep 13, 6:18 pm, omat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This is more of a python / mod_python configuration issue, but there
> had been some discussions on this list ([1]), and django-users is
> where I feel home, so I am posting here. Sorry.
>
> I am running 7 Django sites with an Apache + mod_python setup, on a
> Fedora Core 4 dedicated server with 2 GB memory. When I restart
> apache, memory usage is somewhere between 200 - 400 MB and quickly
> climbs up to somewhere around 1.5 GB. The sites are not high traffic,
> in total, they generate no more then 20,000 page views daily.
>
> I am not very comfortable with linux server configuration, but with
> the light of ref. [1], I did some examinations. My process list shows
> that there is 1 parent (pid:2293) using 20+ MB, and 21 child apache
> processes using 20-60 MB each.

Using prefork and embedded Python in Apache child processes using
mod_python is not a good idea.

> F   UID   PID  PPID PRI  NIVSZ   RSS COMMAND
> 1 0  2293 1  16   0  23840 11204 -  /usr/sbin/httpd
> 5 0  2300  2293  23   0  19704  4512 -  /usr/sbin/httpd
> 548  2301  2293  15   0  49844 34288 -  /usr/sbin/httpd
> 548  2302  2293  16   0  61092 45344 -  /usr/sbin/httpd
> ...
>
> Size of mod_python.so was over 4 MB, and ldd command shows no link to
> libpython.so, which means that the mod_python was build with a static
> library (which causes huge memory consumption) according to [1].
>
> So, I started with building python2.5.1 with --enable-shared option:
> $ LD_RUN_PATH=/usr/local/lib
> $ export LD_RUN_PATH
> $ ./configure --enable-shared
> $ make
> # make install
>
> Then I installed mod_python3.3.1:
> $ ./configure --with-apxs=/usr/sbin/apxs
> $ make
> # make install
>
> Now the new mod_python.so is 3.8 MB, not 300K as promised. And ldd
> still does not show any reference to libpython. And the memory
> consumption follows the same pattern.

Probably because the Python 'config' directory does not have the
required symlink in it which points to where the shared library was
installed. Ie., in 'config' directory the libpython2.5.a and
libpython2.5.so must be side by side else libtool/ld will not find and
use the shared library. Compiling from Python source code causes this
problem, where as packaged distributions usually ensure it is done
properly.

What I would suggest you do is look at mod_wsgi daemon mode.

See configuration examples in:

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

and for some more complicated automated hosting examples for numerous
applications instances also see Trac examples in:

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

Also look at other documentation on www.modwsgi.org site, including:

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

plus documentation on installation and application issues, which
explain issues like the shared library not being used.

Using daemon mode of mod_wsgi you can separate out your Django
applications into distinct daemon processes for each site and
therefore only incur memory use of site once for each site instead of
once per Apache child process. If you have problems with memory leaks
you can easily set maximum requests before daemon process restarted.
You can also run each Django site as a distinct user if need be.

If certain sites see more traffic to justify additional processes,
then you can easily designate just for that site that it gets more
than default single daemon process.

In summary, with mod_wsgi it is much easier to control memory usage
that mod_python.

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: Populating a form

2007-09-13 Thread Peter Melvyn

On 9/13/07, MikeHowarth <[EMAIL PROTECTED]> wrote:

> Look at form_for_instance in newforms:

I am not sure if it could help me. I try to demostrate my problem on
the view fragment handling post request:

form = MyHTMLForm(request.POST)
if not form.is_valid():
  # will render bound form
else:
  try:
 # posted data processing
  except:
 # will render bound form
  else:
 # Here I need to clear some form's fields without generating
 # error in bound form.
 # I suppose it could be done by creating a new unbound instance
 # of MyHTMLForm and passing values I need to retain as initial values
 # from old form instance.
 # But it seems to be ugly solution
...
  response = (,form,)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Initial value for a choices field in admin?

2007-09-13 Thread Ana

> > the 'default' keyword argument should work, but be sure to use the
> > stored-value(first) element from the stored/representation tuple you use.
>
> > ie if your UNITS tuple is defined
>
> > >>> UNITS = ( ('in', 'Inches'), ('cm', 'Centimeters'), )
>
> > you'll want to use
>
> > >>> class MyModel(models.Model):
> > >>>   units = models.CharField(maxlength=2, choices=UNITS, default='cm')


Hi,
I have similar problem. In my model I have field

owner = models.ForeignKey(User, maxlength=60,  db_index = True)

In application it appears as a combobox with a dashed line as an
initial value.
I'd like to initialize the field with the current username.
I have current user from ThreadLocalsMiddleware.get_current_user()

I tried to use default keyword but in my case it also was unavailable.
I also tried the method You suggested but there is no difference - the
initial value is still dashed line.
Is there any way to make out with it?

Thanks for any help,
Ana


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



how to access the host-name in settings.py

2007-09-13 Thread Julian

hello,

in a view it's easy to find out under wich host the django-project ist
running:

{{{
def view(request):
 from django import http
 hostname = http.get_host(request)
}}}

hostname ist set to localhost:8000 running the django-app with ./
manage.py runserver

but how do i access the full host-name (in this case: http://localhost:8000)
in the settings.py?

reason: i don't want to change the media-url constant when i upload it
to another server...


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



Re: HELP needed POST and Python

2007-09-13 Thread AniNair

Hello,
I wish to make an app that takes id (as integer ) from the user
and displays details. I am using GET to take the value from the  user
to the view. Now I have the id in variable uid in a function
disp_list().

def disp_list(request):
uid = request.GET['id_user']
ed_user=getfrmdb(uid)
return render_to_response('details.html',
{'id':ed_user.id,'name':ed_user.name,

'addr':ed_user.address,'email':ed_user.email,

'ph':ed_user.phone,'comm':ed_user.comments})
  This is working fine. But...
   I have another function in the same view to edit this and I need to
pass this value  [uid]   to it. If I try to pass as an arguement, the
url conf gives error. Can you tell me some other way? I'm just a
beginner, so forgive if I missing something obvious. Thank u.


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



Re: HELP needed POST and Python

2007-09-13 Thread AniNair

It's working fine now. thank you


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



Re: HELP needed POST and Python

2007-09-13 Thread AniNair

Hello,
I wish to make an app that takes id (as integer ) from the user
and displays details. I am using GET to take the value from the  user
to the view. Now I have the id in variable uid in a function
disp_list().

def disp_list(request):
uid = request.GET['id_user']
ed_user=getfrmdb(uid)
return render_to_response('details.html',
{'id':ed_user.id,'name':ed_user.name,
 
'addr':ed_user.address,'email':ed_user.email,
 
'ph':ed_user.phone,'comm':ed_user.comments})
  This is working fine. But...
   I have another function in the same view to edit this and I need to
pass this value  [uid]   to it. If I try to pass as an arguement, the
url conf gives error. Can you tell me some other way? I'm just a
beginner, so forgive if I missing something obvious. Thank u.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Only Simplified Chinese translation not working?

2007-09-13 Thread Ryan K

You are correct Nis...in
django.utils.translation.trans_real.to_locale. No idea why the two
need be any different...

On Sep 13, 10:02 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Ryan K skrev:> Hi. I have a few languages I've translated my site into. They 
> all work
> > except Simplified Chinese. Any hints as to why?
>
> Try being more specific than "does not work". Do you see English,
> garbled characters, something else?> This is in my settings file:
>
> > LANGUAGES = (
> > ('es', ugettext('Spanish')),
> > ('fr', ugettext('French')),
> > ('it', ugettext('Italian')),
> > ('ru', ugettext('Russian')),
> > ('zh-cn', ugettext('Simplified Chinese')),
> > )
>
> > And the .po and .mo files are under the zh-cn directory (in locale).
>
> In my installation, the directory is called zh_CN, not zh-cn. zh_CN is a
> locale-specification, zh-cn is a language specification. I am not sure
> which one is correct, but there definitely is code in django which
> translates from one to the other. Try renaming (or symlonking) to zh_CN
> and see if this helps.
>
> Nis


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Only Simplified Chinese translation not working?

2007-09-13 Thread Ryan K

Yesafter checking the Django sources I saw that zh_CN is where
the .po .mo files should go.

On Sep 13, 10:02 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Ryan K skrev:> Hi. I have a few languages I've translated my site into. They 
> all work
> > except Simplified Chinese. Any hints as to why?
>
> Try being more specific than "does not work". Do you see English,
> garbled characters, something else?> This is in my settings file:
>
> > LANGUAGES = (
> > ('es', ugettext('Spanish')),
> > ('fr', ugettext('French')),
> > ('it', ugettext('Italian')),
> > ('ru', ugettext('Russian')),
> > ('zh-cn', ugettext('Simplified Chinese')),
> > )
>
> > And the .po and .mo files are under the zh-cn directory (in locale).
>
> In my installation, the directory is called zh_CN, not zh-cn. zh_CN is a
> locale-specification, zh-cn is a language specification. I am not sure
> which one is correct, but there definitely is code in django which
> translates from one to the other. Try renaming (or symlonking) to zh_CN
> and see if this helps.
>
> Nis


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 & trac on the same lighttpd?

2007-09-13 Thread est

Could I install django on www.xxx.com while trac nicely on www.xxx.com/trac/
?


My lighttpd.conf is something like this but it is not working


$HTTP["host"] == "labs.dormforce.net" {
server.document-root = "/srv/dormlabs/django-projects/
labtest"
fastcgi.server = (
"/django-projects.fcgi" => (
"main" => (
# Use host / port instead of socket
for TCP fastcgi
# "host" => "127.0.0.1",
# "port" => 3033,
"socket" => "/home/est/django-
projects.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/media/" => "/srv/dormlabs/django-projects/media/",
)


url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/django-projects.fcgi$1",
)



}


$HTTP["url"] =~ "^/trac/.*$" {

fastcgi.server += ("/trac" =>
("trac" =>
(
"socket" => "/tmp/trac-fastcgi.sock",
"bin-path" => "/opt/trac-0.10.4/share/trac/cgi-
bin/trac.fcgi",
"check-local" => "disable",
"bin-environment" =>  ("TRAC_ENV" =>
"/srv/dormlabs/trac")
)
)
)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Populating a form

2007-09-13 Thread MikeHowarth

Look at form_for_instance in newforms:

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



On Sep 13, 9:08 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On 9/11/07, Ole Laursen <[EMAIL PROTECTED]> wrote:
>
> > You can also use the initial parameter when instantiating the form:
>
> And how to solve situation when you've processed posted data and in
> the next step you need to redisplay the same form with some values
> reset to initial values?
>
> Peter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Only Simplified Chinese translation not working?

2007-09-13 Thread Nis Jørgensen

Ryan K skrev:
> Hi. I have a few languages I've translated my site into. They all work
> except Simplified Chinese. Any hints as to why?
>   
Try being more specific than "does not work". Do you see English,
garbled characters, something else?
> This is in my settings file:
>
> LANGUAGES = (
> ('es', ugettext('Spanish')),
> ('fr', ugettext('French')),
> ('it', ugettext('Italian')),
> ('ru', ugettext('Russian')),
> ('zh-cn', ugettext('Simplified Chinese')),
> )
>
> And the .po and .mo files are under the zh-cn directory (in locale).
>   
In my installation, the directory is called zh_CN, not zh-cn. zh_CN is a
locale-specification, zh-cn is a language specification. I am not sure
which one is correct, but there definitely is code in django which
translates from one to the other. Try renaming (or symlonking) to zh_CN
and see if this helps.

Nis

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: mod_python memory consumption and tuning issues

2007-09-13 Thread omat

I have one apache instance for serving both django and static content
but the static content is not served through mod_python (with a
 directive for static content in the virtual host
configuration that does "SetHandler None")

After solving this dynamic / static library issue for mod_python, I am
going to separate static content totally, setting up another apache
instance or with lighttpd or with Amazon S3 for serving static
content, but I do not know which one and how for now.

Did restricting MaxThreadsPerChild imposed a negative effect on
performance?



On 13 Eylül, 11:28, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 13-Sep-07, at 1:48 PM, omat wrote:
>
> > I am running 7 Django sites with an Apache + mod_python setup, on a
> > Fedora Core 4 dedicated server with 2 GB memory. When I restart
> > apache, memory usage is somewhere between 200 - 400 MB and quickly
> > climbs up to somewhere around 1.5 GB. The sites are not high traffic,
> > in total, they generate no more then 20,000 page views daily.
>
> are you serving media also through mod_python? are you restricting
> MaxThreadsPerChild? I find doing these two brings down memory usage
> dramatically
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.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: Foreign key error "Reverse query name for field 'foo' clashes with field Foo.bar"

2007-09-13 Thread Jon Atkinson

Thank you all for your help - I renamed the application.

Best regards,

--Jon

On 9/13/07, Joseph Kocherhans <[EMAIL PROTECTED]> wrote:
>
> On 9/12/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > On Thu, 2007-09-13 at 08:16 +0800, Russell Keith-Magee wrote:
> > [...]
> > > The long term solution is to find a way to do the equivalent of 'from
> > > foo import bar as whiz'. This has been suggested previously; I believe
> > > the sticking point has been finding a syntax that is backwards
> > > compatible, but also elegant and intuitive.
> >
> > This is closed to sovle, form memory .There is a ticket somewhere, but I
> > can't find it at the moment. Joseph Kocherhans started things off and
> > then Vinay Sajip wrote something more comprehensive. So there's a patch
> > in Trac that needs somebody like you or I or Jacob or Adrian to review
> > and approve.
>
> I know that the work I did was very, well, hackish. I would be the
> first to oppose checking it in as-is. I haven't looked at Vinay
> Sajip's work, but here is the ticket in question:
>
> http://code.djangoproject.com/ticket/3591
>
> 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: mod_python memory consumption and tuning issues

2007-09-13 Thread Kenneth Gonsalves


On 13-Sep-07, at 1:48 PM, omat wrote:

> I am running 7 Django sites with an Apache + mod_python setup, on a
> Fedora Core 4 dedicated server with 2 GB memory. When I restart
> apache, memory usage is somewhere between 200 - 400 MB and quickly
> climbs up to somewhere around 1.5 GB. The sites are not high traffic,
> in total, they generate no more then 20,000 page views daily.

are you serving media also through mod_python? are you restricting  
MaxThreadsPerChild? I find doing these two brings down memory usage  
dramatically

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.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: caching and authentication

2007-09-13 Thread patrickk

one additional note:
if 2 users are logged in, the username is displayed correctly for each
user. BUT: if a user is logged-out, his/her username is still
displayed. something doesn´t seem to work here and I can´t figure out
what´s wrong.

On 13 Sep., 10:14, patrickk <[EMAIL PROTECTED]> wrote:
> I´ve upgraded to the current trunk and it´s still not working.
>
> this is my views:
>
> def top_imagegalleries(request):
> ...
>
> response = render_to_response('site/container/
> topimagegalleries.html', {
> 'object_list_left': rendered_object_list_left,
> 'object_list_right': rendered_object_list_right,
> 'category': 'filme',
> 'subcategory': 'bildgalerien',
> 'site_title': 'Bildgalerien',
> 'title': 'Bildgalerien',
> 'sidebar_list': rendered_sidebar_list,
> 'limit': limit.limit,
> }, context_instance=RequestContext(request) )
> patch_vary_headers(response, ['Cookie'])
> return response
> top_imagegalleries = cache_page(top_imagegalleries, 60 * 15)
>
> My username is still displayed on the page when I´m logged out.
> For most of our pages, we use cached blocks within the site, but that
> doesn´t work for all the pages we have. We have to cache some high-
> traffic pages as a "whole" (still displaying the right username
> though).
>
> thanks,
> patrick
>
> On 29 Aug., 17:33, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
>
> > It's clear to me that the docs involving patch_vary_header, cache_page
> > and the cache middleware need to be improved.
>
> > I'm using this thread as proof.  :)
>
> > The cache_page decorator is actually just a wrapper around the cache
> > middleware; think of it as view-specific application ofthe cache
> > middleware.
>
> > In any case, thepatch_vary_headers*should* work with the cache_page
> > decorator; the decorator forms the cache key based on the response.
> > This is a separate problem from the unicode issue.
>
> > Can you provide any info on what isn't working as expected with 
> > thepatch_vary_headerscall?
>
> > On 8/29/07, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > I´ve been too optimistic - the above code doesn´t work.
> > > (This whole caching-issue gives me the willies)
>
> > > On 29 Aug., 12:21, patrickk <[EMAIL PROTECTED]> wrote:
> > > > it´s a bit late, but I just wanted to tell that it works with
> > > >patch_vary_headers.
> > > > in my opinion, this could be explained better in the docs.
>
> > > > so, if one uses a page based on user-authentication and wants to cache
> > > > that page using the cache_page decorator, here´s the code:
>
> > > > def my_view(request):
> > > > 
>
> > > > response = render_to_response('site/whatever/template.html', {
> > > > ...
> > > > }, context_instance=RequestContext(request) )
> > > >patch_vary_headers(response, ['Cookie'])
> > > > return response
> > > > my_view = cache_page(may_view, 60 * 15)
>
> > > > thanks,
> > > > patrick
>
> > > > On 8 Jul., 01:18, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
>
> > > > > On 7/7/07, patrick k. <[EMAIL PROTECTED]> wrote:
>
> > > > > > I don´t understand why the page_cache is keyed by the vary header 
> > > > > > and
> > > > > > the view_cache is not. is there a reason for this?
>
> > > > > You mean cache_page rather than page_cache, but what is view_cache?
>
> > > > > I think I may have spotted the problem: the cache_page decorator runs
> > > > > before the Vary header gets patched for the session access.
>
> > > > > As a test, just before you return your HttpResponse, try adding this
> > > > > to one of your auth views, and try to use the cache_page decorator:
>
> > > > > from django.utils.cacheimportpatch_vary_headers
> > > > >patch_vary_headers(response, ('Cookie',))
>
> > > > > (Maye sure to dump yourcachefirst, too.)


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



mod_python memory consumption and tuning issues

2007-09-13 Thread omat

Hi,

This is more of a python / mod_python configuration issue, but there
had been some discussions on this list ([1]), and django-users is
where I feel home, so I am posting here. Sorry.

I am running 7 Django sites with an Apache + mod_python setup, on a
Fedora Core 4 dedicated server with 2 GB memory. When I restart
apache, memory usage is somewhere between 200 - 400 MB and quickly
climbs up to somewhere around 1.5 GB. The sites are not high traffic,
in total, they generate no more then 20,000 page views daily.

I am not very comfortable with linux server configuration, but with
the light of ref. [1], I did some examinations. My process list shows
that there is 1 parent (pid:2293) using 20+ MB, and 21 child apache
processes using 20-60 MB each.

F   UID   PID  PPID PRI  NIVSZ   RSS COMMAND
1 0  2293 1  16   0  23840 11204 -  /usr/sbin/httpd
5 0  2300  2293  23   0  19704  4512 -  /usr/sbin/httpd
548  2301  2293  15   0  49844 34288 -  /usr/sbin/httpd
548  2302  2293  16   0  61092 45344 -  /usr/sbin/httpd
...

Size of mod_python.so was over 4 MB, and ldd command shows no link to
libpython.so, which means that the mod_python was build with a static
library (which causes huge memory consumption) according to [1].

So, I started with building python2.5.1 with --enable-shared option:
$ LD_RUN_PATH=/usr/local/lib
$ export LD_RUN_PATH
$ ./configure --enable-shared
$ make
# make install

Then I installed mod_python3.3.1:
$ ./configure --with-apxs=/usr/sbin/apxs
$ make
# make install

Now the new mod_python.so is 3.8 MB, not 300K as promised. And ldd
still does not show any reference to libpython. And the memory
consumption follows the same pattern.

Thanks for any help...
oMat


[1] 
http://groups.google.com/group/django-users/browse_thread/thread/3f478214e358bf56


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: caching and authentication

2007-09-13 Thread patrickk

I´ve upgraded to the current trunk and it´s still not working.

this is my views:

def top_imagegalleries(request):
...

response = render_to_response('site/container/
topimagegalleries.html', {
'object_list_left': rendered_object_list_left,
'object_list_right': rendered_object_list_right,
'category': 'filme',
'subcategory': 'bildgalerien',
'site_title': 'Bildgalerien',
'title': 'Bildgalerien',
'sidebar_list': rendered_sidebar_list,
'limit': limit.limit,
}, context_instance=RequestContext(request) )
patch_vary_headers(response, ['Cookie'])
return response
top_imagegalleries = cache_page(top_imagegalleries, 60 * 15)

My username is still displayed on the page when I´m logged out.
For most of our pages, we use cached blocks within the site, but that
doesn´t work for all the pages we have. We have to cache some high-
traffic pages as a "whole" (still displaying the right username
though).

thanks,
patrick

On 29 Aug., 17:33, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> It's clear to me that the docs involving patch_vary_header, cache_page
> and the cache middleware need to be improved.
>
> I'm using this thread as proof.  :)
>
> The cache_page decorator is actually just a wrapper around the cache
> middleware; think of it as view-specific application ofthe cache
> middleware.
>
> In any case, thepatch_vary_headers*should* work with the cache_page
> decorator; the decorator forms the cache key based on the response.
> This is a separate problem from the unicode issue.
>
> Can you provide any info on what isn't working as expected with 
> thepatch_vary_headerscall?
>
> On 8/29/07, patrickk <[EMAIL PROTECTED]> wrote:
>
>
>
> > I´ve been too optimistic - the above code doesn´t work.
> > (This whole caching-issue gives me the willies)
>
> > On 29 Aug., 12:21, patrickk <[EMAIL PROTECTED]> wrote:
> > > it´s a bit late, but I just wanted to tell that it works with
> > >patch_vary_headers.
> > > in my opinion, this could be explained better in the docs.
>
> > > so, if one uses a page based on user-authentication and wants to cache
> > > that page using the cache_page decorator, here´s the code:
>
> > > def my_view(request):
> > > 
>
> > > response = render_to_response('site/whatever/template.html', {
> > > ...
> > > }, context_instance=RequestContext(request) )
> > >patch_vary_headers(response, ['Cookie'])
> > > return response
> > > my_view = cache_page(may_view, 60 * 15)
>
> > > thanks,
> > > patrick
>
> > > On 8 Jul., 01:18, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
>
> > > > On 7/7/07, patrick k. <[EMAIL PROTECTED]> wrote:
>
> > > > > I don´t understand why the page_cache is keyed by the vary header and
> > > > > the view_cache is not. is there a reason for this?
>
> > > > You mean cache_page rather than page_cache, but what is view_cache?
>
> > > > I think I may have spotted the problem: the cache_page decorator runs
> > > > before the Vary header gets patched for the session access.
>
> > > > As a test, just before you return your HttpResponse, try adding this
> > > > to one of your auth views, and try to use the cache_page decorator:
>
> > > > from django.utils.cacheimportpatch_vary_headers
> > > >patch_vary_headers(response, ('Cookie',))
>
> > > > (Maye sure to dump yourcachefirst, too.)


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

2007-09-13 Thread Peter Melvyn

On 9/11/07, Ole Laursen <[EMAIL PROTECTED]> wrote:

> You can also use the initial parameter when instantiating the form:

And how to solve situation when you've processed posted data and in
the next step you need to redisplay the same form with some values
reset to initial values?


Peter

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ManyToMany and save()

2007-09-13 Thread Alessandro Ronchi

2007/9/13, Collin Grady <[EMAIL PROTECTED]>:

> As such, it's impossible to add an m2m link until the object is saved
> - this means that admin's code can't possibly set the m2ms up in time
> for save() to get them, and there is no event or function to hook
> where you can get it.

2007/9/13, Collin Grady <[EMAIL PROTECTED]>:
>
> While I believe you were the one asking this in IRC, I will answer
> here for anyone else stumbling across this :)
>
> ManyToManyField entries are just two IDs - one for each object.
>
> As such, it's impossible to add an m2m link until the object is saved
> - this means that admin's code can't possibly set the m2ms up in time
> for save() to get them, and there is no event or function to hook
> where you can get it.

The object isnt' saved in (1):

   def save(self):
   print "Before save"
   super(Person, self).save() # Call the "real" save() method #(1)
   print "After save"

After that super().save() the object should be saved, or not?
http://www.djangoproject.com/documentation/models/save_delete_hooks/

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



best alternative for subclassing

2007-09-13 Thread Rob Slotboom

For a model I need subclassing which is work on progres. Falling back
to a OneToOne approach seems tricky because "the semantics of one-to-
one relationships will be changing soon". I'm wondering now what to
do. Here's my model in the OneToOne approach.

class Cropcat(models.Model):
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set')
   name = models.CharField(maxlength=70)
   slug = models.SlugField(unique=True, prepopulate_from=('name',))
   text = models.TextField()

class Cropdescription(models.Model):
   name = models.CharField(maxlength=70)
   history = models.TextField()
   etc.

class Crop(models.Model):
   cropcat = models.ForeignKey(Cropcat, blank=True, null=True,
limit_choices_to = {'parent__isnull': False})
   cropdescription = models.OneToOneField(Cropdescription)

class Cropvar(models.Model):
   parent = models.ForeignKey(Crop)
   cropdescription = models.OneToOneField(Cropdescription)


As you can see, all common fiels for Crop and Cropvar live in
Cropdescription. Crop has an extra field for Cropcat.  Cropvar has an
extra field for patent which is a Crop.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---