Re: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Kenneth Gonsalves


On 13-Jul-06, at 12:13 PM, Carlos Yoder wrote:

> Don't think so. I don't have root access to my box in Bluehost. Can
> anythone think of an alternative, short of telling support to install
> it themselves?

tell them - PIL is such an integral part of all python programs that  
python hosting is of now use without it. They should be ashamed of  
themselves ;-)

-- 

regards
kg
http://lawgon.livejournal.com
http://avsap.org.in



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Sean Perry

Carlos Yoder wrote:
>>> Is there a way around PIL? Can Django use another kind of library? If
>>> not, has anyone got around this? Maybe by getting a precompiled Linux
>>> PIL?
> 
>> http://packages.debian.org/unstable/python/python-imaging
>> ?
> 
> Don't think so. I don't have root access to my box in Bluehost. Can
> anythone think of an alternative, short of telling support to install
> it themselves?
> 

Technically all PIL is needed for is determining height, width and what 
not of the image. If you do not need it or can ask the user, then PIL is 
nice but not required. May take a little hacking, but it should be 
feasible to ignore the warning.

Another option is to see if imagemagick / graphicsmagick is installed 
and write a wrapper which uses that instead of PIL. Also feasible and 
should be relatively easy.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Carlos Yoder

>> Don't think so. I don't have root access to my box in Bluehost. Can
>> anythone think of an alternative, short of telling support to install
>> it themselves?
> Technically all PIL is needed for is determining height, width and what
> not of the image. If you do not need it or can ask the user, then PIL is
> nice but not required. May take a little hacking, but it should be
> feasible to ignore the warning.
>
> Another option is to see if imagemagick / graphicsmagick is installed
> and write a wrapper which uses that instead of PIL. Also feasible and
> should be relatively easy.

Maybe so, but unfortunately I'm just too much of a Python newbie to
try tackling that, while the clock is ticking for the Django app I
must get thru the door.

It's getting frustrating, all of this obstacles (which I believe are
not Django's fault, but related to sysadmins' ignorance). We *really*
need to think of a "providing Django support" tutorial for sysadmins,
as we discussed briefly in the last few days... otherwise a lot of
people would be scared away from Django because it's "too hard" or
"unsupported".

Anyway, I'll keep you posted, thanks a lot to you all!
-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: Django and MySQLdb on Bluehost

2006-07-13 Thread Carlos Yoder

Hey Steve, seems like I'm not the only one struggling with Django+Bluehost.

If you manage to get ImageFields running on your models, let me
know... I can't make PIL work.

Regards,

Carlos

On 7/13/06, Steve <[EMAIL PROTECTED]> wrote:
>
> Nevermind, I figured it out.  Gosh I get smarter just by writing to
> this group :)
>
> All I had to do was add the local path of MySQLdb to my .fcgi file
> under my web root directory.  So:
> sys.path += ['/homedir/pythondir']
>
>
> >
>


-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: conflict between edit_inline and ManyToManyField

2006-07-13 Thread Arnaud Delobelle

arnodel wrote:
> Hi everyone,
>
> I am trying to get to grips with django and so far I find it wonderful!
>  But I am stuck on the following problem, which I have tried to make a
> test case of below (see models.py).  The problem is that when I try to
> add a new parent with some children, then I get an error relating to
> the 'toys' field, namely:
>
> Child' object has no attribute 'set_toys'
>
> But if I remove the edit_inline argument from the 'mum' field in the
> 'Child' object it works fine. It also works fine if I remove the 'toys'
> field from the 'Child' object but keep the edit_inline in the 'mum'
> field.
>
> Can I remedy this by changing something (maybe define my own set_toys
> methode, but how?) ?

After having had a go at tracing what's going wrong, I have kludged
together this solution to my problem by adding the following method to
the 'Child' class:

class Child(models.Model):
[...]
def set_toys(self, new_ids):
self.toys = [Toy.objects.get(id=new_id) for new_id in new_ids]
return True

Now everything seems to work fine.  Note that the method returns True
because where it is needed in the django source it seems to expect a
boolean that says whether there was actually a change (I return True
because it's the simplest).

Is this a bug in django? If so please tell me where to report it.
Otherwise I'd be glad to learn how to do things the correct way.

> Is there a reason why I shouldn't consider doing things this way?
> In short, please enlighten me.
>
> PS: My version of django advertises itself as "Django version 0.95
> (post-magic-removal)"
>
> -- models.py ---
> from django.db import models
>
>
> class Toy(models.Model):
> name = models.CharField(maxlength=20)
>
> def __str__(self):
> return self.name
>
> class Admin:
> pass
>
>
> class Parent(models.Model):
> name = models.CharField(maxlength=20)
>
> def __str__(self):
> return self.name
>
> class Admin:
> pass
>
>
> class Child(models.Model):
> name = models.CharField(maxlength=20, core=True)
> toys = models.ManyToManyField(Toy)
> mum = models.ForeignKey(Parent, edit_inline=models.TABULAR)
>
> def __str__(self):
> return self.name
>
> class Admin:
> pass
> - end of models.py --

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



How to use lighttpd error-handler-404 handler to serve django?

2006-07-13 Thread Wei Litao

I already have lots of static files in my lighttpd web server, so I'd
like it to only talk to the django server if it can't find what it's
looking for. So I'd like use error-handler-404 directive to do that
thing.
In django official document, it use url-write method to talk to django
server. Is is possible to
hack that script to use error-handler-404?

-- 
Sincerely,

Wei Litao

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Aidas Bendoraitis

Carlos,

If you need to get started quickly, you can use FileField instead of
ImageField, so the PIL won't be necessary. The requirements of the
uploaded image may be written in help_text. Maybe some validation of
the image width and height can be done using Javascript. I'm not sure
about that, you should check, whether it is posible to retrieve the
dimensions of the selected file through Javascript, writing something
like that:
oImg = new Image();
oImg.onload = function() {
  alert(oImg.width + "x" + oImg.height);
}
oImg.src = document.getElementById("fileUploadFieldId").value;
(The script is written on the fly, I am not sure whether it works correctly)

Good luck!
Aidas Bendoraitis [aka Archatas]

On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
>
> >> Don't think so. I don't have root access to my box in Bluehost. Can
> >> anythone think of an alternative, short of telling support to install
> >> it themselves?
> > Technically all PIL is needed for is determining height, width and what
> > not of the image. If you do not need it or can ask the user, then PIL is
> > nice but not required. May take a little hacking, but it should be
> > feasible to ignore the warning.
> >
> > Another option is to see if imagemagick / graphicsmagick is installed
> > and write a wrapper which uses that instead of PIL. Also feasible and
> > should be relatively easy.
>
> Maybe so, but unfortunately I'm just too much of a Python newbie to
> try tackling that, while the clock is ticking for the Django app I
> must get thru the door.
>
> It's getting frustrating, all of this obstacles (which I believe are
> not Django's fault, but related to sysadmins' ignorance). We *really*
> need to think of a "providing Django support" tutorial for sysadmins,
> as we discussed briefly in the last few days... otherwise a lot of
> people would be scared away from Django because it's "too hard" or
> "unsupported".
>
> Anyway, I'll keep you posted, thanks a lot to you all!
> --
> Carlos Yoder
> http://carlitosyoder.blogspot.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: Custom SQL in Q objects

2006-07-13 Thread Kilian CAVALOTTI

On Thursday 13 July 2006 01:33, Russell Keith-Magee wrote:
> On 7/12/06, Kilian CAVALOTTI <[EMAIL PROTECTED]> wrote:
> No. Q objects do not support custom SQL - they are just wrappers that can
> be used to wrap groups of keyword search parameters (e.g.,
> article__name__contains='foo') so that they can be combined using logical
> operations.
>
> If you want custom SQL, you must use extra(), or obtain a cursor and write
> all the SQL from scratch.

Argh, bad news. Actually I asked the question because I'd like to use custom 
SQL in a 'limit_choices_to' option, in the admin interface. I can't figure 
how to proceed, since this option only takes a dictionary of lookup 
arguments, or Q objects. So I guess there's no way to use custom SQL 
in 'limit_choices_to', is it?

Regards,
-- 
Kilian CAVALOTTI  Administrateur réseaux et systèmes
UPMC / CNRS - LIP6 (C870)
8, rue du Capitaine Scott  Tel. : 01 44 27 88 54
75015 Paris - France   Fax. : 01 44 27 70 00

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Carlos Yoder

Aidas, thanks for the great tip!

I'll get cracking.

Best regards,

On 7/13/06, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
>
> Carlos,
>
> If you need to get started quickly, you can use FileField instead of
> ImageField, so the PIL won't be necessary. The requirements of the
> uploaded image may be written in help_text. Maybe some validation of
> the image width and height can be done using Javascript. I'm not sure
> about that, you should check, whether it is posible to retrieve the
> dimensions of the selected file through Javascript, writing something
> like that:
> oImg = new Image();
> oImg.onload = function() {
>   alert(oImg.width + "x" + oImg.height);
> }
> oImg.src = document.getElementById("fileUploadFieldId").value;
> (The script is written on the fly, I am not sure whether it works correctly)
>
> Good luck!
> Aidas Bendoraitis [aka Archatas]
>
> On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> >
> > >> Don't think so. I don't have root access to my box in Bluehost. Can
> > >> anythone think of an alternative, short of telling support to install
> > >> it themselves?
> > > Technically all PIL is needed for is determining height, width and what
> > > not of the image. If you do not need it or can ask the user, then PIL is
> > > nice but not required. May take a little hacking, but it should be
> > > feasible to ignore the warning.
> > >
> > > Another option is to see if imagemagick / graphicsmagick is installed
> > > and write a wrapper which uses that instead of PIL. Also feasible and
> > > should be relatively easy.
> >
> > Maybe so, but unfortunately I'm just too much of a Python newbie to
> > try tackling that, while the clock is ticking for the Django app I
> > must get thru the door.
> >
> > It's getting frustrating, all of this obstacles (which I believe are
> > not Django's fault, but related to sysadmins' ignorance). We *really*
> > need to think of a "providing Django support" tutorial for sysadmins,
> > as we discussed briefly in the last few days... otherwise a lot of
> > people would be scared away from Django because it's "too hard" or
> > "unsupported".
> >
> > Anyway, I'll keep you posted, thanks a lot to you all!
> > --
> > Carlos Yoder
> > http://carlitosyoder.blogspot.com
> >
> > >
> >
>
> >
>


-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread [EMAIL PROTECTED]

Sean Perry wrote:

> > Don't think so. I don't have root access to my box in Bluehost. Can
> > anythone think of an alternative, short of telling support to install
> > it themselves?
>
> Technically all PIL is needed for is determining height, width and what
> not of the image. If you do not need it or can ask the user, then PIL is
> nice but not required. May take a little hacking, but it should be
> feasible to ignore the warning.

if that's all you need, you don't really have to compile PIL.

just copy the contents of the "PIL" directory to some suitable location
on your path, and you get a PIL install that can identify and open most
image formats (you'll get errors if you're actually trying to do
something with the pixels, though).

example:

>>> from PIL import Image
>>> im = Image.open("Images/lena.jpg")
>>> im.mode
'RGB'
>>> im.size
(128, 128)
>>> im.load()
Traceback (most recent call last):
  File "", line 1, in ?
  File "PIL/ImageFile.py", line 217, in load
return Image.Image.load(self)
  File "PIL/Image.py", line 607, in load
return self.im.pixel_access(self.readonly)
AttributeError: pixel_access




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Menus parent/child foreign key dropdown too big

2006-07-13 Thread Aidas Bendoraitis

What about autocomplete functionality there? Try to integrate this one
into your system:
http://code.djangoproject.com/wiki/AJAXWidgetComboBox

Regards,
Aidas Bendoraitis [aka Archatas]


On 7/12/06, Mike <[EMAIL PROTECTED]> wrote:
>
> So here's the deal. I have Menus and MenuItems:
>
> class Menu(models.Model):
> name = models.CharField(maxlength=200)
>
> class MenuItem(models.Model):
> menu_id = models.ForeignKey(Menu, blank=False, null=False,
> edit_inline=models.TABULAR, num_in_admin=3)
> parent = models.ForeignKey('self', null=True, blank=True,
> related_name='child')
> name = models.CharField(maxlength=200, core=True)
> url = models.CharField(maxlength=255, core=True)
> target = models.CharField(maxlength=200, blank=True,
> choices=TARGET_CHOICES)
> tagID = models.CharField(maxlength=200, blank=True, null=True)
> sequence = models.IntegerField(choices=SEQUENCE_CHOICES)
>
> My problem is that there exist over 1,000 records for MenuItem and the
> dropdown list in the Admin has become unwieldy. In the parent dropdown
> I would just like to show the MenuItems associated with the menu I'm
> currently editing. I can't use raw_id_admin because of the edit_inline
> and limit_choices_to hasn't worked because the ID I need to compare it
> to comes from the url which the model doesn't have access to. If anyone
> can point me in the right direction I'd appreciate 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: Referring to media files

2006-07-13 Thread Steven Armstrong

>
> One more thing, if you don't mind. The documentation, and your
> context_processors.py show in the myapp directory. Can that file be in
> "mysite", rather than "myapp" so I don't have to repeat it for
> application I make?
>

Yep that'll work. You can put the context_processors.py file wherever you
like, it just has to be on your PYTHONPATH and the entry in settings.py
has to point to the right place.

cheers



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

2006-07-13 Thread Carlos Yoder

>> class Item(models.Model):
> > name = models.Charfield(maxlength=100)
> > user = models.ForeignKey(User)
> >
> > def get_user_name(self):
> > return self.user.name
> >
> > class Admin:
> > list_display = ('name', 'get_user_name')
> > ordering = ('get_user_name', 'name')
>
> Hi Mikael,
>
> You can't order by the result of a Python function, because the
> ordering clause happens at the SQL level, not in Python.


How about ordering by a ForeignKeyField?

snippet follows:

class Model(models.Model):
opis= models.CharField(maxlength=50)
znamka  = models.ForeignKey(Znamka)

def __str__(self):
return "%s %s" % (self.znamka, self.opis)

class Admin:
list_filter = ['znamka']# 
sidebar with handy filters

class Meta:
verbose_name_plural = "Modeli"
ordering = ['znamka', 'opis']


In the memorable words of Dr. Jones... "this doesn't seem to work" =)

Regards,


-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: admin ordering question

2006-07-13 Thread Carlos Yoder

I solved it!

The problem was because I was trying to sort by a field that was not
listed on Admin.list_display


Updated code:

class Model(models.Model):
opis= models.CharField(maxlength=50)
znamka  = models.ForeignKey(Znamka)

def __str__(self):
return "%s %s" % (self.znamka, self.opis)

class Admin:
list_filter = ['znamka']# 
sidebar with handy filters
list_display = ('znamka', 'opis')

class Meta:
verbose_name_plural = "Modeli"
ordering = ['znamka','opis']

Like a charm, it works.

=)


On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> >> class Item(models.Model):
> > > name = models.Charfield(maxlength=100)
> > > user = models.ForeignKey(User)
> > >
> > > def get_user_name(self):
> > > return self.user.name
> > >
> > > class Admin:
> > > list_display = ('name', 'get_user_name')
> > > ordering = ('get_user_name', 'name')
> >
> > Hi Mikael,
> >
> > You can't order by the result of a Python function, because the
> > ordering clause happens at the SQL level, not in Python.
>
>
> How about ordering by a ForeignKeyField?
>
> snippet follows:
>
> class Model(models.Model):
> opis= models.CharField(maxlength=50)
> znamka  = models.ForeignKey(Znamka)
>
> def __str__(self):
> return "%s %s" % (self.znamka, self.opis)
>
> class Admin:
> list_filter = ['znamka']# 
> sidebar with handy filters
>
> class Meta:
> verbose_name_plural = "Modeli"
> ordering = ['znamka', 'opis']
>
>
> In the memorable words of Dr. Jones... "this doesn't seem to work" =)
>
> Regards,
>
>
> --
> Carlos Yoder
> http://carlitosyoder.blogspot.com
>


-- 
Carlos Yoder
http://carlitosyoder.blogspot.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
-~--~~~~--~~--~--~---



apache, fastcgi, auto-reload?

2006-07-13 Thread Gábor Farkas

hi,

(yes, i know that the devel-server does auto-reload)

i'm using apache with fastcgi with flup with django.

is there a way to somehow have my source-code changes cause a reload? 
(so that i do not have to restart the fastcgi server (or apache) after 
every source-code change?)


thanks,
gabor

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



Image auto resizing

2006-07-13 Thread Enrico

Hi,

I'm trying to resize an image automatically after the upload. Maybe
Django should have this by default, but until there I'll try myself...

I got it working sucessfully, but I don't know if this is the best way,
the image is processed every time I save the object, it should be done
only on new uploads.

My model:

class pic(models.Model):
name = models.CharField(maxlength=60, core=True)
pic = models.ImageField(upload_to='news')

def save(self):
file_path = self.get_pic_filename()
# There's is a file?
if (file_path):
im = Image.open(file_path)
# Using my own image resizing based on PIL
im = image_util.best_fit(im, 30, 30)
im.save(file_path)
super(news_pic, self).save()

class Admin:
pass

Is there a better way to do it?

How hard would be to create a "custom" ImageField for this?
It could be used in many other models in my project, and could even get
included in the Django package.

Thanks in advance.

Enrico


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



Camino and Safari do not open feeds

2006-07-13 Thread bayerj

Hi group,

I implemented a feed as described in
http://www.djangoproject.com/documentation/syndication/.

The source can be found here: http://paste.e-scribe.com/703/

The url configuration is:

(
r'^feeds/(?P.*)/$',
'django.contrib.syndication.views.feed',
{
'feed_dict': { "latest" : LatestEntries}
}
),

If I point Safari to the url, I get a "Don't understand content" error.
Camino just saves the file to the download folder. The structure and
everything of the file ( := the feed) is as intended. But I want Safari
and Camino and all the other browsers to recognize the feed as a feed.

Anyone has had similar experiences?

Regards,
-Justin


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



Django hosting

2006-07-13 Thread [EMAIL PROTECTED]

Hi, all!

Can anybody give me hosting for my django project for a week?

I need to show my project to my customer tomorrow but i can't take
hosting for it now.

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: Custom SQL in Q objects

2006-07-13 Thread Russell Keith-Magee
On 7/13/06, Kilian CAVALOTTI <[EMAIL PROTECTED]> wrote:
Argh, bad news. Actually I asked the question because I'd like to use customSQL in a 'limit_choices_to' option, in the admin interface. I can't figurehow to proceed, since this option only takes a dictionary of lookup
arguments, or Q objects. So I guess there's no way to use custom SQLin 'limit_choices_to', is it?Unfortunately, no. There is not currently a way to put custom SQL in limit_choices_to. 
The idea (allowing an extra() clause on the Q objects so that you can have extra customization in limit_choices_to) is reasonable enough, so it's probably worth lodging this as an enhancement request, so the idea isn't lost. However, I wouldn't bet on this being implemented any time soon (unless your itch gets the better of you, and you try your own hand at a fix).
Otherwise, you're out of luck. Sorry :-(Russ Magee %-)

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


Re: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Jeremy Dunck

On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
>
> > http://packages.debian.org/unstable/python/python-imaging
> > ?
>
> Don't think so. I don't have root access to my box in Bluehost. Can
> anythone think of an alternative, short of telling support to install
> it themselves?

I may be wrong here, but I think deb packages can be installed
anywhere.  The important thing is that Python be able to find and use
it.

I think you can download the .deb, then do something like this:

dpkg -i -instdir=/some/path/under/your/home your.deb

from the man page:
--root=dir | --admindir=dir | --instdir=dir
Change default directories. admindir defaults to /var/lib/dpkg and
contains many files that give information about status of installed or
uninstalled packages, etc. instdir defaults to / and refers to the
directory where packages are to be installed. instdir is also the
directory passed to chroot(2) before running package's installation
scripts, which means that the scripts see instdir as a root directory.
Changing root changes instdir to dir and admindir to dir/var/lib/dpkg.

Since you'll be installing to a non-standard location of PIL, you'll
need to make sure it's on the path (and on Python's path, which I
think you can do with SetEnv in your apache conf), and then (I think)
you should be set.

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

2006-07-13 Thread Jeremy Dunck

On 7/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi, all!
>
> Can anybody give me hosting for my django project for a week?
>
> I need to show my project to my customer tomorrow but i can't take
> hosting for it now.

In a pinch, the built-in dev server might save you for a demo:

/your/project/directory/manage.py runserver

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

2006-07-13 Thread [EMAIL PROTECTED]

I can't meet with customer, project must be shared.


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

2006-07-13 Thread Waylan Limberg

On 7/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi, all!
>
> Can anybody give me hosting for my django project for a week?
>
> I need to show my project to my customer tomorrow but i can't take
> hosting for it now.
>
> Thanks.
>
Perhaps you could take advantage of some hosting providers "trial
period." That is if the dev server on a laptop won't cut it.


-- 

Waylan Limberg
[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
-~--~~~~--~~--~--~---



Setting up Django on Archlinux with MySQL backend

2006-07-13 Thread [EMAIL PROTECTED]

Hi all, I was trying to set up Django on Archlinux with MySQL, and I'm
running without problems.
I have post "Setting up Django on Archlinux with MySQL backend" on my
blog http://laitsas.com/lighttpd/49/django_archlinux/
I hope it helps someone :-)


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



Please fix my ugly code

2006-07-13 Thread Carlos Yoder

Hello people, my ongoing adventures in firstdjangoappland continue thus:

I'm putting together a simple search app for a car project. On entry,
user sees a list of 5 random cars. He can use up to two comboboxes to
filter the results (car model and fuel type).

This is what I've come up with on my home() view, so far, and it looks
really ugly.

def home(request):

results = {}

# these 2 guys are the filters
model_list = Model.objects.all()
gorivo_list = Gorivo.objects.all().order_by('opis')

selected_model_id = 0
selected_gorivo_id = 0

if request.POST:
# this handles 'SELECTED' attribute on comboboxes
try:
selected_model_id = int(request.POST['model_id'])
except:
pass
try:
selected_gorivo_id = int(request.POST['gorivo_id'])
except:
pass

# and this should take care of the filtering... but I'm stumped 
really
# both filters should add up
results = Vozilo.objects.all()
if selected_model_id != 0:
results = 
results.filter(model_id__exact=selected_model_id)
if selected_gorivo_id != 0:
results = 
results.filter(gorivo_id__exact=selected_gorivo_id)
else:
# no POST, we show 5 random cars.
results = Vozilo.objects.order_by('?')[:5]

return render_to_response('cars/home.html', {
'model_list':model_list,
'gorivo_list':gorivo_list,
'selected_model_id':selected_model_id,
'selected_gorivo_id':selected_gorivo_id,
'results': results
})


There must be a better way of doing this, right? I'm a terrible newbie
both at Python and Django --and I'm not a kid anymore, so no more time
to spare hitting my head on walls :-)

Insights? Ideas?

Thanks a million,

-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: Django hosting

2006-07-13 Thread Jeremy Dunck

On 7/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I can't meet with customer, project must be shared.
>

Give him your IP.  ;-)

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

2006-07-13 Thread David Reynolds


On 13 Jul 2006, at 2:37 pm, bayerj wrote:

>
> Hi group,
>
> I implemented a feed as described in
> http://www.djangoproject.com/documentation/syndication/.
>
> The source can be found here: http://paste.e-scribe.com/703/
>
> The url configuration is:
>
> (
> r'^feeds/(?P.*)/$',
> 'django.contrib.syndication.views.feed',
> {
> 'feed_dict': { "latest" : LatestEntries}
> }
> ),
>
> If I point Safari to the url, I get a "Don't understand content"  
> error.
> Camino just saves the file to the download folder. The structure and
> everything of the file ( := the feed) is as intended. But I want  
> Safari
> and Camino and all the other browsers to recognize the feed as a feed.
>
> Anyone has had similar experiences?

Hi. Are you running the development server?

I've found these don't tend to work in the development server in  
Safari, but you when you make sure app live at a 'proper' url they  
will work.

Cheers,

David

-- 
David Reynolds
[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
-~--~~~~--~~--~--~---



Re: Django hosting

2006-07-13 Thread [EMAIL PROTECTED]

I have not static ip :(


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



SQL Queries with columns not in the DB

2006-07-13 Thread Jason Murray

I'm reposting this because I was told my last post got lost in an existing 
thread. Sorry about that.

I figured out my syncdb question. It turns out that as long as the model is
defined correctly things go well. And the output from syncdb will help you
with any trivial troubles you might have with your model. Nice!

Another question for you all.

I want to duplicate the queries that the existing app does. The site 
maintains the results, standings, and stats for a baseball league.
It has queries like:

select number, name, win, loss, tie, streak, streak_type,
win/(win+loss+tie)*1.000 wpct, win*2+tie points, win+loss+tie GP,
gamesinseason.games - (win+loss+tie) GL from stand_overall, gamesinseason,
team where team.year = %s && gamesinseason.year = team.year &&
stand_overall.team = team.ID order by points desc, win desc, tie desc, loss

and

select First_name, Last_name, sum(ab) ab, sum(runs) r, sum(1b) s, s
um(2b) d, sum(3b) t, sum(hr) hr, sum(hbp) hbp, sum(bb) bb, sum(ko) ko,
sum(1b+2b+3b+hr) hits, (sum(1b)+sum(2b)+sum(3b)+sum(hr))/sum(ab)*1. avg,
sum(bb)/(sum(bb)+sum(ab))*1. bb,
(sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))/(sum(ab)+sum(bb)+sum(hbp))*1.
ob, (sum(1b)+2*sum(2b)+3*sum(3b)+4*sum(hr))/sum(ab)*1. as slug,
sum(runs)/(sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))*1
. score, sum(ko)/(sum(ab)+sum(bb)+sum(hbp))*1. kperapp from player,
offensive_stats, game where player.ID = offensive_stats.player && game.ID =
offensive_stats.game && player.First_name = %s && player.Last_name = %s 
group by First_name, Last_name

My question revolves around how I should get similar results in django. From
what I can tell I should be subclassing a Manager so I can return my own
QuerySets. I don't think the writing custom SQL with connection.cursor() is
the way to go.

I know that the join portions of the where clauses will be taken care of by 
the db_api. I also know that I can do ORDER BY and LIMIT type stuff with 
extra=, .order(), etc.

Am I on the right path?

-- 
| Jason Murray
  --
| The problem in living with popular culture is maintaining some degree of
| individuality - some sense of who we are and what we think in a world
| in which so many others are trying to determine those things for us.
  -- Gary Bauslaugh

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

2006-07-13 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:

> I have not static ip :(

http://www.dyndns.com/services/dns/dyndns/




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

2006-07-13 Thread Jeremy Dunck

On 7/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi, all!
>
> Can anybody give me hosting for my django project for a week?

I assume you've seen this:
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

Failing that, I'm sorry... I don't have a proper dev environment to share.  :-/

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

2006-07-13 Thread Carlos Yoder

www.no-ip.com

!

On 7/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I have not static ip :(
>
>
> >
>


-- 
Carlos Yoder
http://carlitosyoder.blogspot.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: Camino and Safari do not open feeds

2006-07-13 Thread Adrian Holovaty

On 7/13/06, bayerj <[EMAIL PROTECTED]> wrote:
> If I point Safari to the url, I get a "Don't understand content" error.
> Camino just saves the file to the download folder. The structure and
> everything of the file ( := the feed) is as intended. But I want Safari
> and Camino and all the other browsers to recognize the feed as a feed.

Hi Justin,

I believe this is happening because Django uses the
"application/atom+xml" MIME type for Atom feeds, and your browsers
don't appear to be able to handle that MIME type. In the grand scheme
of things, this is no problem, but if you really want to be able to
see the raw source of your feed, change your browser settings to use a
particular program to handle that MIME type.

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: Please fix my ugly code

2006-07-13 Thread Kenneth Gonsalves


On 13-Jul-06, at 8:02 PM, Carlos Yoder wrote:

> There must be a better way of doing this, right? I'm a terrible newbie
> both at Python and Django --and I'm not a kid anymore, so no more time
> to spare hitting my head on walls :-)

i have done more or less the same thing - yet to try it out though.  
If it works go with it

-- 

regards
kg
http://lawgon.livejournal.com
http://avsap.org.in



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

2006-07-13 Thread keukaman

I get an attibute error and a template error when I try to view the
detail of a post:

'NoneType' object has no attribute '_default_manager' is the attribute
error.

{% free_comment_form for blog.entry object.id %} is highlighted as an
error in the template.

Can you give me some idea of where to start looking to correct these
errors? I have a feeling it is in the models.py somewhere, but I'm
using the exact same code as from the url you provided.


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

2006-07-13 Thread Jorge Gajon

Hi Carlos,

I think your code is going good so far. Of course I'm not a guru but I
think your code is fine. Is there something that you don't feel
comfortable with? With respect to adding the results of both filters,
you need to extend the results of the first results (if any), like
this:

results = Vozilo.objects.all()
if selected_model_id != 0:
results = results.filter(model_id__exact=selected_model_id)
if selected_gorivo_id != 0:
results.extend(results.filter(gorivo_id__exact=selected_gorivo_id))



If I were to code that view I would use a custom manipulator and it
would end up something like the following. But PLEASE, PLEASE, be
aware that it's just my personal way of doing things, I am no one to
tell you how to do things.

class FilterResultsManipulator(forms.Manipulator):
def __init__(self):
model_choices = [(m.id, m) for m in Model.objects.all()]
gorivo_choices = [(g.id, g) for g in
Gorivo.objects.all().order_by('opis')]
self.fields = (
forms.SelectField(field_name='model', choices=model_choices),
forms.SelectField(field_name='gorivo', choices=gorivo_choices),
)

def home(request):
results = []
filter_manipulator = FilterResultsManipulator()
filter_data = {}

if request.POST:
filter_data = request.POST.copy()

model = None
gorivo = None
if filter_data.get('model'):
model = get_object_or_404(Model, pk=filter_data['model'])
if filter_data.get('gorivo'):
gorivo = get_object_or_404(Gorivo, pk=filter_data['gorivo'])

if model:
results = Vozilo.objects.filter(model=model)
if gorivo:
results.extend(Vozilo.objects.filter(gorivo=gorivo))
else:
results = Vozilo.objects.order_by('?')[:5]

filter_form = forms.FormWrapper(filter_manipulator, filter_data, {})

return render_to_response('cars/home.html', {
'results': results,
'filter_form': filter_form,
})

And the template you only need to display the form fields.


Search by:
Model: {{ filter_form.model }}
Gorivo: {{ filter_form.gorivo }}




The custom manipulator and associated form wrapper takes care of
displaying the select fields in your form and maintaining the selected
option between posted pages. The use of the utility
get_object_or_404() frees you of worrying if the incoming data is
invalid or malformed, if it is a 404 exception will be raised and the
user will get a 404 page.

If you have questions about the above code feel free to ask.

Cheers,
Jorge



On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
>
> Hello people, my ongoing adventures in firstdjangoappland continue thus:
>
> I'm putting together a simple search app for a car project. On entry,
> user sees a list of 5 random cars. He can use up to two comboboxes to
> filter the results (car model and fuel type).
>
> This is what I've come up with on my home() view, so far, and it looks
> really ugly.
>
> def home(request):
>
> results = {}
>
> # these 2 guys are the filters
> model_list = Model.objects.all()
> gorivo_list = Gorivo.objects.all().order_by('opis')
>
> selected_model_id = 0
> selected_gorivo_id = 0
>
> if request.POST:
> # this handles 'SELECTED' attribute on comboboxes
> try:
> selected_model_id = int(request.POST['model_id'])
> except:
> pass
> try:
> selected_gorivo_id = int(request.POST['gorivo_id'])
> except:
> pass
>
> # and this should take care of the filtering... but I'm 
> stumped really
> # both filters should add up
> results = Vozilo.objects.all()
> if selected_model_id != 0:
> results = 
> results.filter(model_id__exact=selected_model_id)
> if selected_gorivo_id != 0:
> results = 
> results.filter(gorivo_id__exact=selected_gorivo_id)
> else:
> # no POST, we show 5 random cars.
> results = Vozilo.objects.order_by('?')[:5]
>
> return render_to_response('cars/home.html', {
> 'model_list':model_list,
> 'gorivo_list':gorivo_list,
> 'selected_model_id':selected_model_id,
> 'selected_gorivo_id':selected_gorivo_id,
> 'results': results
> })
>
>
> There must be a better way of doing this, right? I'm a terrible newbie
> both at Python and Django --and I'm not a kid anymore, so no more time
> to spare hitting my head on walls :-)
>
> Insights? Ideas?
>
> Thanks a million,
>
> --
> Carlos Yoder
> http://carlitosyoder.blogspot.com
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Goog

MySQLdb problems

2006-07-13 Thread birrafondaio

Hi all, I`m just starting to use Django and I`m trying to install it on
my Fedora Distro but when i try to sync the db with "python manage.py
syncdb" I keep on getting this traceback:

-
Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "/usr/lib/python2.4/site-packages/django/core/management.py",
line 1297, in execute_manager
execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.4/site-packages/django/core/management.py",
line 1221, in execute_from_command_line
action_mapping[action]()
  File "/usr/lib/python2.4/site-packages/django/core/management.py",
line 425, in syncdb
from django.db import connection, transaction, models,
get_creation_module
  File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
11, in ?
backend = __import__('django.db.backends.%s.base' %
settings.DATABASE_ENGINE, '', '', [''])
  File
"/usr/lib/python2.4/site-packages/django/db/backends/mysql/base.py",
line 12, in ?
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: cannot import name ImmutableSet
---

I already searched for people with similar problems as mine but can`t
find any solution.
I`ve already installed mysql and mysql-python but nothing seems to
work, can someone help me please? I`m getting desperate, any help will
be much appreciated.

Regards, David


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

2006-07-13 Thread Geert Vanderkelen

Hi David,

birrafondaio wrote:
..
> raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: cannot import name ImmutableSet
> ---
> 
> I already searched for people with similar problems as mine but can`t
> find any solution.
> I`ve already installed mysql and mysql-python but nothing seems to
> work, can someone help me please? I`m getting desperate, any help will
> be much appreciated.
..

This has been discussed here before. You probably upgraded MySQLdb over an 
older version. You need to remove set.py from the MySQLdb 1.2.1 installation.

I reported it here:
 
http://sourceforge.net/tracker/index.php?func=detail&aid=1445105&group_id=22307&atid=374932

Hope this works.

Cheers,

Geert

-- 
Geert Vanderkelen
http://some-abstract-type.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
-~--~~~~--~~--~--~---



Non iterable argument

2006-07-13 Thread Lucas Vogelsang

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I have an integer in my model:
 rating= models.IntegerField(null=true, blank=true)
And I create my Add form for the class like as described in the
manipulator doc with a manipulator[1]. As expected, { form.rating }
creates an input field. However, when I try to submit the form I get
the error "Non iterable argument", see [2].

Anybody can help me out with this?

[1] http://wservices.ch/~lucas/ablage/views.py
[2] http://wservices.ch/~lucas/ablage/error.html

regards, lucas
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Signed with GPG & Enigmail - see http://www.vincisolutoins.ch/pgp/

iD8DBQFEtn4P3RQ/RpGW2HgRAn9qAJ9btgJXt34o2aQWnSiXwRkmwVnOBwCgsmrO
yDHFpzWwFpM2jN7RlXmHyYY=
=iBZU
-END PGP SIGNATURE-


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



Re: Please fix my ugly code

2006-07-13 Thread Jorge Gajon

Hi again Carlos,

I suggested this change in your code:
> results = Vozilo.objects.all()
> if selected_model_id != 0:
> results = results.filter(model_id__exact=selected_model_id)
> if selected_gorivo_id != 0:
> results.extend(results.filter(gorivo_id__exact=selected_gorivo_id))
>
But I'm totally wrong there. Your original code should be fine,
because you were chaining the filters. The 'extends' is not necessary
and in fact it is wrong.

I also realized that the filter logic in the code that I proposed is
wrong. With that code you would get a list of cars that match the
specified model, along with all the cars that match the gorivo type
(regardless of model).

The correct thing is to chain the filters like you did in your
original code. This should work, I tested it with a model I have here.

results = Vozilo.objects.all()
if model:
results = results.filter(model=model)
if gorivo:
results = results.filter(gorivo=gorivo)


I'm sorry if I caused any confusion and for not paying more attention
to that filtering part :)

Cheers,
Jorge



On 7/13/06, Jorge Gajon <[EMAIL PROTECTED]> wrote:
> Hi Carlos,
>
> I think your code is going good so far. Of course I'm not a guru but I
> think your code is fine. Is there something that you don't feel
> comfortable with? With respect to adding the results of both filters,
> you need to extend the results of the first results (if any), like
> this:
>
> results = Vozilo.objects.all()
> if selected_model_id != 0:
> results = results.filter(model_id__exact=selected_model_id)
> if selected_gorivo_id != 0:
> results.extend(results.filter(gorivo_id__exact=selected_gorivo_id))
>
>
>
> If I were to code that view I would use a custom manipulator and it
> would end up something like the following. But PLEASE, PLEASE, be
> aware that it's just my personal way of doing things, I am no one to
> tell you how to do things.
>
> class FilterResultsManipulator(forms.Manipulator):
> def __init__(self):
> model_choices = [(m.id, m) for m in Model.objects.all()]
> gorivo_choices = [(g.id, g) for g in
> Gorivo.objects.all().order_by('opis')]
> self.fields = (
> forms.SelectField(field_name='model', choices=model_choices),
> forms.SelectField(field_name='gorivo', choices=gorivo_choices),
> )
>
> def home(request):
> results = []
> filter_manipulator = FilterResultsManipulator()
> filter_data = {}
>
> if request.POST:
> filter_data = request.POST.copy()
>
> model = None
> gorivo = None
> if filter_data.get('model'):
> model = get_object_or_404(Model, pk=filter_data['model'])
> if filter_data.get('gorivo'):
> gorivo = get_object_or_404(Gorivo, pk=filter_data['gorivo'])
>
> if model:
> results = Vozilo.objects.filter(model=model)
> if gorivo:
> results.extend(Vozilo.objects.filter(gorivo=gorivo))
> else:
> results = Vozilo.objects.order_by('?')[:5]
>
> filter_form = forms.FormWrapper(filter_manipulator, filter_data, {})
>
> return render_to_response('cars/home.html', {
> 'results': results,
> 'filter_form': filter_form,
> })
>
> And the template you only need to display the form fields.
>
> 
> Search by:
> Model: {{ filter_form.model }}
> Gorivo: {{ filter_form.gorivo }}
> 
> 
>
>
> The custom manipulator and associated form wrapper takes care of
> displaying the select fields in your form and maintaining the selected
> option between posted pages. The use of the utility
> get_object_or_404() frees you of worrying if the incoming data is
> invalid or malformed, if it is a 404 exception will be raised and the
> user will get a 404 page.
>
> If you have questions about the above code feel free to ask.
>
> Cheers,
> Jorge
>
>
>
> On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> >
> > Hello people, my ongoing adventures in firstdjangoappland continue thus:
> >
> > I'm putting together a simple search app for a car project. On entry,
> > user sees a list of 5 random cars. He can use up to two comboboxes to
> > filter the results (car model and fuel type).
> >
> > This is what I've come up with on my home() view, so far, and it looks
> > really ugly.
> >
> > def home(request):
> >
> > results = {}
> >
> > # these 2 guys are the filters
> > model_list = Model.objects.all()
> > gorivo_list = Gorivo.objects.all().order_by('opis')
> >
> > selected_model_id = 0
> > selected_gorivo_id = 0
> >
> > if request.POST:
> > # this handles 'SELECTED' attribute on comboboxes
> > try:
> > selected_model_id = int(request.POST['model_id'])
> > except:
> > pass
> > try:
> > selected_gorivo_id = int(request.POST['gorivo_id'])
> >  

Re: Non iterable argument

2006-07-13 Thread Jorge Gajon

Hi,
You are calling manipulator.do_html2python() before the call to
get_validation_errors()

The correct thing is to call do_html2python() after you have validated
the data and there are no errors.

It should look like this:

errors = manipulator.get_validation_errors(new_data)
print errors
if not errors:
print "noerrors"
manipulator.do_html2python(new_data)
print new_data['owner']


Cheers,
Jorge




On 7/13/06, Lucas Vogelsang <[EMAIL PROTECTED]> wrote:
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi,
>
> I have an integer in my model:
>  rating= models.IntegerField(null=true, blank=true)
> And I create my Add form for the class like as described in the
> manipulator doc with a manipulator[1]. As expected, { form.rating }
> creates an input field. However, when I try to submit the form I get
> the error "Non iterable argument", see [2].
>
> Anybody can help me out with this?
>
> [1] http://wservices.ch/~lucas/ablage/views.py
> [2] http://wservices.ch/~lucas/ablage/error.html
>
> regards, lucas
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Signed with GPG & Enigmail - see http://www.vincisolutoins.ch/pgp/
>
> iD8DBQFEtn4P3RQ/RpGW2HgRAn9qAJ9btgJXt34o2aQWnSiXwRkmwVnOBwCgsmrO
> yDHFpzWwFpM2jN7RlXmHyYY=
> =iBZU
> -END PGP SIGNATURE-
>
>
> >
>

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



Problems with __str__ methods in my Models

2006-07-13 Thread Jason Murray

Yes it's me again :)

Anyway I've populating my Models with __str_ methods. I've only had on 
hicough.

Here is the model in question:
class Result(models.Model):
 ID = models.IntegerField(primary_key=True)
 home_runs = models.IntegerField("home team runs", null=True, blank=True)
 away_runs = models.IntegerField("visiting team runs", null=True, 
blank=True)
 game = models.ForeignKey(Game, db_column='game')
 ump1 = models.ForeignKey(Ump, related_name='result_ump1', 
db_column='ump1')
 ump2 = models.ForeignKey(Ump, related_name='result_ump2', 
db_column='ump2')
 def __str__(self):
 return "%s: %i (%i)" % (self.game.datetime.strftime("%Y-%m-%d"),
 self.game.away.number, self.away_runs)
 class Meta:
 db_table = 'result'
 class Admin:
 pass

When I jump into the shell (python manage.py shell) to try it out...

 >>> Result.objects.all()
Traceback (most recent call last):
   File "", line 1, in ?
   File 
"/usr/local/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/query.py",
 
line 88, in __repr__
 return repr(self._get_data())
   File 
"/usr/local/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/base.py",
 
line 76, in __repr__
 return '<%s: %s>' % (self.__class__.__name__, self)
   File "/home/jmurray/prfa/../prfa/standings/models.py", line 88, in __str__
 return "%s: %i (%i)" % (self.game.datetime.strftime("%Y-%m-%d"), 
self.game.away.number, self.away_runs)
TypeError: int argument required


However when I retrieve an individual result...

 >>> r=Result.objects.get(pk=234)
 >>> r

 >>>

This is confusing to me. __str__ works for an individual objects, but not 
a collection of them. What's happening here?

I'm puzzled, I hope someone here is able to help me out.

BTW it is self.away_runs that causes the problems. When I remove that from 
the __str__ function it works 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
-~--~~~~--~~--~--~---



Re: Django Blog Code

2006-07-13 Thread Jeremy Dunck

On 7/13/06, keukaman <[EMAIL PROTECTED]> wrote:
> {% free_comment_form for blog.entry object.id %} is highlighted as an
> error in the template.

Based on the settings file here:
http://code.djangoproject.com/svn/djangoproject.com/django_website/settings.py

They're using the django.contrib.comments app, which defines the
free_comment_form template tag.  django.contrib.comments is included
in your django distro, though it's not documented yet.  You should be
able to just add comments to your INSTALLED_APPS and sync your DB.

http://code.djangoproject.com/svn/django/trunk/django/contrib/comments/

If you want to understand how to use the comments app, browsing the
source and documenting what you be a fine way to learn 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: django for end users?

2006-07-13 Thread maphew

thanks for the response eas. I have seen and tried to install some of
the django blog apps people have shared but without success (so far). I
guess the message here is that there is just no way around setting some
time aside to sit down and learn how the pieces go together, that it is
not for end users (perhaps post 1.0...)...it IS called a "framework"
after all. :)


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

2006-07-13 Thread Adrian Holovaty

On 7/13/06, Jason Murray <[EMAIL PROTECTED]> wrote:
>File "/home/jmurray/prfa/../prfa/standings/models.py", line 88, in __str__
>  return "%s: %i (%i)" % (self.game.datetime.strftime("%Y-%m-%d"),
> self.game.away.number, self.away_runs)
> TypeError: int argument required

This is happening because at least one of your Result objects has an
away_runs field with a value of None. The "%i" string formatting
parameter accepts only integers; if you feed it None, you'll get that
exact error. Try this at the Python interactive prompt:

print '%i' % None

The solution is to either use '%s' instead of '%i', or to special-case
the case in which self.away_runs is None. Example:

def __str__(self):
if self.away_runs is None:
away_txt = 'No away runs'
else:
away_txt = str(self.away_runs)
return "%s: %i (%s)" % (self.game.datetime.strftime("%Y-%m-%d"),
self.game.away.number, away_txt)

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



[Django Publicity] Cameron Moll's Screen Grab Confab

2006-07-13 Thread Paulo

This is slightly OT, and I apologize if this has been posted already,
but I thought it was pretty darn cool... In 60+ entries (already) I've
seen reference to *three* different posts where people were working
with django. Check it out <
http://www.cameronmoll.com/archives/001045.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
-~--~~~~--~~--~--~---



Re: Custom SQL in Q objects

2006-07-13 Thread Malcolm Tredinnick

On Thu, 2006-07-13 at 21:54 +0800, Russell Keith-Magee wrote:
> 
> 
> On 7/13/06, Kilian CAVALOTTI <[EMAIL PROTECTED]> wrote:
> 
> Argh, bad news. Actually I asked the question because I'd like
> to use custom
> SQL in a 'limit_choices_to' option, in the admin interface. I
> can't figure
> how to proceed, since this option only takes a dictionary of
> lookup 
> arguments, or Q objects. So I guess there's no way to use
> custom SQL
> in 'limit_choices_to', is it?
> 
> Unfortunately, no. There is not currently a way to put custom SQL in
> limit_choices_to. 
> 
> The idea (allowing an extra() clause on the Q objects so that you can
> have extra customization in limit_choices_to) is reasonable enough, so
> it's probably worth lodging this as an enhancement request, so the
> idea isn't lost. However, I wouldn't bet on this being implemented any
> time soon (unless your itch gets the better of you, and you try your
> own hand at a fix). 
> 
> Otherwise, you're out of luck. Sorry :-(

Actually there is another solution. You can create a custom Q class (the
"Q" class is defined in django.db.query). The get_sql() method of your
class has to return something in the right format, so it requires
understanding the return results from django.db.query.parse_lookup().
It's not too hard to work out (putting a print into Q.get_sql() and
running one should be enough of a start).

Malcolm


> 
> Russ Magee %-)
> 
> 
> 
> 
> > 


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



Re: SQL Queries with columns not in the DB

2006-07-13 Thread Malcolm Tredinnick

On Thu, 2006-07-13 at 10:48 -0400, Jason Murray wrote:
> I'm reposting this because I was told my last post got lost in an existing 
> thread. Sorry about that.
> 
> I figured out my syncdb question. It turns out that as long as the model is
> defined correctly things go well. And the output from syncdb will help you
> with any trivial troubles you might have with your model. Nice!
> 
> Another question for you all.
> 
> I want to duplicate the queries that the existing app does. The site 
> maintains the results, standings, and stats for a baseball league.
> It has queries like:
> 
> select number, name, win, loss, tie, streak, streak_type,
> win/(win+loss+tie)*1.000 wpct, win*2+tie points, win+loss+tie GP,
> gamesinseason.games - (win+loss+tie) GL from stand_overall, gamesinseason,
> team where team.year = %s && gamesinseason.year = team.year &&
> stand_overall.team = team.ID order by points desc, win desc, tie desc, loss
> 
> and
> 
> select First_name, Last_name, sum(ab) ab, sum(runs) r, sum(1b) s, s
> um(2b) d, sum(3b) t, sum(hr) hr, sum(hbp) hbp, sum(bb) bb, sum(ko) ko,
> sum(1b+2b+3b+hr) hits, (sum(1b)+sum(2b)+sum(3b)+sum(hr))/sum(ab)*1. avg,
> sum(bb)/(sum(bb)+sum(ab))*1. bb,
> (sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))/(sum(ab)+sum(bb)+sum(hbp))*1.
> ob, (sum(1b)+2*sum(2b)+3*sum(3b)+4*sum(hr))/sum(ab)*1. as slug,
> sum(runs)/(sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))*1
> . score, sum(ko)/(sum(ab)+sum(bb)+sum(hbp))*1. kperapp from player,
> offensive_stats, game where player.ID = offensive_stats.player && game.ID =
> offensive_stats.game && player.First_name = %s && player.Last_name = %s 
> group by First_name, Last_name
> 
> My question revolves around how I should get similar results in django. From
> what I can tell I should be subclassing a Manager so I can return my own
> QuerySets. I don't think the writing custom SQL with connection.cursor() is
> the way to go.

If you are wanting to use aggregates in the select clauses, then you
need to write custom SQL to some extent. The extra() method on QuerySets
will help you with some of this, since you can inject extra things into
the select clause that way (see the DB API documentation examples). 

Unfortunately, the "group by" clause sinks you. You cannot do grouping
with query sets (at the moment, at least). So you are back to writing
custom SQL for those.

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



Re: [Django Publicity] Cameron Moll's Screen Grab Confab

2006-07-13 Thread Adrian Holovaty

On 7/13/06, Paulo <[EMAIL PROTECTED]> wrote:
> This is slightly OT, and I apologize if this has been posted already,
> but I thought it was pretty darn cool... In 60+ entries (already) I've
> seen reference to *three* different posts where people were working
> with django. Check it out <
> http://www.cameronmoll.com/archives/001045.html >.

Sweet! Thanks for sharing 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: Please fix my ugly code

2006-07-13 Thread Kenneth Gonsalves


On 13-Jul-06, at 11:06 PM, Jorge Gajon wrote:

> But I'm totally wrong there. Your original code should be fine,
> because you were chaining the filters. The 'extends' is not necessary
> and in fact it is wrong.

you scared me a bit there ;-)

-- 

regards
kg
http://lawgon.livejournal.com
http://avsap.org.in



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

2006-07-13 Thread Kenneth Gonsalves


On 14-Jul-06, at 12:01 AM, Jason Murray wrote:

> TypeError: int argument required

put int(value) around all your int values, or refer to int values by % 
s and put a str() around them

-- 

regards
kg
http://lawgon.livejournal.com
http://avsap.org.in



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



Set up problems ( webfaction )

2006-07-13 Thread Iain Duncan

I'm setting up a sight on webfaction, and so far things are coming along
ok, but I can't figure out how to serve images. I've never used a shared
hosting setup that didn't have a directory called 'public' or 'htdocs'.
Has anyone on here used them? Any tips on where I need to put media and
what I need to put in my httpd.conf to get this working?

Thanks
Iain

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: [Django Publicity] Cameron Moll's Screen Grab Confab

2006-07-13 Thread James Bennett

On 7/13/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
> Sweet! Thanks for sharing that. :)

Last I checked, there were five Django-powered projects in there. It's growing.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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

2006-07-13 Thread Ian Holsman

Hi Iain.

in your apache config do something similar to
http://svn.zyons.python-hosting.com/trunk/zilbo/conf/zyons.conf.tmpl

and that will let the apache handle the 'images' area of your site  
instead of django.

On 14/07/2006, at 12:02 PM, Iain Duncan wrote:

>
> I'm setting up a sight on webfaction, and so far things are coming  
> along
> ok, but I can't figure out how to serve images. I've never used a  
> shared
> hosting setup that didn't have a directory called 'public' or  
> 'htdocs'.
> Has anyone on here used them? Any tips on where I need to put media  
> and
> what I need to put in my httpd.conf to get this working?
>
> Thanks
> Iain
>
> >


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



Samples for displaying a tree of data

2006-07-13 Thread Chris Moffitt

I'm using the recipe here 
(http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic) 
for a category model.  It's working well for the most part. 

I am getting a little stuck trying to figure out how to turn it into a 
vertical navigation structure.  I've looked at 
http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal but I 
think this is not as nice from an admin perspective so I'm not using it. 

My category structure might look like books :: non-fiction :: technical 
:: Django for Dummies

How can I create some sort of menu structure like I've shown below?

Books
  ->Non-fiction
 ->History
 ->Biographies
  ->Technical
  ->Fiction
Movies
Games

I'm a little worried that all the recursion could get painful from a 
performance perspective & I figure this is a common enough situation 
that maybe someone else already has something that works pretty well.

Thanks,
Chris

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



Re: Samples for displaying a tree of data

2006-07-13 Thread Malcolm Tredinnick

On Thu, 2006-07-13 at 22:03 -0500, Chris Moffitt wrote:
> I'm using the recipe here 
> (http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic) 
> for a category model.  It's working well for the most part. 
> 
> I am getting a little stuck trying to figure out how to turn it into a 
> vertical navigation structure.  I've looked at 
> http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal but I 
> think this is not as nice from an admin perspective so I'm not using it. 
> 
> My category structure might look like books :: non-fiction :: technical 
> :: Django for Dummies
> 
> How can I create some sort of menu structure like I've shown below?
> 
> Books
>   ->Non-fiction
>  ->History
>  ->Biographies
>   ->Technical
>   ->Fiction
> Movies
> Games
> 
> I'm a little worried that all the recursion could get painful from a 
> performance perspective & I figure this is a common enough situation 
> that maybe someone else already has something that works pretty well.

It's not too bad to do the obvious thing. I do something similar in the
sidebar of http://www.pointy-stick.com/blog/ and on
http://www.pointy-stick.com/blog/topics/ .

I'm not nearly as cool as Ian Holsman, so I don't have a version control
respository online. You can grab the source code from
http://www.pointy-stick.com/software/website-latest.tar.gz and have a
look, though. It's basically the recursion approach you are talking
about. Performance isn't too bad for "reasonable" levels of nesting.

Start at weblog/templatetags/mt_weblog.py (TagCloud.render, in
particular) and work back to the Tag model.

Once we get model-aware validators in place, I intend to switch to using
a slightly different encoding for tag sub-trees, as mentioned in the
comments in weblog/models.py, so I haven't worked too hard on making
this neat and spiffy yet as the "extract all tags" portion can be done
in a single query with a slightly different model setup.

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



About iServicePro

2006-07-13 Thread zw_sea

iServicePro is an innovative approach to offering affordable tools for
Java and J2EE developers. in particular, we are a professional team for
applying oneself to develop and integrate eclipse plug-in for user
applications.

Our mission now is to deliver business value and to maximize
developers' productivity by consistently delivering reliable products
and a true end-to-end seamless J2EE development environment.
iServicePro is the eclipse plug-in solution for all your UML, Web,
J2EE, JSP, XML, Struts, JSF, Hibernate and application server
integration needs.

We are committed to the success of your trial. If you need to see a
demonstration of Data Service or need assistance during the trial
process, please do not hesitate to contact us.

 www.iservicepro.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: Set up problems ( webfaction )

2006-07-13 Thread Iain Duncan


> in your apache config do something similar to
> http://svn.zyons.python-hosting.com/trunk/zilbo/conf/zyons.conf.tmpl
> 
> and that will let the apache handle the 'images' area of your site  
> instead of django.
> 
> On 14/07/2006, at 12:02 PM, Iain Duncan wrote:

Thanks Ian, got them working. I was actually thinking as I watched the (
very helpful ) screencast that it would be nice to have a link to the
files used. ;)

Now my only remaining hurdle ( db migration was surprisingly easy! ) is
those admin media files. I notice you have

alias /media/ /home2/bmg/django/django/contrib/admin/media/

and that you have loaded the alias module from
loadmodule alias_module /etc/httpd/modules/mod_alias.so

I tried this out with no apache complaints but still no admin media. The
docs suggest a link to the media files, but they don't say what that
link should be ( ie I don't know where django is looking for them! )
Any tips on that? I think maybe we should suggest to Remi to add
mod_alias to the stock modules set up in apache2/modules.

Thanks
Iain


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

2006-07-13 Thread Iain Duncan


> Now my only remaining hurdle ( db migration was surprisingly easy! ) is
> those admin media files. I notice you have
> 
> alias /media/ /home2/bmg/django/django/contrib/admin/media/
> 
> and that you have loaded the alias module from
> loadmodule alias_module /etc/httpd/modules/mod_alias.so
> 
> I tried this out with no apache complaints but still no admin media. The
> docs suggest a link to the media files, but they don't say what that
> link should be ( ie I don't know where django is looking for them! )
> Any tips on that? I think maybe we should suggest to Remi to add
> mod_alias to the stock modules set up in apache2/modules.

Got it! Wound up just copying the admin media directories into my media
directory. Pipe up if there's a better way ...

Thanks for the tips and the very useful screencast.

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



winpdb and django

2006-07-13 Thread Scott Chapman

I can run django under winpdb with no problem but I can't figure out how to 
do a set_trace() which makes the winpdb active. pdb.set_trace() makes pdb 
active in a text window. I'd love to make it make winpdb active instead. 
Anyone make this work?

I'd also like to know how to get it (winpdb) to load views.py so I might set a 
breakpoint there.  Any clues?

Scott


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

2006-07-13 Thread Carlos Yoder

Jorge, muchas gracias!

I have not got as close as a mile from manipulators yet, even though
they look pretty cool. I'll certainly save your code around for later.

Who would have thought my code was not that off-track as I thought! =)

Anyway, a big thank you for the time you took to write this, I really
appreciate it!!!

On 7/13/06, Jorge Gajon <[EMAIL PROTECTED]> wrote:
>
> Hi again Carlos,
>
> I suggested this change in your code:
> > results = Vozilo.objects.all()
> > if selected_model_id != 0:
> > results = results.filter(model_id__exact=selected_model_id)
> > if selected_gorivo_id != 0:
> > results.extend(results.filter(gorivo_id__exact=selected_gorivo_id))
> >
> But I'm totally wrong there. Your original code should be fine,
> because you were chaining the filters. The 'extends' is not necessary
> and in fact it is wrong.
>
> I also realized that the filter logic in the code that I proposed is
> wrong. With that code you would get a list of cars that match the
> specified model, along with all the cars that match the gorivo type
> (regardless of model).
>
> The correct thing is to chain the filters like you did in your
> original code. This should work, I tested it with a model I have here.
>
> results = Vozilo.objects.all()
> if model:
> results = results.filter(model=model)
> if gorivo:
> results = results.filter(gorivo=gorivo)
>
>
> I'm sorry if I caused any confusion and for not paying more attention
> to that filtering part :)
>
> Cheers,
> Jorge
>
>
>
> On 7/13/06, Jorge Gajon <[EMAIL PROTECTED]> wrote:
> > Hi Carlos,
> >
> > I think your code is going good so far. Of course I'm not a guru but I
> > think your code is fine. Is there something that you don't feel
> > comfortable with? With respect to adding the results of both filters,
> > you need to extend the results of the first results (if any), like
> > this:
> >
> > results = Vozilo.objects.all()
> > if selected_model_id != 0:
> > results = results.filter(model_id__exact=selected_model_id)
> > if selected_gorivo_id != 0:
> > results.extend(results.filter(gorivo_id__exact=selected_gorivo_id))
> >
> >
> >
> > If I were to code that view I would use a custom manipulator and it
> > would end up something like the following. But PLEASE, PLEASE, be
> > aware that it's just my personal way of doing things, I am no one to
> > tell you how to do things.
> >
> > class FilterResultsManipulator(forms.Manipulator):
> > def __init__(self):
> > model_choices = [(m.id, m) for m in Model.objects.all()]
> > gorivo_choices = [(g.id, g) for g in
> > Gorivo.objects.all().order_by('opis')]
> > self.fields = (
> > forms.SelectField(field_name='model', choices=model_choices),
> > forms.SelectField(field_name='gorivo', choices=gorivo_choices),
> > )
> >
> > def home(request):
> > results = []
> > filter_manipulator = FilterResultsManipulator()
> > filter_data = {}
> >
> > if request.POST:
> > filter_data = request.POST.copy()
> >
> > model = None
> > gorivo = None
> > if filter_data.get('model'):
> > model = get_object_or_404(Model, pk=filter_data['model'])
> > if filter_data.get('gorivo'):
> > gorivo = get_object_or_404(Gorivo, pk=filter_data['gorivo'])
> >
> > if model:
> > results = Vozilo.objects.filter(model=model)
> > if gorivo:
> > results.extend(Vozilo.objects.filter(gorivo=gorivo))
> > else:
> > results = Vozilo.objects.order_by('?')[:5]
> >
> > filter_form = forms.FormWrapper(filter_manipulator, filter_data, {})
> >
> > return render_to_response('cars/home.html', {
> > 'results': results,
> > 'filter_form': filter_form,
> > })
> >
> > And the template you only need to display the form fields.
> >
> > 
> > Search by:
> > Model: {{ filter_form.model }}
> > Gorivo: {{ filter_form.gorivo }}
> > 
> > 
> >
> >
> > The custom manipulator and associated form wrapper takes care of
> > displaying the select fields in your form and maintaining the selected
> > option between posted pages. The use of the utility
> > get_object_or_404() frees you of worrying if the incoming data is
> > invalid or malformed, if it is a 404 exception will be raised and the
> > user will get a 404 page.
> >
> > If you have questions about the above code feel free to ask.
> >
> > Cheers,
> > Jorge
> >
> >
> >
> > On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> > >
> > > Hello people, my ongoing adventures in firstdjangoappland continue thus:
> > >
> > > I'm putting together a simple search app for a car project. On entry,
> > > user sees a list of 5 random cars. He can use up to two comboboxes to
> > > filter the results (car model and fuel type).
> > >
> > > This is what I've come up with on my home() view, so far, and it looks
> > > really ugly.
> > >
> > > def home(request):
>