Re: Deployed url mapping

2007-02-18 Thread Malcolm Tredinnick

On Sat, 2007-02-17 at 23:42 -0800, kbochert wrote:
> 
> 
> On Feb 17, 11:04 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
[...]
> > It will very much vary on a per-host basis. Django code may not be
> > responsible for serving all of the URLs for a particular site, for
> > example. Somewhere in the web server's configuration (regardless of
> > which web server is being used), there will be a setting that says
> > "everything under this part of the URL tree gets passed off to that
> > Django process over there for processing". Different parts of the URL
> > tree may be passed off to different Django instances. So whether Django
> > is responsible for serving a response towww.mysite.com/depends on the
> > configuration of your site.
> >
> Do you mean the configuration of my site, or my host's configuration
> of the server?

The server: without at least some minimal server configuration (and
possibly some intermediate setup on your side as well), your code is
never going to be called.

> Do I need to talk to my host to find this out, and then have different
> url.py
> files for development  and deployment?
> 
> I.E., how do I design and test a url.py which will work on my host?.

Have a look in Django's installation document (and fastcgi setup
document) for a couple of examples of how Django can be integrated with
a webserver.

If you are really confused about this, then trying to install your app
in a hosting environment without first testing it on your local machine
with your own copy of Apache, etc, is probably going to be a long and
frustrating exercise, because you just won't know what to expect or be
able to ask the right questions of your hosting provider.

The sort of things you would need to know include: are you using
mod_python (not particularly common on a cohosting site)? Does your
hosting provider support fastcgi so that you can access Django that way?
Are they a known Django-friendly hosting provider or do they say "what's
Django" (the latter case is much harder for people who are not
experienced in setting these things up, because you are going to have to
solve almost all problems yourself).



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

2007-02-18 Thread kbochert



On Feb 18, 12:05 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2007-02-17 at 23:42 -0800, kbochert wrote:
>
> > On Feb 17, 11:04 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
> [...]
> > > It will very much vary on a per-host basis. Django code may not be
> > > responsible for serving all of the URLs for a particular site, for
> > > example. Somewhere in the web server's configuration (regardless of
> > > which web server is being used), there will be a setting that says
> > > "everything under this part of the URL tree gets passed off to that
> > > Django process over there for processing". Different parts of the URL
> > > tree may be passed off to different Django instances. So whether Django
> > > is responsible for serving a response towww.mysite.com/dependson the
> > > configuration of your site.
>
> > Do you mean the configuration of my site, or my host's configuration
> > of the server?
>
> The server: without at least some minimal server configuration (and
> possibly some intermediate setup on your side as well), your code is
> never going to be called.
>
> > Do I need to talk to my host to find this out, and then have different
> > url.py
> > files for development  and deployment?
>
> > I.E., how do I design and test a url.py which will work on my host?.
>
> Have a look in Django's installation document (and fastcgi setup
> document) for a couple of examples of how Django can be integrated with
> a webserver.
>
> If you are really confused about this, then trying to install your app
> in a hosting environment without first testing it on your local machine
> with your own copy of Apache, etc, is probably going to be a long and
> frustrating exercise, because you just won't know what to expect or be
> able to ask the right questions of your hosting provider.

So using Django requires a facility with Apache? Not what I expected!

>
> The sort of things you would need to know include: are you using
> mod_python (not particularly common on a cohosting site)? Does your
> hosting provider support fastcgi so that you can access Django that way?
> Are they a known Django-friendly hosting provider or do they say "what's
> Django" (the latter case is much harder for people who are not
> experienced in setting these things up, because you are going to have to
> solve almost all problems yourself).

I was considering using a Django-friendly host (maybe Webfaction).
Do I just ask them how I should write urls.py for my particular
directory structure?


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

2007-02-18 Thread Malcolm Tredinnick

On Sun, 2007-02-18 at 00:20 -0800, kbochert wrote:
> 
> 
> On Feb 18, 12:05 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
[...]
> >
> > If you are really confused about this, then trying to install your app
> > in a hosting environment without first testing it on your local machine
> > with your own copy of Apache, etc, is probably going to be a long and
> > frustrating exercise, because you just won't know what to expect or be
> > able to ask the right questions of your hosting provider.
> 
> So using Django requires a facility with Apache? Not what I expected!

No it doesn't *require* Apache, although that is one popular option.
Please read the installation documentation, which contains pointers to
setup instructions for other environments.

> 
> >
> > The sort of things you would need to know include: are you using
> > mod_python (not particularly common on a cohosting site)? Does your
> > hosting provider support fastcgi so that you can access Django that way?
> > Are they a known Django-friendly hosting provider or do they say "what's
> > Django" (the latter case is much harder for people who are not
> > experienced in setting these things up, because you are going to have to
> > solve almost all problems yourself).
> 
> I was considering using a Django-friendly host (maybe Webfaction).
> Do I just ask them how I should write urls.py for my particular
> directory structure?

Maybe you should have a look at
http://blog.webfaction.com/django-screencast , which gives very concrete
details about setting up Django on webfaction.

Regards,
Malcolm


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

2007-02-18 Thread kbochert



On Feb 18, 12:29 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-02-18 at 00:20 -0800, kbochert wrote:

> No it doesn't *require* Apache, although that is one popular option.
> Please read the installation documentation, which contains pointers to
> setup instructions for other environments.
>
I looked at the installation docs and saw
"Install python"  -- ok no problem
"install Apache and mod_python"  -- oops, I'm not about to do that!
I have installed on my system with no problems. The problem is
deployment.

So perhaps "install apache and mod_python" really means "insure that
your host has apache and mod_python installed".

OK, my misunderstanding


>
> Maybe you should have a look athttp://blog.webfaction.com/django-screencast, 
> which gives very concrete
> details about setting up Django on webfaction.
>
I saw that screencast offer but don't have quicktime, and anyway, I
assumed that I would only need that when I actually moved my site to
webfaction. I now understand that the details of that installation
affect the details of urls.py, and I'll just have to accept that
urls.py just can't be (fully) tested locally.

Disappointed, but thanks for your help
Karl


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

2007-02-18 Thread ashwoods

i think you are a little confused. i'll try to clear things up.

first, the url.py does not depend on the apache configuration in the
sense you imply.
but apache does have to know when to call the django/python handler,
and that can be host based, directory based, virtualhost based (if the
apache instance is hosting more than domain)

django also doesn't require knowledge of apache or another webserver,
just as php doesn't: in theory!

because both php, django, or serving html files depend on the apache
configuration. "somebody" has to configure it. most hosting out there
already have everything configured for you to serve php and html
files, with django, unless you are working with a django friendly
hosting company, you might have to do some tweaking yourself, but it
isnt that hard. in most hosting configurations you can configure
apache to use either modpython or fastcgi, and in both you can tell
apache where to load django. it doesnt have to be a subfolder polls,
you can map any django app to the root webfolder.

if you do something like this at the end of url.py (r'^',
'grasshoppr.apps.main.views.login'), then everything that hasnt been
filtered before will be mapped. (not recommended, not 404 errors will
be generated)

if you "want" to be able to have apache handle the root domain by
itself and serve a index.html file, that can be done.
but normally you will want apache to call the python handler from the
domain root.

part of a apache config can look like this:



ServerName beta.example.com
ServerAdmin [EMAIL PROTECTED]

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE example.settings
PythonDebug On
Alias /media "/var/django/example/media/"

SetHandler None

 


so when the root is called, and any other location under root, the
python-django handler is called, and all the url mappings are handled
by django.
except a "subfolder" called media, apache serves the media directly.
if you put .html files in beta.example.com/media, they will be served
normally by apache. you don't want django serving media.

you can call your urls _ANYTHING_ you want. if you want to conserve an
old link, you _can_ map www.example.com/index.html if you wish.
but there isn't really a good reason to do so, except for "backwards"
compability with an existing site. http://www.w3.org/Provider/Style/URI
so called shorturls or pretty uri are a lot better and django is
really great at it.

even though you probably would get by without installing apache
locally, it will make your life easier if you do.  it isn't that hard.
you will probably only have to add one or two directives like i did
above to get it working. be careful with python path (thats where i
always mess up :)

cheers, ashley




On Feb 18, 9:51 am, "kbochert" <[EMAIL PROTECTED]> wrote:
> On Feb 18, 12:29 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Sun, 2007-02-18 at 00:20 -0800, kbochert wrote:
> > No it doesn't *require* Apache, although that is one popular option.
> > Please read the installation documentation, which contains pointers to
> > setup instructions for other environments.
>
> I looked at the installation docs and saw
> "Install python"  -- ok no problem
> "install Apache and mod_python"  -- oops, I'm not about to do that!
> I have installed on my system with no problems. The problem is
> deployment.
>
> So perhaps "install apache and mod_python" really means "insure that
> your host has apache and mod_python installed".
>
> OK, my misunderstanding
>
>
>
> > Maybe you should have a look 
> > athttp://blog.webfaction.com/django-screencast, which gives very concrete
> > details about setting up Django on webfaction.
>
> I saw that screencast offer but don't have quicktime, and anyway, I
> assumed that I would only need that when I actually moved my site to
> webfaction. I now understand that the details of that installation
> affect the details of urls.py, and I'll just have to accept that
> urls.py just can't be (fully) tested locally.
>
> Disappointed, but thanks for your help
> Karl


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

2007-02-18 Thread paulh

Thanks for the replies. As always, reading the docs again teaches you
a bit more than the first time; I now see that that initial was not
what I was after.

Arnaud, I think your method is more what I was after and as you say,
it does exactly what I wanted.

It seems to be much simpler than overriding the __init__ method. Is
that simplicity at some cost I wonder?

Paul Hide

On Feb 18, 12:35 am, "Arnaud Delobelle" <[EMAIL PROTECTED]>
wrote:
> On Feb 17, 7:05 pm, "paulh" <[EMAIL PROTECTED]> wrote:
>
> > I feel the following should work:
> > class Myform(forms.Form):
> > ...publ = forms.ChoiceField(label='Publisher', required=False)
>
> > and then in handler I should be able to set the choices dynamically
> > by:
>
> > def meth(request):
> > ...frm=Myform(initial={'publ':((1,2),(2,3),(3,4)))}) #even if the
> > brackets are wrong here, they were right in the original
>
> That shouldn't work as initial is meant to set the value of a field.
>
> I had the same problem and a peek at the source told me that a
> ChoiceField has a 'choices' attribute which is settable so:
>
> form = MyForm(...)
> form.fields['publ'].choices = ((1,2),(2,3),(3,4))
>
> will work, but I don't know whether it is the right thing to do (TM).
>
> --
> Arnaud


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

2007-02-18 Thread Honza Král
On 2/18/07, paulh <[EMAIL PROTECTED]> wrote:
>
> Thanks for the replies. As always, reading the docs again teaches you
> a bit more than the first time; I now see that that initial was not
> what I was after.
>
> Arnaud, I think your method is more what I was after and as you say,
> it does exactly what I wanted.
>
> It seems to be much simpler than overriding the __init__ method. Is
> that simplicity at some cost I wonder?

yes, you must either wrap the form in a function or assin the choices
every time you wish to work with the form. with overriding the
__init__, it is part of the form and you don't have to think about it
at all... depends how you want to use it...

>
> Paul Hide
>
> On Feb 18, 12:35 am, "Arnaud Delobelle" <[EMAIL PROTECTED]>
> wrote:
> > On Feb 17, 7:05 pm, "paulh" <[EMAIL PROTECTED]> wrote:
> >
> > > I feel the following should work:
> > > class Myform(forms.Form):
> > > ...publ = forms.ChoiceField(label='Publisher', required=False)
> >
> > > and then in handler I should be able to set the choices dynamically
> > > by:
> >
> > > def meth(request):
> > > ...frm=Myform(initial={'publ':((1,2),(2,3),(3,4)))}) #even if the
> > > brackets are wrong here, they were right in the original
> >
> > That shouldn't work as initial is meant to set the value of a field.
> >
> > I had the same problem and a peek at the source told me that a
> > ChoiceField has a 'choices' attribute which is settable so:
> >
> > form = MyForm(...)
> > form.fields['publ'].choices = ((1,2),(2,3),(3,4))
> >
> > will work, but I don't know whether it is the right thing to do (TM).
> >
> > --
> > Arnaud
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



ordering - how to using relation or db function

2007-02-18 Thread VIK_Tomas

Hi,

how to set modelClass.Meta.ordering = ( ... )
  for sorting same as "ORDER BY (description IS NULL)"

  or same as "ORDER BY LOWER(item)"

Thx


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

2007-02-18 Thread kbochert

I think I almost get it.

If I configure Apache as you suggest, and a user surfs to
"www.mysite.com"
what url gets 'passed' to urls.py?
Will that url match:
1:(r'^$', 'mysite.myapp.views.index'),
or
2:  (r'^myapp/$', 'mysite.myapp.views.index'),
or
3:  (r'^index$', 'mysite.myapp.views.index'),

The tutorial implies #2, but doesn't that require the Apache
configuration (or maybe .htaccess, (or whatever)) to know the app
name?


Karl


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

2007-02-18 Thread VIK_Tomas

Hi,

I have db-model like this:

class Action(models.Model):
   name = models.CharField(maxlength=64, unique=True)
   photo = models.ForeignKey('Photo', null=True, blank=True)

class Album(models.Model):
   action = models.ForeignKey(Action, null=True, blank=True)
name = models.CharField(maxlength=64)
directory = models.CharField(maxlength=64, unique=True)
   ...
   def __str__(self):
   if self.action:
   return "%s - %s" % (self.action, self.name)
   else:
   return self.name


class Photo(models.Model):
   album = models.ForeignKey(Album)
   file_name = models.CharField(maxlength=64)
   ...
def __str__(self):
return "%s/%s" % (self.album.directory, self.file_name)


When I go to admin page "Change action", then is executed  3597 SQL
queries and many of queries are same.
(database contains:  25 actions, 29 albums, 3592 photos)

How to set model to automatic select related album when selecting a
photo?

or
 how to set database result cache?
   admin interface executes for each photo (in ) query
"SELECT  * FROM album where id = ... "

or another solution to reduce number of queries

Thx.


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



{% url %} syntax in templates

2007-02-18 Thread omat * gezgin.com

I am running revision 4541 and experimenting with the new {% url
path.to.view %} syntax.

My template for displaying a set of thumbnail images is like:

{% for photo in photo_set %}



{% endfor %}

And url pattern that matches the view is
(r'^photo/(?P[-\w]+)/(?P\d+)/$',
'artist.views.artist_photo'),

Images are displaying fine but the links does not appear. (i.e. {% url
artist.views.artist_photo slug=artist.slug,id=photo.id %} does not
render anything.

Do you have any idea what is wrong with my syntax?

Also I think this syntax works only if the view is defined as a string
in the urls.py. Is this true?

Thanks,
oMat


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



see some picture

2007-02-18 Thread Urmila Mayra
Hi dear friend some pictures for you.
See all the pictures one by one
Ayesha Takia pictures.

http://ifs1.imagefly.info/v/f9/jpg/aye16v.html

http://ifs1.imagefly.info/v/55/jpg/aye17a.html

http://ifs1.imagefly.info/v/cc/jpg/aye18v.html

http://ifs1.imagefly.info/v/82/jpg/aye19a.html

http://ifs1.imagefly.info/v/17/jpg/aye21a.html

http://ifs1.imagefly.info/v/f2/jpg/aye23v.html

http://ifs1.imagefly.info/v/f4/jpg/aye24a.html

http://ifs1.imagefly.info/v/13/jpg/aye25v.html

http://ifs1.imagefly.info/v/fd/jpg/aye26a.html

http://ifs1.imagefly.info/v/d7/jpg/aye27v.html

http://ifs1.imagefly.info/v/c7/jpg/aye28a.html

http://ifs1.imagefly.info/v/38/jpg/aye29v.html

http://ifs1.imagefly.info/v/db/jpg/aye30a.html

http://ifs1.imagefly.info/v/29/jpg/aye31a.html
http://ifs1.imagefly.info/v/2c/jpg/aye32v.html

Katrina Kaif pictures.

 http://ifs3.imagefly.info/v/39/jpg/kat35a.html
http://ifs3.imagefly.info/v/e5/jpg/kat39a.html

http://ifs3.imagefly.info/v/26/jpg/kat40v.html

http://ifs3.imagefly.info/v/d4/jpg/kat41a.html

http://ifs3.imagefly.info/v/93/jpg/kat42a.html

http://ifs3.imagefly.info/v/38/jpg/kat43v.html

http://ifs3.imagefly.info/v/35/jpg/kat45v.html

http://ifs3.imagefly.info/v/a3/jpg/kat46a.html

http://ifs3.imagefly.info/v/9c/jpg/kat50v.html

http://ifs3.imagefly.info/v/08/jpg/kat51a.html

http://ifs2.imagefly.info/v/2a/jpg/kat53a.html

http://ifs3.imagefly.info/v/ea/jpg/kat54a.html

http://ifs3.imagefly.info/v/f8/jpg/kat56a.html

http://ifs3.imagefly.info/v/0a/jpg/katrina_kaif_2.html

http://ifs3.imagefly.info/v/e6/jpg/n48dq.html
http://ifs3.imagefly.info/v/49/jpg/sarkar-2005-9b.html

Shah Rukh Khan pictures.

http://ifs3.imagefly.info/v/29/jpg/sha18a.html

http://ifs3.imagefly.info/v/aa/jpg/sha17a.html

http://ifs3.imagefly.info/v/72/jpg/sha16a.html

http://ifs3.imagefly.info/v/aa/jpg/sha15a.html

http://ifs3.imagefly.info/v/de/jpg/sha14a.html

http://ifs3.imagefly.info/v/ed/jpg/sha13v.html

http://ifs3.imagefly.info/v/b2/jpg/sha12a.html

http://ifs3.imagefly.info/v/b1/jpg/sha9a.html

http://ifs2.imagefly.info/v/45/jpg/sha10a.html

http://ifs2.imagefly.info/v/f9/jpg/sha5d.html

http://ifs2.imagefly.info/v/7d/jpg/sha1v.html

http://ifs2.imagefly.info/v/57/jpg/sha3a.html

http://ifs2.imagefly.info/v/66/jpg/sha8a.html

http://ifs2.imagefly.info/v/81/jpg/sha7v.html

http://ifs2.imagefly.info/v/8c/jpg/sha5d.html

http://ifs2.imagefly.info/v/c7/jpg/sha0a.html

Future CAR pictures.

http://ifs2.imagefly.info/v/80/jpg/nona.html

http://ifs2.imagefly.info/v/7f/jpg/noname.html

http://ifs2.imagefly.info/v/c8/jpg/noname-1.html

http://ifs2.imagefly.info/v/da/jpg/noname-2.html

http://ifs2.imagefly.info/v/e7/jpg/noname-3.html

http://ifs2.imagefly.info/v/0c/jpg/noname-4.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
-~--~~~~--~~--~--~---



Custom Admin save function

2007-02-18 Thread Florian Apolloner

How can I tweak the normal save button (by hooking into the save
method) to, instead of updating the record, add it as new one and mark
the old one as deleted (to mark it as deleted I would like to change
an boolean attribute...)?

Thx Florian


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

2007-02-18 Thread Benjamin Slavin

I second the SliceHost VPS recommendation... my experience with them
has been nothing but positive.

 - Ben

On 2/17/07, Scott Paul Robertson <[EMAIL PROTECTED]> wrote:
> On Sat, Feb 17, 2007 at 04:41:46PM -, akonsu wrote:
> >
> > www.prgmr.com seem to have affordable VPS hosting. but i agree, they
> > still offer less space and bandwidth than shared hosting.
> >
>
> www.slicehost.com has been treating me very well for VPS hosting.
> $20/month for 256 MB RAM, 10 GB disk, 100 GB bandwidth. They even
> provide DNS for free.
>
> --
> Scott Paul Robertson
> http://spr.mahonri5.net
> GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601
>
>

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

2007-02-18 Thread enquest

Is it possible that I can pay somebody to help me learning
Django/python. I'm starting a project with Django and don't want to get
stuck. I simple want to ask quickly via Jabber. How do you do this/that
and get some help on it. Maybe you can have some overview of what I'm
doing and give pointers... I want to avoid getting cryptic answers or
waiting long time. 

My background is PHP.

Is some one intressted?

What would you ask €/$ for this kind of help.  Can you send invoices?

Enquest


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



Re: Custom Admin save function

2007-02-18 Thread Honza Král
you simply override the save() function to do what you described:
create another instance and mark this one as deleted...

the only problem I can think of is with the instance

for example if I do

m = Model.objects.all()[0]
m.some_field = 'new value'
m.save()

what is now in 'm' ?? the new object, the one merked for deletion? etc.
if you only need this in admin, then you shouldn't have to worry about
this, though I am not 100% sure. But if you want to use some other
code with such a model you would have to be careful about that.

On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> How can I tweak the normal save button (by hooking into the save
> method) to, instead of updating the record, add it as new one and mark
> the old one as deleted (to mark it as deleted I would like to change
> an boolean attribute...)?
>
> Thx Florian
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread Honza Král
On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have db-model like this:
>
> class Action(models.Model):
>name = models.CharField(maxlength=64, unique=True)
>photo = models.ForeignKey('Photo', null=True, blank=True)
>
> class Album(models.Model):
>action = models.ForeignKey(Action, null=True, blank=True)
> name = models.CharField(maxlength=64)
> directory = models.CharField(maxlength=64, unique=True)
>...
>def __str__(self):
>if self.action:
>return "%s - %s" % (self.action, self.name)
>else:
>return self.name
>
>
> class Photo(models.Model):
>album = models.ForeignKey(Album)
>file_name = models.CharField(maxlength=64)
>...
> def __str__(self):
> return "%s/%s" % (self.album.directory, self.file_name)
>
>
> When I go to admin page "Change action", then is executed  3597 SQL
> queries and many of queries are same.
> (database contains:  25 actions, 29 albums, 3592 photos)
>
> How to set model to automatic select related album when selecting a
> photo?

http://www.djangoproject.com/documentation/model_api/#list-select-related

>
> or
>  how to set database result cache?
>admin interface executes for each photo (in ) query
> "SELECT  * FROM album where id = ... "
>
> or another solution to reduce number of queries
>
> Thx.
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Dont Miss to see This.........

2007-02-18 Thread khaja mohaideen
You Learn From this How to in dollars within a week
www.freewebs.com./khaja_mohai <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>

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



Re: ordering - how to using relation or db function

2007-02-18 Thread Honza Král
AFAIK this is currently not possible with django's ORM, you can work
around that by using:

queryset.order_by().extra( where=[ ' 1=1 ORDER BY whatever' ] )
which means: on queryset, reset sorting and to where clause append 1=1
(so if the SQL has correct syntax) and ORDER BY whatever...

but I consider it an ugly hack

On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> how to set modelClass.Meta.ordering = ( ... )
>   for sorting same as "ORDER BY (description IS NULL)"
>
>   or same as "ORDER BY LOWER(item)"
>
> Thx
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: ManyToManyField does not allow empty relations

2007-02-18 Thread akonsu

thanks for your response.

specifying null=True for ManyToManyField will allow nulls in the
corresponding field in the association table, right? but since this
table is just a list of pairs this is not needed because having no
row  at all has the same effect. correct? if so null=True is not
really necessary. or am i wrong?

konstantin

On Feb 17, 8:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-02-18 at 01:09 +, akonsu wrote:
> > Hello,
>
> > i have set A that has many-to-many relationship with set B
>
> > currently admin interface (at least) forces me to select at least one
> > object from B if i add an object to A and the other way around. i do
> > not want that. i want to add an object to A which has no related
> > objects in B.
>
> > i need to have a model that enables empty relations. is there a way to
> > achieve this?
>
> You need to have specified null=True and blank=True on the
> ManyToManyField in your model (and you need to have done that before you
> created the database, otherwise it will not permit NULL values in that
> column). If you do that, it should work fine.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: ManyToManyField does not allow empty relations

2007-02-18 Thread Honza Král
On 2/18/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> thanks for your response.
>
> specifying null=True for ManyToManyField will allow nulls in the
> corresponding field in the association table, right? but since this
> table is just a list of pairs this is not needed because having no
> row  at all has the same effect. correct? if so null=True is not
> really necessary. or am i wrong?

that is correct, null has no effect for ManyToMany Field

>
> konstantin
>
> On Feb 17, 8:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
> > On Sun, 2007-02-18 at 01:09 +, akonsu wrote:
> > > Hello,
> >
> > > i have set A that has many-to-many relationship with set B
> >
> > > currently admin interface (at least) forces me to select at least one
> > > object from B if i add an object to A and the other way around. i do
> > > not want that. i want to add an object to A which has no related
> > > objects in B.
> >
> > > i need to have a model that enables empty relations. is there a way to
> > > achieve this?
> >
> > You need to have specified null=True and blank=True on the
> > ManyToManyField in your model (and you need to have done that before you
> > created the database, otherwise it will not permit NULL values in that
> > column). If you do that, it should work fine.
> >
> > Regards,
> > Malcolm
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread VIK_Tomas

>
> http://www.djangoproject.com/documentation/model_api/#list-select-related
>

a try add

   class Admin:
  list_select_related = True

to all models, but it has no effect - "Edit Action" is still very
slow.

with this option in all models:  3598 queries
without this option: 3598 queries

 -- problem is editing "Action" page, where is a "photo list"
and I need select list of photos AS " SELECT ... photo JOIN album
" instead of many queries
because Photo.__str__() looks uses photo.album


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

2007-02-18 Thread Honza Král
On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote:
>
> >
> > http://www.djangoproject.com/documentation/model_api/#list-select-related
> >
>
> a try add
>
>class Admin:
>   list_select_related = True
>
> to all models, but it has no effect - "Edit Action" is still very
> slow.
>
> with this option in all models:  3598 queries
> without this option: 3598 queries
>
>  -- problem is editing "Action" page, where is a "photo list"
> and I need select list of photos AS " SELECT ... photo JOIN album
> " instead of many queries
> because Photo.__str__() looks uses photo.album

that's odd can you post your Model definition?
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread Tomáš Pokorný
 models.py attached.


On Sun, 2007-02-18 at 16:51 +0100, Honza Král wrote:

> 
> that's odd can you post your Model definition?
> >
> >
> > >
> >
> 
> 
-- 
TomᚠPokorný
=
email: [EMAIL PROTECTED]
mobil: +420 776 379 631
icq# 22996508
==
1.Robotická s.r.o.
http://www.roboticka.cz

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

# -*- encoding: utf-8 -*- 

from django.db import models
from django.contrib.auth.models import User 
from django.conf import settings
from django.core import validators
import datetime

# Create your models here.

class UserProfile(models.Model):
""" User/Member information """
user = models.ForeignKey(User, unique=True)
icq = models.IntegerField(null=True, blank=True)
is_member = models.BooleanField(default=False)
description = models.TextField(null=True, blank=True)

icon_width = models.SmallIntegerField(null=True, blank=True)
icon_height = models.SmallIntegerField(null=True, blank=True)
icon_mimetype = models.CharField(maxlength=64, null=True, blank=True)

created_at = models.DateTimeField(auto_now_add=True, null=True)
changed_at = models.DateTimeField(auto_now=True, null=True)

class Meta:
ordering = ('id',)

class Admin:
fields = (
(None, {'fields': ('user', 'icq', 'is_member', 'description')}),
(_('User icon'), {'fields': ('icon_width', 'icon_height', 'icon_mimetype')}),
)
list_display = ('user', 'name', 'email', 'icq', 'icon_size', 'is_member')
list_filter = ('is_member',)
search_fields = ('user__first_name', 'user__last_name', 'user__email', 'user__username', 'description',)
list_select_related = True

def __str__(self):
return self.name()

def icon_url(self):
return settings.DATA_DIR + 'usericon/' + self.id + '/'

def has_icon(self):
return self.icon_width and self.icon_height

def icon_img_tag(self):
if self.has_icon():
return '' % (self.id, self.icon_width, self.icon_height)
return '' % settings.MEDIA_URL

def name(self):
return self.user.get_full_name()

def email(self):
return self.user.email

def icon_size(self):
if self.has_icon():
return "%dx%d" % (self.icon_width, self.icon_height)


class Action(models.Model):
name = models.CharField(maxlength=64, unique=True)
from_date = models.DateField(null=True, blank=True, validator_list=[validators.IsLessThanOtherField('to_date', _('From_date must be before to_date!'))])
to_date = models.DateField(null=True, blank=True)
description = models.TextField(null=True, blank=True)
photo = models.ForeignKey('Photo', null=True, blank=True)
rank = models.IntegerField(null=True, blank=True)
enabled = models.BooleanField(default=True)

created_at = models.DateTimeField(auto_now_add=True, null=True)
changed_at = models.DateTimeField(auto_now=True, null=True)

class Meta:
ordering = ('rank', 'from_date', 'to_date', 'id')

class Admin:
list_display = ('name', 'from_date', 'to_date', 'rank', 'enabled')
list_filter = ('enabled',)
search_fields = ('name', 'description',)
list_select_related = True

def rank_is_null(self):
return rank is None

def __str__(self):
if not self.enabled:
return "%s (disabled)" % self.name
return self.name

def group_name(self):
return {0: 'Starší', : 'Plánované'}.get(self.group_rank, "Rok %d" % self.from_date.year)

def group_rank(self):
if not self.from_date:
return 0
if self.from_date > datetime.datetime.now():
return 
return self.from_date.year



class Album(models.Model):
action = models.ForeignKey(Action, null=True, blank=True)
name = models.CharField(maxlength=64)
description = models.TextField(null=True, blank=True)
directory = models.CharField(maxlength=64, unique=True)
rank = models.IntegerField(null=True, blank=True)
enabled = models.BooleanField(default=True)

# access permissions 
public_read = models.BooleanField(default=True)

created_at = models.DateTimeField(auto_now_add=True, null=True)
changed_at = models.DateTimeField(auto_now=True, null=True)

class Meta:
unique_together = (('action', 'name'),)
#order_with_respect_to = 'action'
ordering = ('rank', 'name')

class Admin:
list_display = ('action', 'name', 'directory', 'rank', 'public_read', 'enabled')
list_d

Re: Custom Admin save function

2007-02-18 Thread Florian Apolloner

> you simply override the save() function to do what you described:
> create another instance and mark this one as deleted...
That's what I want to do

> what is now in 'm' ?? the new object, the one merked for deletion? etc.
> if you only need this in admin, then you shouldn't have to worry about
> this, though I am not 100% sure. But if you want to use some other
> code with such a model you would have to be careful about that.
This is my problem too. So, what to do now exactly? A little example
would be nice, and please mark which is the old instance and which is
the new instance...

Thx


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



Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> > you simply override the save() function to do what you described:
> > create another instance and mark this one as deleted...
> That's what I want to do
>
> > what is now in 'm' ?? the new object, the one merked for deletion? etc.
> > if you only need this in admin, then you shouldn't have to worry about
> > this, though I am not 100% sure. But if you want to use some other
> > code with such a model you would have to be careful about that.
> This is my problem too. So, what to do now exactly? A little example
> would be nice, and please mark which is the old instance and which is
> the new instance...

something like:

def save( self ):
old_data = self.__class__.objects.get(pk=self.id).__dict__
old_data['deleted'] = True
self.__class__.objects.create( **old_data )
super( models.Model, self ).save()

then when you do

m = Model.objects.get(pk=42)
m.some_field='some new value'
m.save()

another object will appear in your DB, m will be the updated object

you should add some transaction support, check if anything has changed
etc, but it should work...

>
> Thx
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread Honza Král
On 2/18/07, Tom� Pokorn� <[EMAIL PROTECTED]> wrote:
>  models.py attached.
>
>
> On Sun, 2007-02-18 at 16:51 +0100, Honza Kr�l wrote:
>
> >
> > that's odd can you post your Model definition?

definitely odd, list_select_related appears to have no effect on the
sql queries.
even if I add photo to list_display, it still doesn't do a
select_related() query, which it should...

I don't have to delve deeper at the moment, but something is
definitely wrong here...
I will try and have a look later... but I still hope I missed
something obvious...

> >
> >
> --
> Tom� Pokorn�
> =
> email: [EMAIL PROTECTED]
> mobil: +420 776 379 631
> icq# 22996508
> ==
> 1.Robotick� s.r.o.
> http://www.roboticka.cz
>
> >
>
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Re: Custom Admin save function

2007-02-18 Thread Florian Apolloner

> def save( self ):
> old_data = self.__class__.objects.get(pk=self.id).__dict__
> old_data['deleted'] = True
> self.__class__.objects.create( **old_data )
> super( models.Model, self ).save()
>
> then when you do
>
> m = Model.objects.get(pk=42)
> m.some_field='some new value'
> m.save()
Now I understand, I'll try it out and ask if something isn't clear
Thx :)

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

2007-02-18 Thread akonsu

hello,

class A(models.Model):

bs = models.ManyToManyField('B')

class B(models.Model):


how to implement this query:

select *
from myapp_a
inner join (select a_id, count(*)
   from myapp_a_bs
   group by a_id) as a
on myapp_a.id=a.a_id;

thanks for any help!
konstantin


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

2007-02-18 Thread paulh

As far as I can see the __init__ way of doing things creates a field
as opposed to a base_field. Given that this is done in the __init__
method every instance will have this field. Is there any disadvantage
in this? I suppose you could also have a base_field with the same name/
key. Looking at the django code there doesn't seem to be any real
difference between a base_field and a field that is created in the
__init__ method; or maybe I've missed something.

Paul Hide

On Feb 18, 6:21 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 2/18/07, paulh <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks for the replies. As always, reading the docs again teaches you
> > a bit more than the first time; I now see that that initial was not
> > what I was after.
>
> > Arnaud, I think your method is more what I was after and as you say,
> > it does exactly what I wanted.
>
> > It seems to be much simpler than overriding the __init__ method. Is
> > that simplicity at some cost I wonder?
>
> yes, you must either wrap the form in a function or assin the choices
> every time you wish to work with the form. with overriding the
> __init__, it is part of the form and you don't have to think about it
> at all... depends how you want to use it...
>
>
>
>
>
> > Paul Hide
>
> > On Feb 18, 12:35 am, "Arnaud Delobelle" <[EMAIL PROTECTED]>
> > wrote:
> > > On Feb 17, 7:05 pm, "paulh" <[EMAIL PROTECTED]> wrote:
>
> > > > I feel the following should work:
> > > > class Myform(forms.Form):
> > > > ...publ = forms.ChoiceField(label='Publisher', required=False)
>
> > > > and then in handler I should be able to set the choices dynamically
> > > > by:
>
> > > > def meth(request):
> > > > ...frm=Myform(initial={'publ':((1,2),(2,3),(3,4)))}) #even if the
> > > > brackets are wrong here, they were right in the original
>
> > > That shouldn't work as initial is meant to set the value of a field.
>
> > > I had the same problem and a peek at the source told me that a
> > > ChoiceField has a 'choices' attribute which is settable so:
>
> > > form = MyForm(...)
> > > form.fields['publ'].choices = ((1,2),(2,3),(3,4))
>
> > > will work, but I don't know whether it is the right thing to do (TM).
>
> > > --
> > > Arnaud
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: {% url %} syntax in templates

2007-02-18 Thread Ivan Sagalaev

omat * gezgin.com wrote:
> And url pattern that matches the view is
> (r'^photo/(?P[-\w]+)/(?P\d+)/$',
> 'artist.views.artist_photo'),
> 
> Images are displaying fine but the links does not appear. (i.e. {% url
> artist.views.artist_photo slug=artist.slug,id=photo.id %} does not
> render anything.
> 
> Do you have any idea what is wrong with my syntax?

The syntax is correct, I just got it working on my machine. Things to check:

- Does your template's context actually contain an object 'artist' with 
a non-empty slug? Non-empty because your url pattern expects it this way.

- Is photo.is is a number?

- What is the first parameter in your patterns() that contains this 
pattern? It it's not empty then the actual view name will be 
concatenated after that prefix.

- Is this urlconf file included in the root urlconf? E.g. does your 
project find a URL like /photo/something/1/ ?

> Also I think this syntax works only if the view is defined as a string
> in the urls.py. Is this true?

No, it works with callable views just fine.

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



beautiful pohos of Amrita Rao

2007-02-18 Thread Urmila Mayra
Hi Dear Friend.
See all the pictures
Amrita Rao picture

http://ifs3.imagefly.info/v/f6/jpg/amr34a.html

http://ifs3.imagefly.info/v/92/jpg/amr17v.html

http://ifs3.imagefly.info/v/fa/jpg/amr18a.html

http://ifs3.imagefly.info/v/3f/jpg/amr19a.html

http://ifs3.imagefly.info/v/bc/jpg/amr20v.html

http://ifs3.imagefly.info/v/3b/jpg/amr21a.html

http://ifs3.imagefly.info/v/b2/jpg/amr22v.html

http://ifs3.imagefly.info/v/ca/jpg/amr23a.html

http://ifs3.imagefly.info/v/dd/jpg/amr24a.html

http://ifs1.imagefly.info/v/45/jpg/amr25v.html

http://ifs1.imagefly.info/v/21/jpg/amr26a.html

http://ifs1.imagefly.info/v/25/jpg/amr27v.html

http://ifs1.imagefly.info/v/f2/jpg/amr28a.html

http://ifs1.imagefly.info/v/c2/jpg/amr29v.html

http://ifs1.imagefly.info/v/76/jpg/amr30a.html

http://ifs1.imagefly.info/v/bf/jpg/amr31a.html

http://ifs1.imagefly.info/v/f0/jpg/amr33a.html

http://ifs3.imagefly.info/v/3e/jpg/amr35a.html

http://ifs3.imagefly.info/v/b6/jpg/amr36a.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
-~--~~~~--~~--~--~---



Re: rendering dynamic fields in newforms

2007-02-18 Thread [EMAIL PROTECTED]

Jeff,
Looks like you are rendering out the form class itself rather than an
instance of the form.
You could try this approach.

from django import newforms as forms
from django.template import Context, Template
from django.http import HttpResponse

class MedForm(forms.Form):
def __init__(self, *args, **kwargs):
super(MedForm, self).__init__(*args, **kwargs)
self.med_list = []
for i in range(1, 6):  # arbitrary number
k = 'med_%d' % i
self.fields[k] = forms.CharField(required=False, label=k)
self.med_list.append(self.fields[k])

def test(request):
Form = MedForm()
return HttpResponse(Form.as_p())


(example .py file at 
http://www.pukkapeople.com/django/how-to-s/django_newforms.py/
)

On Feb 17, 4:22 am, "Rubic" <[EMAIL PROTECTED]> wrote:
> Hi, I'm the 985th person to attempt dynamic fields
> in newforms.  ;-)
>
> Actually I've been able to do lots of dynamic stuff
> in newforms.  It's rendering the forms in templates
> that sometimes confuses me.  For example, given
> the following code to build a form based on an
> arbitrary number of medications:
> --
> from django import newforms as forms
> from django.template import Context, Template
>
> class MedForm(forms.Form):
> def __init__(self, *args, **kwargs):
> super(MedForm, self).__init__(*args, **kwargs)
> self.med_list = []
> for i in range(1, 4):  # arbitrary number
> k = 'med_%d' % i
> self.fields[k] = forms.CharField(required=False, label=k)
> self.med_list.append(self.fields[k])
>
> t = Template("""{% for med in form.med_list %}
>   {{ med.label }}: {{ med }}
> {% endfor %}""")
>
> print t.render(Context({'form':MedForm({})}))
> --
> Produces the following output:
>
>   med_1: 
>   med_2: 
>   med_3: 
>
> Obviously, what I want is something more like this:
>
>   med_1: 
>   med_2: 
>   med_3: 
>
> So how do I get there?  I could do something like
> this in line 11:
>
>   bf = BoundField(self, self.fields[k], k)
>   self.med_list.append(bf.as_widget(self.fields[k].widget))
>
> But I'd lose all the field information.  Basically, I'm
> looking for the magic BoundField.as_widget() rendering
> formula.  I've put the above code here for easier viewing:
>
>  http://dpaste.com/hold/5764/
>
> --
> Jeff Bauer
> Rubicon, Inc.


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

2007-02-18 Thread Gary Wilson

On Feb 18, 10:48 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 2/18/07, Tom? Pokorn? <[EMAIL PROTECTED]> wrote:
>
> >  models.py attached.
>
> > On Sun, 2007-02-18 at 16:51 +0100, Honza Kr?l wrote:
>
> > > that's odd can you post your Model definition?
>
> definitely odd, list_select_related appears to have no effect on the
> sql queries.
> even if I add photo to list_display, it still doesn't do a
> select_related() query, which it should...
>
> I don't have to delve deeper at the moment, but something is
> definitely wrong here...
> I will try and have a look later... but I still hope I missed
> something obvious...

I think I might have encountered this bug before too, and I think the
problem arises when you use a related object in the __str__ method.


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



Re: Custom Admin save function

2007-02-18 Thread Florian Apolloner

I got a few questions cause it is not working (I assume I am to
silly):
> def save( self ):
> old_data = self.__class__.objects.get(pk=self.id).__dict__
I can substitue pk with id (this is my primary...)
> old_data['deleted'] = True
Mark the old_data as deleted
> self.__class__.objects.create( **old_data )
Now create a new record with the old_data
> super( models.Model, self ).save()
Saves what?
>
> then when you do
>
> m = Model.objects.get(pk=42)
42 should be self.id?
> m.some_field='somenewvalue'
The things I want to change is the submitted input of the user
> m.save()

What I get is the new data through the admin form. Somehow it is not
working for me, I even don't get errors the server just hangs up...


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

2007-02-18 Thread Honza Král
On 2/18/07, Gary Wilson <[EMAIL PROTECTED]> wrote:
>
> On Feb 18, 10:48 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote:
> > On 2/18/07, Tom? Pokorn? <[EMAIL PROTECTED]> wrote:
> >
> > >  models.py attached.
> >
> > > On Sun, 2007-02-18 at 16:51 +0100, Honza Kr?l wrote:
> >
> > > > that's odd can you post your Model definition?
> >
> > definitely odd, list_select_related appears to have no effect on the
> > sql queries.
> > even if I add photo to list_display, it still doesn't do a
> > select_related() query, which it should...
> >
> > I don't have to delve deeper at the moment, but something is
> > definitely wrong here...
> > I will try and have a look later... but I still hope I missed
> > something obvious...
>
> I think I might have encountered this bug before too, and I think the
> problem arises when you use a related object in the __str__ method.

must be more than that... tried replacing all __str__ with return
'constant' and still doesn't work... :-/

>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> I got a few questions cause it is not working (I assume I am to
> silly):
> > def save( self ):
> > old_data = self.__class__.objects.get(pk=self.id).__dict__
> I can substitue pk with id (this is my primary...)

sure, that's exactly the same

> > old_data['deleted'] = True
> Mark the old_data as deleted
> > self.__class__.objects.create( **old_data )
> Now create a new record with the old_data

and save it (create also saves the record in db)

> > super( models.Model, self ).save()
> Saves what?

current instance with updated fields...

> >
> > then when you do
> >
> > m = Model.objects.get(pk=42)
> 42 should be self.id?

no, this is just a sample code to show how you would use the feature,
self is not defined here, its not inside the model's definition...

> > m.some_field='somenewvalue'
> The things I want to change is the submitted input of the user
> > m.save()
>
> What I get is the new data through the admin form. Somehow it is not
> working for me, I even don't get errors the server just hangs up...

it doesn't matter where you get the data from, the snipped I posted
only shows example usage, the simplest possible and one easily
testable from interactive shell...

I just wrote it into the email as an example of how I would go about
doing something like this, I said you will have to tweak it a bit, try
it in shell first and see how its behaving...

>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread Honza Král
Hi,
I believe you could use

queryset.extra( select={ 'B_count' : 'SELECT COUNT(*) FROM myapp_a_bs
WHERE a_id = myapp_a.id' } )

it will result in a slightly different, but equivalent, query:
SELECT
  myapp_a.id,
  myapp_a,
  ...,
  ( SELECT COUNT(*) FROM myapp_a_bs WHERE a_id = myapp_a.id ) AS "B_count"
FROM
  ...


or you could call

.b_set.count() on every a object you would get (one query for every
instance !! )

there is no clean (without SQL) way to do aggregations in django ORM.

On 2/18/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> class A(models.Model):
> 
> bs = models.ManyToManyField('B')
>
> class B(models.Model):
> 
>
> how to implement this query:
>
> select *
> from myapp_a
> inner join (select a_id, count(*)
>from myapp_a_bs
>group by a_id) as a
> on myapp_a.id=a.a_id;
>
> thanks for any help!
> konstantin
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



global name '_get_deleted_objects' is not defined

2007-02-18 Thread Robin Percy
Has anyone else run into the following error when deleting objects using the
newforms-admin branch?

Exception Value: global name '_get_deleted_objects' is not defined
Exception Location:
/usr/lib/python2.4/site-packages/django/contrib/admin/options.py in
delete_view, line 466

Obviously _get_deleted_objects hasn't been imported, just want to confirm
this is a bug.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: global name '_get_deleted_objects' is not defined

2007-02-18 Thread Honza Král
On 2/18/07, Robin Percy <[EMAIL PROTECTED]> wrote:
> Has anyone else run into the following error when deleting objects using the
> newforms-admin branch?
>
> Exception Value: global name '_get_deleted_objects' is not defined
> Exception Location:
> /usr/lib/python2.4/site-packages/django/contrib/admin/options.py
> in delete_view, line 466
>
> Obviously _get_deleted_objects hasn't been imported, just want to confirm
> this is a bug.

definitely,  _get_deleted_objects  is defined in
django.contrib.admin.views.main and that is not imported to the module
you are referring to.


>
>  >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



Re: Custom Admin save function

2007-02-18 Thread Florian Apolloner

2007/2/18, Honza Král <[EMAIL PROTECTED]>:
> I just wrote it into the email as an example of how I would go about
> doing something like this, I said you will have to tweak it a bit, try
> it in shell first and see how its behaving...

I got something like this now:
def save(self):
try:
# get the old data and save the newer one over the old
db-entry (this will keep the id static...[for bookmarks etc, cause
using the id as identifer in the url instead of slug]).
old_data = Rezept.objects.get(id=self.id).__dict__
super(Rezept, self ).save()
# Now I create a new entry
old_record = Rezept.objects.create( **old_data )
old_record.is_active = False # change it to deleted
del old_record['id'] # remove the id
# and now I want t save it as new one (old_record). I need
to do this without calling this save method, this would result in an
rekursion...
super() #and what?
except:
super(Rezept , self ).save()

try and except is to check whether the record exists... I know it is
not the same as you posted but I am trying and I am stuck (Maybe I
need to sleep over it for a while)

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



Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> 2007/2/18, Honza Kr�l <[EMAIL PROTECTED]>:
> > I just wrote it into the email as an example of how I would go about
> > doing something like this, I said you will have to tweak it a bit, try
> > it in shell first and see how its behaving...
>
> I got something like this now:
> def save(self):
> try:
> # get the old data and save the newer one over the old
> db-entry (this will keep the id static...[for bookmarks etc, cause
> using the id as identifer in the url instead of slug]).
> old_data = Rezept.objects.get(id=self.id).__dict__
> super(Rezept, self ).save()
> # Now I create a new entry
> old_record = Rezept.objects.create( **old_data )
> old_record.is_active = False # change it to deleted
> del old_record['id'] # remove the id
> # and now I want t save it as new one (old_record). I need
> to do this without calling this save method, this would result in an
> rekursion...
> super() #and what?
   super( models.Model, old_record ).save() should work here


> except:
> super(Rezept , self ).save()
>
> try and except is to check whether the record exists... I know it is
> not the same as you posted but I am trying and I am stuck (Maybe I
> need to sleep over it for a while)
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread akonsu

thanks.

this is good enough, although in general having to fall back to sql is
not portable between different database engines.

i think that at least having methods that return the names of the
underlying database tables and/or fields would be helpful. so that i
could use them in stead of 'myapp_a_bs' or 'a_id'. just in case the
naming scheme changes later. i realise of course that i could go the
other way and make the models use my own names when creating the
tables/fields in the first place.

i appreciate your help
konstantin

On Feb 18, 3:31 pm, "Honza Král" <[EMAIL PROTECTED]> wrote:
> Hi,
> I believe you could use
>
> queryset.extra( select={ 'B_count' : 'SELECT COUNT(*) FROM myapp_a_bs
> WHERE a_id = myapp_a.id' } )
>
> it will result in a slightly different, but equivalent, query:
> SELECT
>   myapp_a.id,
>   myapp_a,
>   ...,
>   ( SELECT COUNT(*) FROM myapp_a_bs WHERE a_id = myapp_a.id ) AS "B_count"
> FROM
>   ...
>
> or you could call
>
> .b_set.count() on every a object you would get (one query for every
> instance !! )
>
> there is no clean (without SQL) way to do aggregations in django ORM.
>
> On 2/18/07, akonsu <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > hello,
>
> > class A(models.Model):
> > 
> > bs = models.ManyToManyField('B')
>
> > class B(models.Model):
> > 
>
> > how to implement this query:
>
> > select *
> > from myapp_a
> > inner join (select a_id, count(*)
> >from myapp_a_bs
> >group by a_id) as a
> > on myapp_a.id=a.a_id;
>
> > thanks for any help!
> > konstantin
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585- Hide quoted text -
>
> - Show quoted text -


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



Re: django admin - too many sql-queries

2007-02-18 Thread James Bennett

On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote:
> class Action(models.Model):
>name = models.CharField(maxlength=64, unique=True)
>photo = models.ForeignKey('Photo', null=True, blank=True)

Set 'raw_id_admin=True' on the 'photo' field -- otherwise Django will
query the full list of Photos to build a drop-down menu. The
'raw_id_admin' option will tell it to use a text input which takes the
(integer) id of a Photo, and it will add a JavaScript shortcut for
selecting it.

-- 
"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 - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote:
> > class Action(models.Model):
> >name = models.CharField(maxlength=64, unique=True)
> >photo = models.ForeignKey('Photo', null=True, blank=True)
>
> Set 'raw_id_admin=True' on the 'photo' field -- otherwise Django will
> query the full list of Photos to build a drop-down menu. The
> 'raw_id_admin' option will tell it to use a text input which takes the
> (integer) id of a Photo, and it will add a JavaScript shortcut for
> selecting it.

yes, but we are talking about listing the models ( change_list at
/admin/app/model/ ), we haven't got to the form yet, so this shouldn't
affect anything (and it doesn't)

even this was an issue - the population of the drop-down would be 1
SQL select, a big one - true, but just one...

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


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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

2007-02-18 Thread Grupo Django

I can't afford it right now. I would be good anyway.
In bluehost, they offer me modpython, but i have some questions about
that.
First of all, modpython is running through cgi. As Nathan said, this
would be a a loss of permormance, but what about security? I have read
that with fastcgi, only one instance of python is running, but
everybody could access to my objects, even to my config files where
the database password are stored. I supposse that with cgi, nobody can
do this, because I would have one instance of python for each request.
I prefer security.
I'm a bit lost with all this stuff. What is the best for running a
python script? VPS and modpython, VPS and fcgi or  VPS and cgi?
and in a shared hosting, what is the best thinking about security?
I will use a shared hosting. Is it secure enough with modpython
through cgi?

Thank you very much, I'm very confused.


On 18 feb, 15:07, "Benjamin Slavin" <[EMAIL PROTECTED]> wrote:
> I second the SliceHost VPS recommendation... my experience with them
> has been nothing but positive.
>
>  - Ben
>
> On 2/17/07, Scott Paul Robertson <[EMAIL PROTECTED]> wrote:
>
> > On Sat, Feb 17, 2007 at 04:41:46PM -, akonsu wrote:
>
> > >www.prgmr.comseem to have affordable VPS hosting. but i agree, they
> > > still offer less space and bandwidth than shared hosting.
>
> >www.slicehost.comhas been treating me very well for VPS hosting.
> > $20/month for 256 MB RAM, 10 GB disk, 100 GB bandwidth. They even
> > provide DNS for free.
>
> > --
> > Scott Paul Robertson
> >http://spr.mahonri5.net
> > GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601


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

2007-02-18 Thread Robert Coup

[EMAIL PROTECTED] wrote:
> Yes, most of the hostings have fastCGI, but not flup.
> I know the best is to have VPS hosting, but they are very expensive,
> and I think I can manage with a shared hosting.
> I think Blouehost looks good.
>   
For VPS i can't recommend http://www.rimuhosting.com/ enough. They have 
great service, reasonable prices, and will gladly help out their 
customers with system-admin queries (like setting up RoR or Django).

Rob :)


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

2007-02-18 Thread Malcolm Tredinnick

On Sun, 2007-02-18 at 21:36 +, akonsu wrote:
> thanks.
> 
> this is good enough, although in general having to fall back to sql is
> not portable between different database engines.

It usually is possible, providing you get the table and column names
correct (as you indicate below). The main problem I have come across
when writing portable SQL with Django was boolean types (SQLite wants
'1' and '0', postgreSQL wants 't' and 'f') and I solve this by passing
in the Python type True or False as a parameter to the query, rather
than hard-coding it.

> 
> i think that at least having methods that return the names of the
> underlying database tables and/or fields would be helpful. so that i
> could use them in stead of 'myapp_a_bs' or 'a_id'. just in case the
> naming scheme changes later. i realise of course that i could go the
> other way and make the models use my own names when creating the
> tables/fields in the first place.

You can extract this information from the _meta attribute on a model.
This isn't documented (yet), but it's on the TODO list for things to
document before 1.0.

For an example of how to extract the information you are after, have a
look at [1] (in the "Writing the code" section). If you want to see a
bit more what is going on, you can either run "manage.py shell" and
import one of your models, then start poking around the _meta attribute
in the model (have a look at dir(MyModel._meta), etc), or you can look
at the code that is implementing this: django/db/models/options.py.

Regards,
Malcolm



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

2007-02-18 Thread Malcolm Tredinnick

Somebody else has posted an alternative phrasing of the solution, but
let's just clear up a couple of items for the archives...

On Sun, 2007-02-18 at 00:51 -0800, kbochert wrote:
[...]
> So perhaps "install apache and mod_python" really means "insure that
> your host has apache and mod_python installed".

No it doesn't. The last paragraph in that section explains that you
don't have to use Apache and where to get information about other web
server setups.

> >
> > Maybe you should have a look 
> > athttp://blog.webfaction.com/django-screencast, which gives very concrete
> > details about setting up Django on webfaction.
> >
> I saw that screencast offer but don't have quicktime, and anyway, I
> assumed that I would only need that when I actually moved my site to
> webfaction. I now understand that the details of that installation
> affect the details of urls.py, and I'll just have to accept that
> urls.py just can't be (fully) tested locally.

That's not correct. You can set up whatever webserver you like locally
and test against that. Or you can use Django's built in development
server. The only difference between testing with the development server
and testing on the remote system is if your remote installation is not
going to live directly under the root of the URL tree.

For example, when I'm developing my blog software, I test it with the
development server and it all gets served out of http://localhost/... .
When I install it on the remote system, the blog lives under
http://my.host.name/blog/... (note the extra /blog/ component). However,
that really doesn't make any difference to the code providing I'm
careful not to hard-code absolute paths. That last bit can take a bit of
practice and experimenting, but it's well worth the effort.

Alternatively, I could set up Apache (or nginx or lighthttpd or my
favourite web server of choice) to serve my application from a /blog/
prefix so it would look *exactly* like on the target system. I have used
this plan when setting up internal testing and demos for clients, so
that everything looks exactly the same as in production except for the
hostname.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: {% url %} syntax in templates

2007-02-18 Thread omat * gezgin.com

Thank you Ivan, the check list helped a lot. Now it is working.

The problem was, I was including a not-yet-existing urls.py in the
root urls.py. This doesn't cause any problem as long as its pattern is
not matched. But if you try to do the reverse match with the {% url
%}, it fails if there is a non-existing inclusion before the pattern
you want to match.

Another thing is that, if there are multiple patterns matching the
same view function, it seems like, only the first match is considered.
Lets say the artist_photo function has an optional "id" parameter
which defaults to None and below is the patterns pointing that
function.

(r'^photo/(?P[-\w]+)/$', views.artist_photo),
(r'^photo/(?P[-\w]+)/(?P\d+)/$', views.artist_photo),

In that case,

{% url views.artist_photo slug=something,id=someint %}

fails to match anything, where we can expect it to match the second
pattern.


Thanks again,
oMat


On Feb 18, 7:42 pm, Ivan Sagalaev <[EMAIL PROTECTED]> wrote:
> omat * gezgin.com wrote:
> > And url pattern that matches the view is
> > (r'^photo/(?P[-\w]+)/(?P\d+)/$',
> > 'artist.views.artist_photo'),
>
> > Images are displaying fine but the links does not appear. (i.e. {% url
> > artist.views.artist_photo slug=artist.slug,id=photo.id %} does not
> > render anything.
>
> > Do you have any idea what is wrong with my syntax?
>
> The syntax is correct, I just got it working on my machine. Things to check:
>
> - Does your template's context actually contain an object 'artist' with
> a non-empty slug? Non-empty because your url pattern expects it this way.
>
> - Is photo.is is a number?
>
> - What is the first parameter in your patterns() that contains this
> pattern? It it's not empty then the actual view name will be
> concatenated after that prefix.
>
> - Is this urlconf file included in the root urlconf? E.g. does your
> project find a URL like /photo/something/1/ ?
>
> > Also I think this syntax works only if the view is defined as a string
> > in the urls.py. Is this true?
>
> No, it works with callable views just fine.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: {% url %} syntax in templates

2007-02-18 Thread Malcolm Tredinnick

On Sun, 2007-02-18 at 23:26 +, omat * gezgin.com wrote:
[...]
> Another thing is that, if there are multiple patterns matching the
> same view function, it seems like, only the first match is considered.
> Lets say the artist_photo function has an optional "id" parameter
> which defaults to None and below is the patterns pointing that
> function.
> 
> (r'^photo/(?P[-\w]+)/$', views.artist_photo),
> (r'^photo/(?P[-\w]+)/(?P\d+)/$', views.artist_photo),
> 
> In that case,
> 
> {% url views.artist_photo slug=something,id=someint %}
> 
> fails to match anything, where we can expect it to match the second
> pattern.

While this particular example can obviously be fixed to work around that
problem, this looks like a real bug. Would you mind to file a ticket,
please, so that we don't lose this information?

I'm wondering whether it's just a problem with the url tag or (possibly
more likely) a problem with the reverse url resolving, so it will affect
the permalink() decorator as well.

If you could file a ticket, we'll have a look at this

Regards,
Malcolm



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

2007-02-18 Thread akonsu

> First of all, modpython is running through cgi. As Nathan said, this
> would be a a loss of permormance, but what about security? I have read

1. to me, the phrase "modpython is running through cgi" makes no
sense. do you mean to say "python is running through cgi"?

2. what kind of security do you have in mind specifically?

konstantin


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: rendering dynamic fields in newforms

2007-02-18 Thread Rubic

On Feb 18, 12:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Looks like you are rendering out the form class itself rather than an
> instance of the form.

Monster,

Thanks, but Honza had the correct reply.  I need to access the
individual fields in the template, and BoundField is the way to
do this.  I had already started down this path, but it just seemed
a bit convoluted and I wanted to make sure I wasn't overlooking
something obvious.  Your example works fine, BTW.  It's what
makes newforms so handy, even if the dynamic stuff is somewhat
under-documented.

I replied to Honza earlier (thanks!), but my post evaporated
somewhere in Google Groups, and I didn't want to dupe it to
the list.  For reference, here's one slightly hackish way of
dynamically assigning/rendering fields:

  http://dpaste.com/hold/5773/

Suggestions for improving this hack are welcome, but
please keep them in the context of this use case.  Thanks!

--
Jeff Bauer
Rubicon, Inc.


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

2007-02-18 Thread akonsu

>
> You can extract this information from the _meta attribute on a model.
> This isn't documented (yet), but it's on the TODO list for things to
> document before 1.0.
>
thanks, i will check out this _meta attribute.

it seems to me that ManyToManyField is not a field, it is a table. so
if we did not have this field we could still implement this kind of
relationship by introducing a model with two foreign keys (using my
original example):

class Assoc(models.Model):
a = models.ForeignKey('A')
b = models.ForeignKey('B')

but this would result in A and B types not having the helper accessor
methods returning the corresponding sets from the relation. but this
can be solved by introducing a new method that takes a pair of models
(let us call it Pair):

class Assoc(models.Model):
ab = models.Pair(A, B)

this could do just the same as ManyToManyField and create the accessor
methods that return association sets on A and B.

having a separate model for the associations table will allow us to
count associatons easily. whereas right now, unless i have missed
something, we can only count associations that belong to a particular
object. unless we use explicit sql code as shown above.

also, i think QuerySets need a (lazy) join method that would return a
new QuerySet. to be efficient the ORM needs to be as close as possible
to the database query language. i think.

konstantin


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



download computer books for free

2007-02-18 Thread [EMAIL PROTECTED]

Free Computer Education Ebooks,Tutorials and much more
  ASP, Business, C++, Careers, CISCO, e-books, Engineering, English,
Filmmaking, Finance, Health,
  Leadership, Management, Marketing, Mathematics, Mobile, Oracle,
Perl , Photography, PHP,
  Programming, VOIPand much more
visit
http://ebooks2download.blogspot.com
today


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



Admin without Auth

2007-02-18 Thread kbochert

Is there a was to install the contrib.admin app without the
contrib.auth app??

While learning, I am eraseing the database and doing manage.py syncdb
a lot, and it would be real nice to have it come up without having to
enter username email etc. each time.

Karl


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