Re: Verbose name in template

2006-03-28 Thread limodou

On 3/29/06, Topdeck <[EMAIL PROTECTED]> wrote:
>
> Hi there, I was wondering if there's a way to access the verbose_name
> of a field from the template?
>
> Thanks,
>   Topdeck
>

I think it's difficult, if you are using manipulator created by
AddManipulator or ChangeManipulator, and manipulator uses FormField to
show html code, it hasnot a verbose_name attribute in FormField, but
Field has. So there is not a way to access verbose_name now. Maybe I
am wrong.

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

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



ANN:Woodlog Testing

2006-03-28 Thread limodou

I'm very happy announce that woodlog (multiuser blog system is hosted
on DreamHost,  it's openning and receives testing.)

You can test it, but the data may be lost, I only use it to test my project.

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

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



Re: Customising Admin

2006-03-28 Thread Rune Strand


Adrian Holovaty wrote:
> Hey Rune,
>
> That problem has been fixed in Django's development branch and will no
> longer be an issue in the next release.
>
> For now, you could hack around it by removing that button with
> JavaScript using the admin.js hook...
> 
> Adrian

I see!  I'm in no rush so I can wait :-) Thanks a lot.


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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Todd O'Bryan

On Mar 28, 2006, at 8:20 AM, Andy Dustman wrote:

>
> On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>> OperationalError: (2002, "Can't connect to local MySQL server through
>> socket '/var/lib/mysql/mysql.sock' (13)")
>
> This indicates your MySQL server isn't running, and you are using
> DATABASE_HOST="localhost".

We saw this problem because the mysql.sock file was in /tmp/ instead  
of /var/lib/mysql. A symbolic link from /var/lib/mysql/mysql.sock to / 
tmp/mysql.sock solved the problem.

Todd

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



Re: Overthinking urls.py?

2006-03-28 Thread limodou

On 3/29/06, Arthur <[EMAIL PROTECTED]> wrote:
>
> > > "correct" and just as simple, and each time I've failed.  As far as
> > > I'm concerned, if someone can come up with a way to do this that's
> > > stupidly simple then I'm all for a change, but at the same time
> > > get_absolute_url() is a wart I'm willing to live with.
> >
> > In the model you want to know "what is this object's identifier that
> > we would use in a url".   That might be just an object ID, a slug,
> > or maybe /mm/dd/id or who knows what.  This would be formated
> > such that it could be used as-is as PART of a URL.  Let's call this method
> > "get_id_for_url()"  (or whatever you end up calling it)  That seems to be
> > the appropriate type of data to come from a Model.. i.e. not the entire
> > absolute URL, but just a portion of the URL that would be used to
> > identify this Model's object.
> >
> > Then, in the particular view (not clear, it might be and/or in the
> > template) you would want to combine some base URL string with the
> > previous get_id_for_url string to make it into a real url.  To do that
> > might need just a variable "base_url" (or it could be yet another view
> > specific method) that changes by the view.
> >
> > So in a template you'd have to do
> > {{ base_url }}{{ this-object.get_id_for_url }}
> >
> > In your urls.py and/or view you'd setup a dict to pass the appropriate
> > value to the template e.g.
> >info_dict = {
> >'app_label': 'myapp',
> >'module_name': 'mymods',
> >'base_url': 'mymods',
> >}
> >
> > That would allow me to use the generic views if I sent the 'base_url' 
> > correctly,
> > or you could even have it default to the 'module_name'.  Or I could code
> > it into my view's code however I wish.
>
> That's similar to what I do. The get_absolute_url() concatenates a
> _BASE_URL from settings.py or from the top of models.py with
> what you call get_id_for_url. This isn't completely clean but easy to
> change if you remember where to look for the constant.
>
> Arthur

I was do the similar thing. I put a dict in settings.py just like:

APP_ROOT = {'blog':'blog', 'setting':'setting'}
HOST_URL = 'http://mydomain.com'

And I provide some api for get the combined url like:

url = join_app_path('blog', obj.url())

In here, obj.url() just a related path according to the application
url. And join_app_path will auto pick up the HOST_URL, so the result
will be:

'http://mydomain.com/blog/' + obj.url()

the join_app_path will automaticly deal with '/'.

APP_ROOT represents different application url prefix but not including domain.


--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

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



Searching in a foreign table field

2006-03-28 Thread Jaime G. Wong

Hi,

  Newbie here. I've got two models, Song and Queue. The Queue model contains 
foreign keys of songs. In the Admin I want to search for song names so I did:

class META:
admin   = meta.Admin (
list_display  = ('date', 'song'),
search_fields = ('song', ),
)

  ...but I get an exception.

Exception Type: TypeError
Exception Value:got unexpected keyword argument 'song__icontains'

  What am I doing wrong?

-- 
Jaime G. Wong Chacaltana
E-Mail: [EMAIL PROTECTED]
Web   : http://jgwong.org/

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



Re: apache threading - 'QueryDict' object has no attribute '_mutable'

2006-03-28 Thread Eugene Lazutkin

Adrian Holovaty wrote:
> 
> Thanks, guys! I've commited that.

Woot! 1539 and 1442 are both committed! Now all multithreaded guys, and 
MySQL users can start up projects right out of the box without digging 
for "magic incantations" in tickets, mail lists, and blogs!

Thanks,

Eugene


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



Re: Virtual hosting and CommonMiddleware redirects

2006-03-28 Thread Luke Plant

On Wednesday 29 March 2006 00:33, Luke Plant wrote:
> Hi,
>
> I'm using python-hosting which is working great so far.  I've found
> one problem with the way that CommonMiddleware does redirects.
> Python-hosting give you your own apache instance, forwarding on
> requests from the main one on the same machine (I think).  This
> means that HTTP_HOST is not set as you might expect.  

I've found that 'HTTP_X_FORWARDED_HOST' *is* set to what I expect.  Does 
anyone know if this a standard mechanism, and one that Django could use 
if it found it instead of HTTP_HOST?  A quick google suggests Rails 
does this.

Luke

-- 
"A man in love is incomplete until he is married. Then he is finished." 
-- Zsa Zsa Gabor, "Newsweek"

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

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



Virtual hosting and CommonMiddleware redirects

2006-03-28 Thread Luke Plant

Hi,

I'm using python-hosting which is working great so far.  I've found 
one problem with the way that CommonMiddleware does redirects.  
Python-hosting give you your own apache instance, forwarding on 
requests from the main one on the same machine (I think).  This 
means that HTTP_HOST is not set as you might expect.  I've had to 
monkey patch django (magic-removal) as below to get it to work, 
but it is fragile with respect to other potential vhost 
configurations I think.  Any other ideas how to fix this -- either 
fix django or resolve the problem some other way?

Cheers,

Luke



Index: django/middleware/common.py
===
--- django/middleware/common.py (revision 2584)
+++ django/middleware/common.py (working copy)
@@ -31,6 +31,8 @@

 # Check for a redirect based on settings.APPEND_SLASH and 
settings.PREPEND_WWW
 old_url = [request.META.get('HTTP_HOST', ''), request.path]
+if old_url[0].startswith('127.0.0.1'):
+old_url[0] = ''
 new_url = old_url[:]
 if settings.PREPEND_WWW and old_url[0] and not 
old_url[0].startswith('www.'):
 new_url[0] = 'www.' + old_url[0]

-- 
"A man in love is incomplete until he is married. Then he is finished." 
-- Zsa Zsa Gabor, "Newsweek"

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

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



Re: Customising Admin

2006-03-28 Thread Adrian Holovaty

On 3/28/06, Rune Strand <[EMAIL PROTECTED]> wrote:
> Thanks!  I tried that now. The Add-button disappears, but alas the
> 'Save and add another' button is still there and gives an unfriendly
> "Permission denied" if clicked.

Hey Rune,

That problem has been fixed in Django's development branch and will no
longer be an issue in the next release.

For now, you could hack around it by removing that button with
JavaScript using the admin.js hook...

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: Customising Admin

2006-03-28 Thread Rune Strand

Thanks!  I tried that now. The Add-button disappears, but alas the
'Save and add another' button is still there and gives an unfriendly
"Permission denied" if clicked.

I've been reading the Model docs and the META docs, but I can't find
any obvious way.


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



Re: Mixing with Mailman?

2006-03-28 Thread Max Battcher

On 3/26/06, shredwheat <[EMAIL PROTECTED]> wrote:
>
> I'm planning the development of a site that will have several
> integreated mailing lists. I think Django and Mailman could be a good
> mix for this. After some intitial browsing it doesn't look hard to
> import the Mailman package and start querying/setting from Python.
>
> Has anyone travelled this road before? Are there any links of this
> nature?

I've thought about it, but I've not put any work into such a thing. 
I'm not sure I'd have the time, either.

It's interesting in that the Mailman website TODO list for Mailman 3
requires almost a Django-like framework (decent db support, decent
template engine).  Near there it points to one similar attempt, a
Zope-Mailman integration:

http://www.zope.org/Members/srichter/Products/ZMailman

Maybe that will offer some ideas/insight.

--
--Max Battcher--
http://www.worldmaker.net/
All progress is based upon a universal innate desire on the part of
every organism to live beyond its income. --Samuel Butler

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



Re: Overthinking urls.py?

2006-03-28 Thread Glenn Tenney

On Tue, Mar 28, 2006 at 08:44:48PM +0200, Arthur wrote:
> That's similar to what I do. The get_absolute_url() concatenates a
> _BASE_URL from settings.py or from the top of models.py with
> what you call get_id_for_url. This isn't completely clean but easy to
> change if you remember where to look for the constant.

Because the "url" for an object might be different depending on
how you wanted to "see" that object (i.e. depending on the current
view), in your way you'd have to make "get_absolute_url" not actually
be the ABSOULTE URL...   and THAT is the point in what I was suggesting.

That the part of the URL "in front" of the object's unique part is
not a constant for the entire settings.py, but rather is variable
based on the view / tempalte.

-- 
Glenn

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



Re: Overthinking urls.py?

2006-03-28 Thread Arthur

> > "correct" and just as simple, and each time I've failed.  As far as
> > I'm concerned, if someone can come up with a way to do this that's
> > stupidly simple then I'm all for a change, but at the same time
> > get_absolute_url() is a wart I'm willing to live with.
>
> In the model you want to know "what is this object's identifier that
> we would use in a url".   That might be just an object ID, a slug,
> or maybe /mm/dd/id or who knows what.  This would be formated
> such that it could be used as-is as PART of a URL.  Let's call this method
> "get_id_for_url()"  (or whatever you end up calling it)  That seems to be
> the appropriate type of data to come from a Model.. i.e. not the entire
> absolute URL, but just a portion of the URL that would be used to
> identify this Model's object.
>
> Then, in the particular view (not clear, it might be and/or in the
> template) you would want to combine some base URL string with the
> previous get_id_for_url string to make it into a real url.  To do that
> might need just a variable "base_url" (or it could be yet another view
> specific method) that changes by the view.
>
> So in a template you'd have to do
> {{ base_url }}{{ this-object.get_id_for_url }}
>
> In your urls.py and/or view you'd setup a dict to pass the appropriate
> value to the template e.g.
>info_dict = {
>'app_label': 'myapp',
>'module_name': 'mymods',
>'base_url': 'mymods',
>}
>
> That would allow me to use the generic views if I sent the 'base_url' 
> correctly,
> or you could even have it default to the 'module_name'.  Or I could code
> it into my view's code however I wish.

That's similar to what I do. The get_absolute_url() concatenates a
_BASE_URL from settings.py or from the top of models.py with
what you call get_id_for_url. This isn't completely clean but easy to
change if you remember where to look for the constant.

Arthur

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



Re: Overthinking urls.py?

2006-03-28 Thread Max Battcher

On 3/28/06, pbx <[EMAIL PROTECTED]> wrote:
> I think rolling functionality similar to ABSOLUTE_URL_OVERRIDES into
> URLconfs is the way to go. As others have pointed out,
> get_absolute_url() doesn't cover enough ground and creates unnecessary
> coupling.

You realize that because ASOLUTE_URL_OVERRIDES takes arbitrary
functions you could do that today with no framework changes?  (Might
be something worthy of an addition to the body of shortcuts, though,
if someone comes up with a decent version.)

Off the top of my head (don't blame me if it has bugs):

def urlfromconf(object, path):
urlconf = __import__(path)
return urlconf.absolute_url(object)

ABSOLUTE_URL_OVERRIDES = {
'myapp.somemodel': lamda o: urlfromconf(o, 'myapp.urls.somemodelrelated'),
}

Then in myapps.urls.somemodelrelated:

def absolute_url(object):
 return "/path/to/object/%s/" % (object.id)

--
--Max Battcher--
http://www.worldmaker.net/
All progress is based upon a universal innate desire on the part of
every organism to live beyond its income. --Samuel Butler

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



Re: Overthinking urls.py?

2006-03-28 Thread Glenn Tenney

On Tue, Mar 28, 2006 at 12:19:39PM -0600, Jacob Kaplan-Moss wrote:
> "correct" and just as simple, and each time I've failed.  As far as  
> I'm concerned, if someone can come up with a way to do this that's  
> stupidly simple then I'm all for a change, but at the same time  
> get_absolute_url() is a wart I'm willing to live with.


Just thinking aloud...  

In the model you want to know "what is this object's identifier that
we would use in a url".   That might be just an object ID, a slug,
or maybe /mm/dd/id or who knows what.  This would be formated
such that it could be used as-is as PART of a URL.  Let's call this method
"get_id_for_url()"  (or whatever you end up calling it)  That seems to be
the appropriate type of data to come from a Model.. i.e. not the entire
absolute URL, but just a portion of the URL that would be used to
identify this Model's object.

Then, in the particular view (not clear, it might be and/or in the
template) you would want to combine some base URL string with the
previous get_id_for_url string to make it into a real url.  To do that
might need just a variable "base_url" (or it could be yet another view
specific method) that changes by the view. 

So in a template you'd have to do
{{ base_url }}{{ this-object.get_id_for_url }}

In your urls.py and/or view you'd setup a dict to pass the appropriate
value to the template e.g.
   info_dict = {
   'app_label': 'myapp',
   'module_name': 'mymods',
   'base_url': 'mymods',
   }

That would allow me to use the generic views if I sent the 'base_url' correctly,
or you could even have it default to the 'module_name'.  Or I could code
it into my view's code however I wish.

?

-- 
Glenn

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



web

2006-03-28 Thread 2ExtremeStudios.com

Hello, 2ExtremeStudios.com would like to offer you a great deal on a
brand new website for your business.
We invite you to visit www.2ExtremeStudios.com, we offer business
information site design and
e-store integration, as well as other services.


Thanks for your time,
Daniel N.
Phone. 1.416.834.1592
e-mail. [EMAIL PROTECTED]
url. http://2ExtremeStudios.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
-~--~~~~--~~--~--~---



Re: Overthinking urls.py?

2006-03-28 Thread Jacob Kaplan-Moss

On Mar 28, 2006, at 8:55 AM, pbx wrote:
> I think rolling functionality similar to ABSOLUTE_URL_OVERRIDES into
> URLconfs is the way to go. As others have pointed out,
> get_absolute_url() doesn't cover enough ground and creates unnecessary
> coupling.
>
> Simon expresses it well here:
>
>   http://groups.google.com/group/django-developers/msg/ 
> 98ee1a543c40e123

As far as I'm concerned, the problem has always been one of syntax  
and simplicity.  Obviously the model is the wrong place to put a URL  
for all the reasons discussed, but you can't beat it for simplicity.

I've tried a few times to come up with a solution that's both  
"correct" and just as simple, and each time I've failed.  As far as  
I'm concerned, if someone can come up with a way to do this that's  
stupidly simple then I'm all for a change, but at the same time  
get_absolute_url() is a wart I'm willing to live with.

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



Re: What is Caching my DB

2006-03-28 Thread Siah

Thank you Michael,

I must add that on my laptop using django's runserver command, this
problem does not exist.

Moreover, my settings.py middlewares are default installation and holds
no information in regard to caching:

MIDDLEWARE_CLASSES = (
"django.middleware.common.CommonMiddleware",
"django.middleware.sessions.SessionMiddleware",
"django.middleware.doc.XViewMiddleware",
)

I am still stock, so all help is greatly appreciated,
Regards,
Sia


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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Andy Dustman wrote:
> > > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > > >
> > > > This indicates your MySQL server isn't running,
> > > I think it is, since the admin site works fine if I use
> > > manage.py runserver , doesn't it also use the server?
> > >
> > > %myproject]# ps -eadf|grep sql
> > > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > > /usr/bin/mysqld_safe
> > > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > > --socket=/var/lib/mysql/mysql.sock
> > >
> > > unless 'MYSQL server' means somthing different from mysqld ??
> > >
> > >
> > > > and you are using DATABASE_HOST="localhost".
> > > well I use ='', but that should be the same
> > >
> > > but isn't that correct, since mysqld runs on the same host as django?
> >
> > Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
> how do I do that? I can't 'become' apache
> from the permissions it looks readable
>
> myproject$ ls -lst /var/lib/mysql/mysql.sock
> 4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
> myproject$ ls -lst /tmp/mysql.sock

But is the parent directory world-readable? i.e. ls -ld /var/lib/mysql

> there a link to it in /tmp :
> 4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
> /var/lib/mysql/mysql.sock
> [EMAIL PROTECTED] myproject]$
>
> > surprised to see it put the socket there, since (on Gentoo)
> > /var/lib/mysql is only accessible by the user the mysql server runs
> > as, so it puts the socket (which needs to be world-readable and
> > writable) in /var/run.
>
> >
> > When you run manage.py runserver, are you running as root?
> yes (should I?), but I can also run as myself, doesn't matter

You probably shoudn't run it as root on general principle. Make sure
you can access it as a non-root user. The error indicates it did not
get as far as the authentication phase so I am still leaning towards
filesystem permissions. You're not running a chroot apache by any
chance, are you? SELinux? Some sort of virtualization? I guess you
could try 127.0.0.1 for the database host which will make it use TCP
and see if that makes a difference.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

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



Re: apache threading - 'QueryDict' object has no attribute '_mutable'

2006-03-28 Thread Adrian Holovaty

On 3/25/06, Eugene Lazutkin <[EMAIL PROTECTED]> wrote:
> The patch is in the Trac: http://code.djangoproject.com/ticket/1539.
> I've submitted both versions for the Django trunk and the magic-removal
> branch.
>
> Big thanks to Alex Brown for finding the bug and testing the fix.

Thanks, guys! I've commited that.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: ASCII or PDF version of docs?

2006-03-28 Thread Glenn Tenney

On Tue, Mar 28, 2006 at 11:11:58AM -0600, Adrian Holovaty wrote:
> Alternatively (or maybe additionally), we could have a separate
> downloadable tarball of all the docs in HTML format, with all the CSS
> and images. I would prefer not to include all of that in the main
> Django distribution, because it's a lot of cruft.

Regardless of whether you include all the html/css or not, or the
ability to create it after you un-tar a release package, the key point
I was trying to make is:

  The portion of the online doc covering the models (at
  http://www.djangoproject.com/documentation/models/ ) is a critical and
  absolutely necessary part of the documentation as it now exists.

  The examples are not merely "examples", they include some
  documentation that does not appear anywhere else in the docs.

Making the html/css or even pdf a separate download component is fine,
but the docs as part of the base tar file of Django must include all
the docs -- and that must include the example docs too.  ---OR--- the
docs need to be rewriten to bring the documentation aspects of all the
examples into the "docs" another way.

Thanks

-- 
Glenn Tenney

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



Re: ASCII or PDF version of docs?

2006-03-28 Thread Arthur

> > I maintain that all of the online docs need to be in the tar file...
>
> It would be nice and clean to take the code that converts the ReST
> docs into HTML, and the unit tests into HTML, and bundle that with
> Django along with a simple view that displays it, converting the docs
> on the fly -- so you can run a local Django instance to get the docs
> in HTML.

+1 on this one. The last time I've tried building the docs I've run
into some problems (some files gave errors where I wasn't sure whether
my setup was to blame) and the style information is missing. This
would hopefully also help to keep the docs more up to date as more
people would find inconsistencies when using the trunk or branches.

Arthur

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



Re: ASCII or PDF version of docs?

2006-03-28 Thread Adrian Holovaty

On 3/28/06, Glenn Tenney <[EMAIL PROTECTED]> wrote:
> Are these examples helpful?   Certainly, but...
>
> (a) they need to be in a different and much more obvious location... oh,
> in the docs directory would be a start.
>
> (b) they are not the complete text of what's online and the parts that
> are missing are in fact critical to one trying to learn Django.
>
> I maintain that all of the online docs need to be in the tar file...

It would be nice and clean to take the code that converts the ReST
docs into HTML, and the unit tests into HTML, and bundle that with
Django along with a simple view that displays it, converting the docs
on the fly -- so you can run a local Django instance to get the docs
in HTML.

Alternatively (or maybe additionally), we could have a separate
downloadable tarball of all the docs in HTML format, with all the CSS
and images. I would prefer not to include all of that in the main
Django distribution, because it's a lot of cruft.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: display_inline=True?

2006-03-28 Thread Wilson Miner

AFAIK, it's not really in the scope of the admin to display
information that can't be edited. Anything along those lines is
probably a candidate for customization.

On 3/28/06, pbx <[EMAIL PROTECTED]> wrote:
>
> When viewing one object in the admin (say, a Landlord) I'd like to be
> able to display a list of related objects (say, Properties). The
> edit_inline feature is overkill, because the Properties don't need to
> be edited in place -- and they have too many fields to fit comfortably
> inline anyway.
>
> Basically I'm looking for a way to display a list of related objects
> (simple obj.__str__() values, or perhaps a few fields named in a
> Meta.inline_display tuple) that could be clicked on for detailed
> editing.
>
> (A nice refinement would be a JS checkpoint to make sure people weren't
> abandoning changes made to, e.g., the Landlord object.)
>
> Does anything like this exist?
>
> thanks
>
> pb
>
>
>
>

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



Re: Customising Admin

2006-03-28 Thread Wilson Miner

If you only give the user permission to change your object, they will
not see an add button when they log in.

On 3/28/06, Rune Strand <[EMAIL PROTECTED]> wrote:
>
> Just to learn Django, I'm 'porting' a small CMS I wrote in PHP for a
> customer. While the standard admin buttons "Save an add another", "Save
> and continue editing" and "Add ..." makes perfectly sense in most of
> the back-end functionality, I have one page where it doesn't: A
> Settings page where things like No. of Articles to list on the first
> page, image widths, paths etc. can be set.
>
> This is just a single page with a bunch of textfields, checkboxes etc.
> In DB it's only one row. I set default values in the model. Optimally
> there is only a "Save" button and when the user clicks "Configuration"
> in the Admin Index, he should go directly to this page.
>
> So what I wonder is: How to bypass the Add-mechanism and how to remove
> the buttons I don't need?
>
> Considering the absurd amount of time I spent writing this back-end in
> PHP, Django generally feels like a ligther compared to a flintstone.
>
>
>
>

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



Re: Overthinking urls.py?

2006-03-28 Thread pbx

I think rolling functionality similar to ABSOLUTE_URL_OVERRIDES into
URLconfs is the way to go. As others have pointed out,
get_absolute_url() doesn't cover enough ground and creates unnecessary
coupling.

Simon expresses it well here:

  http://groups.google.com/group/django-developers/msg/98ee1a543c40e123


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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread abe


Andy Dustman wrote:
> On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> >
> > Andy Dustman wrote:
> > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > >
> > > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > >
> > > This indicates your MySQL server isn't running,
> > I think it is, since the admin site works fine if I use
> > manage.py runserver , doesn't it also use the server?
> >
> > %myproject]# ps -eadf|grep sql
> > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > /usr/bin/mysqld_safe
> > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > --socket=/var/lib/mysql/mysql.sock
> >
> > unless 'MYSQL server' means somthing different from mysqld ??
> >
> >
> > > and you are using DATABASE_HOST="localhost".
> > well I use ='', but that should be the same
> >
> > but isn't that correct, since mysqld runs on the same host as django?
>
> Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
how do I do that? I can't 'become' apache
from the permissions it looks readable

myproject$ ls -lst /var/lib/mysql/mysql.sock
4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
myproject$ ls -lst /tmp/mysql.sock

there a link to it in /tmp :
4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
/var/lib/mysql/mysql.sock
[EMAIL PROTECTED] myproject]$

> surprised to see it put the socket there, since (on Gentoo)
> /var/lib/mysql is only accessible by the user the mysql server runs
> as, so it puts the socket (which needs to be world-readable and
> writable) in /var/run.

>
> When you run manage.py runserver, are you running as root?
yes (should I?), but I can also run as myself, doesn't matter

thanks, -E


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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > socket '/var/lib/mysql/mysql.sock' (13)")
> >
> > This indicates your MySQL server isn't running,
> I think it is, since the admin site works fine if I use
> manage.py runserver , doesn't it also use the server?
>
> %myproject]# ps -eadf|grep sql
> root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> /usr/bin/mysqld_safe
> mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> --socket=/var/lib/mysql/mysql.sock
>
> unless 'MYSQL server' means somthing different from mysqld ??
>
>
> > and you are using DATABASE_HOST="localhost".
> well I use ='', but that should be the same
>
> but isn't that correct, since mysqld runs on the same host as django?

Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
surprised to see it put the socket there, since (on Gentoo)
/var/lib/mysql is only accessible by the user the mysql server runs
as, so it puts the socket (which needs to be world-readable and
writable) in /var/run.

When you run manage.py runserver, are you running as root?
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:

> OperationalError: (2002, "Can't connect to local MySQL server through
> socket '/var/lib/mysql/mysql.sock' (13)")

This indicates your MySQL server isn't running, and you are using
DATABASE_HOST="localhost".
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

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



Re: Custom annotations on error emails

2006-03-28 Thread Ned Batchelder




I guess I don't have a clear opinion on the best way to do it.  Keep it
in mind, and maybe another data point will make the decision clear. 
For now, I've used an egregious hack (I've stuffed the data I want to
see into a META field so the default processing will show it to me!).

--Ned
[EMAIL PROTECTED]

Adrian Holovaty wrote:

  On 3/27/06, Ned Batchelder <[EMAIL PROTECTED]> wrote:
  
  
I'd like to add some custom annotations on the traceback emails that get
sent when an exception occurs and DEBUG = False.  For example, we are
using our own user representation, and would like to include the user
identity in the traceback.

I can hack into the code that generates these emails, but I'd rather do
it as a hook of some sort.  Has this been done before?  Should I create
a new kind of hook (ERROR_ANNOTATER) to go alonside middleware and
context processors?  Have I overlooked a simple way to accomplish this
already?

  
  
Would the process_exception() middleware hook work for you?

http://www.djangoproject.com/documentation/middleware/#process-exception

It doesn't override the sending of the error e-mail, but you could do
a separate logging of the user information, I guess. Alternatively, we
might be able to move the standard error e-mailing bit into a
middleware of its own, so it can be overridden. If neither of those
solutions work, we could add a specific hook for this, too. Let us
know what you think!

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com




.

  


-- 
Ned Batchelder, http://nedbatchelder.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  -~--~~~~--~~--~--~---





Get objects in _manipulator_validate_.....() methods

2006-03-28 Thread Rudolph

I'm writing a _manipulator_validate_.() method. These methods
become methods for the manipulator of a model and will be validated
before save() is called. Any exception of  validators.ValidationError
will very nicely be displayed in the admin interface (if your raise
such an exception in _pre_save, it won't work that way :-( ).

By Googling around I discovered that self.original_object points to the
old object. Which can be very helpfull. But I would also like to access
other objects from the same model (by using get_object or get_list on
the module). Is there a way to do this? It must be possible (for
example to check if the new value is unique for the whole model, or to
check if a value exists in another field of another object).

I'm using the current trunk but willing to change to Magic Removal if
that solves it.

Thanks in advance!

R.


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



Re: Overthinking urls.py?

2006-03-28 Thread Doug Van Horn

A sed won't work in all situations as it relies on the fact that you
constuct the URL in a particular way.  What if the URL is constructed
dynamically in a template?  Or in code?

Not to mention the fact that it breaks application encapsulation.  If I
have ten integrated apps deployed a syntax change to one application
can ripple through the other 9.  Java contamination or no, that's not
good code.

Not to belabor the point, but I think the concern has merit.

doug.


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



Re: admin apache solved? / now mysql problem

2006-03-28 Thread abe


Adrian Holovaty wrote:
> On 3/24/06, abe <[EMAIL PROTECTED]> wrote:
> > I get a blank screen (in the browser) and the
> > httpd error logs say :
> >
> > [Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal
> > Segmentation fault (11)
> >
> > does anybody have an idea what goes wrong?
>
> Hey there,
>
> Check out the Django/mod_python docs for some possible explanations/solutions.
>
> http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault
>
> Adrian

slowly making progress...

I removed mod_php from the httpd.conf
and installed a newer version of MySQLdb (1.0 -> 1.2.0)

It seems to get a bit further (not completely sure about that)
but now mysql gives problems.
If I try to reach te admin site I get the following error message
in the browser window (just plain text, not the django error page
type):

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 165, in handler
return ModPythonHandler()(req)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 145, in __call__
response = middleware_method(request, response)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/middleware/sessions.py",
line 74, in process_response
session_key = request.session.session_key or
sessions.get_new_session_key()

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/models/core.py",
line 110, in _module_get_new_session_key
get_object(session_key__exact=session_key)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/utils/functional.py",
line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1355, in function_get_object
obj_list = function_get_list(opts, klass, **kwargs)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1395, in function_get_list
return list(function_get_iterator(opts, klass, **kwargs))

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1376, in function_get_iterator
cursor = db.db.cursor()

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/db/backends/mysql.py",
line 67, in cursor
self.connection = Database.connect(**kwargs)

  File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66,
in Connect
return Connection(*args, **kwargs)

  File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)

OperationalError: (2002, "Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13)")


if I use manage.py runserver on the localhost, I get the normal admin
login page.


any idea's how to solve this? I googled for the error message but I
don't find much 
django specific

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



Re: Manipulator fields

2006-03-28 Thread limodou

On 3/28/06, PythonistL <[EMAIL PROTECTED]> wrote:
>
> In my program I use something like this:
>
> #
> 
> ...
>
> for Field in manipulator.fields:
> #do something
> print Field
>.
> ..
> #
> print Field  there
> can print the correct value that is e.g.
>  name="Pieces_4" size="4" value="" maxlength="4" />
>
> but because Field is  an instance I can not use that in
> further processing e.g.
> string.replace(Field ,'id=','disabled id=')
>
> Is there any solution to my problem that is how to replace any text in
> the Field?
> Thanks for reply
> L.
>

every formfield has a render() method, and the function need a data
parameter, so you can use it to get the output html code with the
properly data. or just using str(field) to get the html code.

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

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



Re: follow relationship

2006-03-28 Thread Todd O'Bryan


On Mar 27, 2006, at 11:40 PM, Ivan Sagalaev wrote:

>
> Todd O'Bryan wrote:
>
>> The tutorial explains how to get objects based on field values, but I
>> need to get a subset of the objects in a OneToMany relationship based
>> on one of their values. Here's an example:
>>
>> BRANCH_KINDS = ((0, 'Main'), (1, 'Auxiliary'), (2, 'Dead'),)
>>
>> class Trunk(meta.Model):
>>  name = meta.CharField(max_length=10)
>>
>> class Branch(meta.Model):
>>  trunk = meta.ForeignKey(Trunk)
>>  kind = meta.IntegerField(choices=BRANCH_KINDS)
>>
>> Say I have a Trunk object and want to get all of its Auxiliary
>> branches. How the heck do I do that?
>>
>>
> Since your DB doesn't know anything about BRANCH_KINDS values you  
> should
> manually find a number corresponding a value and use it for lookup:
>
> from myproject.myapp.models import BRANCH_KINDS
>
> index = [bk[1] for bk in BRANCH_KINDS].index('Auxillary')
> trunks.get_branch_list(kind__exact=BRANCH_KINDS[index][0])
>
> But it anyway looks strange that you need to make a DB lookup based on
> values intended only for display purposes and that can be changed  
> any time.

Thanks. It was the second line I couldn't figure out. (Simple in  
hindsight.)

Your comment at the end got me thinking, though. Writing

trunk.get_branch(kind__exact=2)

is not very illuminating, but you're correct that the value 'Dead'  
could get changed later. In Java, I'd use constants for the integer  
values

public static final int DEAD = 2;

but that seems to violate DRY, because the semantics is already  
listed in the choices list. I like using integers for what end up  
being enumerated types because they don't take much space in the  
database and, as you mentioned, it's easy to change the English  
version without having to do anything to the db representation.

Is there a better way to do this kind of thing?

Todd

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



Re: customised generic view

2006-03-28 Thread yml

Thank you Michael,

This make sense now to me, I was expecting to much from 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
-~--~~~~--~~--~--~---



Re: Manipulator fields

2006-03-28 Thread bruno desthuilliers

PythonistL wrote:
> In my program I use something like this:
> 
> #
> 
> ...
> 
> for Field in manipulator.fields:

s/F/f/
it's an instance, not a class (Python's convention is to use CamelCase
for classes and all_lowers for instances).

> #do something
>   print Field
>.
> ..
> #
> print Field  there
> can print the correct value that is e.g.
>  name="Pieces_4" size="4" value="" maxlength="4" />
> 
> but because Field is  an instance I can not use that in
> further processing e.g.
> string.replace(Field ,'id=','disabled id=')


use 'disabled="disabled"' (xhtml compatibility)


And : this is not "because field is an instance", this is "because field
is not a string" (hint: *everything* in Python is an instance).

> Is there any solution to my problem that is how to replace any text in
> the Field?

s/'text in the field'/'string generated by the field's __str__() method'/


Sorry if I look overly pedantic, but correct naming is the prerequisite
to correct understanding.



Depends on what you're trying to achieve. If you want to get the text
generated by the field's __str__() method, modify this text, then use
it, you can do something like:

tags = []
for field in manipulator.fields:
  tags.append(str(field).replace('id=', 'disabled="disabled" id=')


But this won't impact the field object itself, so further calls to
field.__str__ will be as usual.

Another solution would be to subclass Fields classes and write your own
manipulators, but this would require a lot of (boring) work.

Yet another solution solution (and a far better one IMHO) is to take
advantage of Python's delegation mechanisms and use the decorator
pattern (nb : not tested):

class DisabledField(object):
  def __init__(self, field):
self._field = field

  def __str__(self):
return str(self._field).replace('id=', 'disabled="disabled" id=')

  def __getattr__(self, name):
return getattr(self._field, name)

for id, field in enumerate(manipulator.fields):
  manipulator.fields[id] = DisabledField(field)

Then you can use your manipulator as usual.

My 2 cents...
-- 
bruno desthuilliers
développeur
[EMAIL PROTECTED]
http://www.modulix.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
-~--~~~~--~~--~--~---



Re: choices

2006-03-28 Thread Todd O'Bryan

On Mar 27, 2006, at 10:13 PM, Max Battcher wrote:
> If you visit the Admin's documentation site (link in the top bar),  
> under
> Models it will point you to the fact that Django magically creates a
> function for you to do just that.  In your example this would be:
>
> something.get_kind_display()

Thanks for the pointer. It might be good to mention the  
get_FOO_display() method
in the model portion of the documentation where it talks about choices.

I missed it in the database API because it's not clear from the name  
that it
has anything to do with the choices option.

Todd

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



Re: customised generic view

2006-03-28 Thread Michael Radziej

yml schrieb:
> Eureka!
 > [...]

:-)

> Based on this, I can tell you that I do not understand at all what the
> following statement is doing.
> manipulator.do_html2python(new_data)

It converts the form data as received from the http POST request 
(strings) into the datatypes for the associated database fields (i.e., 
numbers, dates, etc.)

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



Manipulator fields

2006-03-28 Thread PythonistL

In my program I use something like this:

#

...

for Field in manipulator.fields:
#do something
print Field
   .
..
#
print Field  there
can print the correct value that is e.g.


but because Field is  an instance I can not use that in
further processing e.g.
string.replace(Field ,'id=','disabled id=')

Is there any solution to my problem that is how to replace any text in
the Field?
Thanks for reply
L.


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



Re: customised generic view

2006-03-28 Thread yml

Eureka!

Thank you all for your help and support. After 2 days of test and
fails. here it is the solution:
Here it is the save function which is solving my issue:

def save(self, new_data):
temp = Profile(
user=users.get_object(pk=new_data['user']),
pseudo=new_data['pseudo'],
#gender=new_data['gender'],
#address=new_data['address'],
#phonenumber=new_data['phonenumber'],

#want_to_publised_personal_info=new_data['want_to_publised_personal_info'],
want_to_publised_personal_info= False,

memberShipLevel=memberships.get_object(pk=new_data['memberShipLevel'])
)
#temp.set_localisation(newdata['localisation'])
temp.save()
return temp


Based on this, I can tell you that I do not understand at all what the
following statement is doing.
manipulator.do_html2python(new_data)

Does someone could help me on this?

Thank you again for open sourcing 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
-~--~~~~--~~--~--~---



Customising Admin

2006-03-28 Thread Rune Strand

Just to learn Django, I'm 'porting' a small CMS I wrote in PHP for a
customer. While the standard admin buttons "Save an add another", "Save
and continue editing" and "Add ..." makes perfectly sense in most of
the back-end functionality, I have one page where it doesn't: A
Settings page where things like No. of Articles to list on the first
page, image widths, paths etc. can be set.

This is just a single page with a bunch of textfields, checkboxes etc.
In DB it's only one row. I set default values in the model. Optimally
there is only a "Save" button and when the user clicks "Configuration"
in the Admin Index, he should go directly to this page.

So what I wonder is: How to bypass the Add-mechanism and how to remove
the buttons I don't need?

Considering the absurd amount of time I spent writing this back-end in
PHP, Django generally feels like a ligther compared to a flintstone.


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