Re: Class Attribute in New Forms Input Elements

2007-11-20 Thread James Bennett

On 11/21/07, Cristian <[EMAIL PROTECTED]> wrote:
> I've been using the old forms for a while but I'm starting to move
> over to the new forms module. One difference that's annoying me is the
> lack of the class attribute in the input tags. I use the class tags in
> my CSS to change colors and widths. Is there a way to add those back
> in (without having to dig into the django code)?

The 'attrs' argument to the Widget class used with each particular
Field (the Widget is what actually renders the HTML) accepts a
dictionary which will become HTML attribute names and values. For
example:

username = forms.CharField(widget=forms.TextInput(attrs={'class': 'myclass'}))

will become:



-- 
"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: Different behaviour for url parameter in dev run versus test run

2007-11-20 Thread Manoj Govindan

I have raised a ticket for this problem.
http://code.djangoproject.com/ticket/5982

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



Class Attribute in New Forms Input Elements

2007-11-20 Thread Cristian

Hi,

I've been using the old forms for a while but I'm starting to move
over to the new forms module. One difference that's annoying me is the
lack of the class attribute in the input tags. I use the class tags in
my CSS to change colors and widths. Is there a way to add those back
in (without having to dig into the django code)?

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

2007-11-20 Thread cute

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



Re: weird "can't adapt" error

2007-11-20 Thread Michael

Thanks Thomas... your shot in the dark hit it's mark for me :)

I was suffering the same "can't adapt" psycopg2 error (worked fine
with sqlite), but it was due to the exact reason you stated.

Although your solution is probably better in the long run, another
solution is to simply convert the result of slugify into a normal
string (as slugify now returns a django.utils.safestring.SafeUnicode
object and the psycopg2 cursor cannot convert this to a string). For
example:

>>> from django.template import defaultfilters

>>> self.group_slug = defaultfilters.slugify(self.name)

becomes:
>>> self.group_slug = str(defaultfilters.slugify(self.name))

Thanks again! It's been causing me headaches...

On Nov 21, 2:55 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> This is just a shot in the dark, but I just solved a similar problem
> that just popped up for me.
>
> I noticed that you are creating slugs for your object near where the
> error happens.  I had the exact same error happen when creating
> slugified names.  It turned out that I was calling the built-in
> slugify() filter in django.template.defaultfilters. This code changed
> significantly as a part of the autoescaping code that was checked in
> starting with r6671.  I didn't investigate all the way to finding out
> what part of the filter code was causing the issue, I just solved it
> by taking the regex logic out of the filter and putting it in my own
> slugify() method.
>
> I was running off the trunk (r6708) with psycopg2.
>
> Hope this helps,
> -Thomas
>
> On Nov 20, 4:17 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> > OK, filed a ticket, but really I do not have any idea as what might be
> > "usable information" in this case, just copied what I posted here.
> > What makes me thinking there's a bug somewhere, is that the code works
> > for psycopg and sqlite3, but fails for psycopg2.
>
> > On 20 Lis, 22:06, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:> "Can't adapt" 
> > is quite a vague error that psycopg2 issues.
>
> > > Your issue is (apparently) something to do with encoding, and that's
> > > different than Sandro's issue.
>
> > > Please include more information, especially if you do decide to file a
> > > ticket.  I can't help with the info given so far...
>
> > > On Nov 20, 2007 2:55 PM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> > > > The problem in my case seems to be strictly related to psycopg2
> > > > backend. I tried with psycopg and it does not happens.
>
> > > > Should I file a ticket?
>
> > > > On 20 Lis, 10:17, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > > > > I just started receiving the same problem when I try to save an object
> > > > > that has non-ASCII values in char field (the values are all properly
> > > > > decoded to unicode)> This seems related to psycopg2 backend, as I do
> > > > > not observe such behaviour on my dev server with sqlite3 backend. The
> > > > > model is similar to:
>
> > > > > class Label(models.Model):
> > > > > title = models.CharField(max_length=200, unique=True)
>
> > > > > the code that leads to exception is like:
>
> > > > > t = 'żołędzie'.decode('utf-8')
> > > > > label = Label(title=t)
> > > > > label.save()
>
> > > > > The traceback from ipython:
>
> > > > > /home/zgoda/www/zgodowie/blog/models.py in save(self)
> > > > >  42 if not self.slug:
> > > > >  43 self.slug = slughifi(self.title)
> > > > > ---> 44 super(Label, self).save()
> > > > >  45
> > > > >  46
>
> > > > > /home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
> > > > > base.py in save(self, raw)
> > > > > 257 cursor.execute("INSERT INTO %s (%s) VALUES
> > > > > (%s)" % \
> > > > > 258 (qn(self._meta.db_table),
> > > > > ','.join(field_names),
> > > > > --> 259 ','.join(placeholders)), db_values)
> > > > > 260 else:
> > > > > 261 # Create a new record with defaults for
> > > > > everything.
>
> > > > > ProgrammingError: can't adapt
>
> > > > > I use SVN trunk rev. 6702.
>
> > > > > On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
>
> > > > > > On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Hi,
>
> > > > > > >   I'm meeting a weird problem in adjangoapplication.
> > > > > > >   It works w/o any problem from my pc connecting remotely to my 
> > > > > > > customer's
> > > > > > >   apache but is not working inside the lan.
>
> > > > > > >   I'm connecting from firefox/ubuntu they're connecting from 
> > > > > > > firefox/XP.
>
> > > > > > >   the weird part is that:
>
> > > > > > > 1. they have being working w/o probelms for 10 days and no 
> > > > > > > modifications
> > > > > > >where made
>
> > > > > > > 2. the error complains "can'tadapt" as if trying to insert 
> > > > > > > wrong types
> > > > > > >into the db, but the error trace shows the values are 
> > > > > > > correct
>
> > > > > > > 3. a 

Re: starting point?

2007-11-20 Thread gmacgregor

On Nov 20, 3:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> thanks! hopefully my webhoster allows all the needed .htaccess stuff.
> but it sounds promising...
>
> how can i figure out if my webhoster uses fastcgi? can this info be
> printed with a simple script?

Take a look at the documentation surrounding your plan details and if
that fails then contact support... FYI, a list pf Django friendly web
hosts can be found here:

http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Python Question - How to show the last few elements in a list

2007-11-20 Thread Greg

Todd,
Yep..it worked.  request.session['prod'][-7:].

Thanks

On Nov 20, 9:56 pm, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> Have you tried request.session['prod'][-7:] ?
>
> If that doesn't work, try list(request.session['prod'])[-7:]
>
> Todd
>
> On Nov 20, 2007 10:52 PM, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hello,
> > I have a session variable.  Whenever anybody adds a product to this
> > session variable it gets stored like so:
>
> > request.session['prod'].append(b)
>
> > This can make my session variable look like this:
>
> > [, , , ]
>
> > //
>
> > I want to show the last 7 elements in my list,  Occassionally my list
> > will only contain less than 7 elements...like above.  So in this case
> > only 4 elements will be shown.  However, I'm getting errors with how I
> > currently have it setup:
>
> > request.session['prod'][len(request.session['prod']) -
> > 6:len(request.session['prod'])]
>
> > It doesn't work correctly when I have less than 7 elements in the
> > list.  I guess it's because I have
>
> > 'len(request.session['prod']) - 6'
>
> > ///
>
> > Does anybody know how I can show the last 7 elements in my list, and
> > if my list has less than 7 elements then it shows all of the elements?- 
> > 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: Python Question - How to show the last few elements in a list

2007-11-20 Thread Todd O'Bryan

Have you tried request.session['prod'][-7:] ?

If that doesn't work, try list(request.session['prod'])[-7:]

Todd

On Nov 20, 2007 10:52 PM, Greg <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I have a session variable.  Whenever anybody adds a product to this
> session variable it gets stored like so:
>
> request.session['prod'].append(b)
>
> This can make my session variable look like this:
>
> [, , , ]
>
> //
>
> I want to show the last 7 elements in my list,  Occassionally my list
> will only contain less than 7 elements...like above.  So in this case
> only 4 elements will be shown.  However, I'm getting errors with how I
> currently have it setup:
>
> request.session['prod'][len(request.session['prod']) -
> 6:len(request.session['prod'])]
>
> It doesn't work correctly when I have less than 7 elements in the
> list.  I guess it's because I have
>
> 'len(request.session['prod']) - 6'
>
> ///
>
> Does anybody know how I can show the last 7 elements in my list, and
> if my list has less than 7 elements then it shows all of the elements?
> >
>

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

2007-11-20 Thread [EMAIL PROTECTED]

This is just a shot in the dark, but I just solved a similar problem
that just popped up for me.

I noticed that you are creating slugs for your object near where the
error happens.  I had the exact same error happen when creating
slugified names.  It turned out that I was calling the built-in
slugify() filter in django.template.defaultfilters. This code changed
significantly as a part of the autoescaping code that was checked in
starting with r6671.  I didn't investigate all the way to finding out
what part of the filter code was causing the issue, I just solved it
by taking the regex logic out of the filter and putting it in my own
slugify() method.

I was running off the trunk (r6708) with psycopg2.

Hope this helps,
-Thomas


On Nov 20, 4:17 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> OK, filed a ticket, but really I do not have any idea as what might be
> "usable information" in this case, just copied what I posted here.
> What makes me thinking there's a bug somewhere, is that the code works
> for psycopg and sqlite3, but fails for psycopg2.
>
> On 20 Lis, 22:06, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:> "Can't adapt" is 
> quite a vague error that psycopg2 issues.
>
> > Your issue is (apparently) something to do with encoding, and that's
> > different than Sandro's issue.
>
> > Please include more information, especially if you do decide to file a
> > ticket.  I can't help with the info given so far...
>
> > On Nov 20, 2007 2:55 PM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> > > The problem in my case seems to be strictly related to psycopg2
> > > backend. I tried with psycopg and it does not happens.
>
> > > Should I file a ticket?
>
> > > On 20 Lis, 10:17, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > > > I just started receiving the same problem when I try to save an object
> > > > that has non-ASCII values in char field (the values are all properly
> > > > decoded to unicode)> This seems related to psycopg2 backend, as I do
> > > > not observe such behaviour on my dev server with sqlite3 backend. The
> > > > model is similar to:
>
> > > > class Label(models.Model):
> > > > title = models.CharField(max_length=200, unique=True)
>
> > > > the code that leads to exception is like:
>
> > > > t = 'żołędzie'.decode('utf-8')
> > > > label = Label(title=t)
> > > > label.save()
>
> > > > The traceback from ipython:
>
> > > > /home/zgoda/www/zgodowie/blog/models.py in save(self)
> > > >  42 if not self.slug:
> > > >  43 self.slug = slughifi(self.title)
> > > > ---> 44 super(Label, self).save()
> > > >  45
> > > >  46
>
> > > > /home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
> > > > base.py in save(self, raw)
> > > > 257 cursor.execute("INSERT INTO %s (%s) VALUES
> > > > (%s)" % \
> > > > 258 (qn(self._meta.db_table),
> > > > ','.join(field_names),
> > > > --> 259 ','.join(placeholders)), db_values)
> > > > 260 else:
> > > > 261 # Create a new record with defaults for
> > > > everything.
>
> > > > ProgrammingError: can't adapt
>
> > > > I use SVN trunk rev. 6702.
>
> > > > On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
>
> > > > > On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi,
>
> > > > > >   I'm meeting a weird problem in adjangoapplication.
> > > > > >   It works w/o any problem from my pc connecting remotely to my 
> > > > > > customer's
> > > > > >   apache but is not working inside the lan.
>
> > > > > >   I'm connecting from firefox/ubuntu they're connecting from 
> > > > > > firefox/XP.
>
> > > > > >   the weird part is that:
>
> > > > > > 1. they have being working w/o probelms for 10 days and no 
> > > > > > modifications
> > > > > >where made
>
> > > > > > 2. the error complains "can'tadapt" as if trying to insert 
> > > > > > wrong types
> > > > > >into the db, but the error trace shows the values are correct
>
> > > > > > 3. a restart of apache fixes the problem
>
> > > > > > 4. this is the second time the error happens...
>
> > > > > >   Any hints?
> > > > > >   TIA
> > > > > >   sandro
> > > > > >   *:-)
>
> > > > > Hi,
>
> > > > >   once again I stumble into this problem. This time I gathered some
> > > > > more
> > > > >   info so I describe them.
>
> > > > >   I try to insert a record it fails from a Windows pc with Firefox
> > > > > (and
> > > > >   IE). It works from linux (firefox or galeon).
>
> > > > >   When it fails the error message is "can't adapt" but
>
> > > > >   1. the params in the log are:
> > > > >   ('2007-10-26 08:50:03.651993', '2007-10-26 08:50:03.652039', 1, 17,
> > > > >   '2007-10-26', u'2', Decimal("100"), 'h', u'prova in fi'
>
> > > > >   2. from my linux box I print params before a *working* insert and I
> > > > > get:
> > > > >   ['2007-10-26 09:17:44.744656', '2007-10-26 09:17:44.744682', 1, 17,
> > > > > '2007-10-26', 

Python Question - How to show the last few elements in a list

2007-11-20 Thread Greg

Hello,
I have a session variable.  Whenever anybody adds a product to this
session variable it gets stored like so:

request.session['prod'].append(b)

This can make my session variable look like this:

[, , , ]

//

I want to show the last 7 elements in my list,  Occassionally my list
will only contain less than 7 elements...like above.  So in this case
only 4 elements will be shown.  However, I'm getting errors with how I
currently have it setup:

request.session['prod'][len(request.session['prod']) -
6:len(request.session['prod'])]

It doesn't work correctly when I have less than 7 elements in the
list.  I guess it's because I have

'len(request.session['prod']) - 6'

///

Does anybody know how I can show the last 7 elements in my list, and
if my list has less than 7 elements then it shows all of the elements?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



case errors in transition to OSX

2007-11-20 Thread [EMAIL PROTECTED]

Hi,

I just transitions development machines from Ubuntu to OS X.

I noted that urls weren't processing correctly.

For example, domain.com/createAccount would show an error in the
debugging output because createaccount matched none of the patterns in
urls.py. Somewhere along the lines, the url was moved to lower case.

I'm using lighttpd. Perhaps something with mod_rewrite? Nothing I can
see.

I've temporarily solve the problem by wrapping each of the patterns in
this function:
import re
def noCase(s):
# re.I option ignores case
return re.compile(s, re.I)

This seems like a kludge. As another thread in the django group
observed, urls should be specific strings. Incorrect cases should be
auto-forwarded to the correct case.

Thoughts?

Possible causes?

Thanks,
Ivan Kirigin

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

2007-11-20 Thread Marty Alchin

On 11/20/07, Vance Dubberly <[EMAIL PROTECTED]> wrote:
>
> Before it's saved to a file...  that would be tricky.
>
> But this might get you started: http://www.clamav.net/ .  It'll run a
> daemon though I don't know if it opens sockets or ports...

If there are Python bindings for it, the upcoming filestorage changes
might actually make it very easy to integrate something like this.
I'll take a look around and see what I can find, but my findings won't
really be useful until the filestorage stuff lands in trunk.

-Gul

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



Re: File upload virus scanning

2007-11-20 Thread Marty Alchin

For the record, pyClamd[1] does look promising, as it supports
scanning streams as well as files. Even before the filestorage stuff
lands, you might want to check it out.

-Gul

[1] http://xael.org/norman/python/pyclamd/

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

2007-11-20 Thread Don Arbow

On Nov 20, 2007, at 3:18 PM, Jeremy Dunck wrote:
>
> On Nov 20, 2007 3:26 PM, hajo <[EMAIL PROTECTED]> wrote:
>>
>> Thanks a lot; will defintely look into this one!
>> The other solution I looked at was to send an address to google (We
>> have a commercial deal with them; I work for a failry large
>> newspaper); get it geocoded and then go from there... The issue here
>> is one of time...
>
> Time to implement, or run-time?  Implementing is not that hard...
> http://www.google.com/uds/solutions/localsearch/reference.html



Perl has a nice library, Geo-StreetAddress, that does some parsing and  
normalization. I looked at porting it to Python, but it has some crazy  
regex code in it. You should be able to call it from Django.

The page below has some other options (like scraping the US Postal  
Service website).

http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/US.pm

Don

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

2007-11-20 Thread Vance Dubberly

Before it's saved to a file...  that would be tricky.

But this might get you started: http://www.clamav.net/ .  It'll run a
daemon though I don't know if it opens sockets or ports...

Vance

On Nov 20, 2007 2:22 PM, leifbyron <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> Is anyone aware of a command-line tool that can be used to scan file
> uploads for viruses before they are saved to a file? I know this is
> not specifically a Django question, but I'm sure a lot of people would
> find the answer useful.
>
> Thanks,
> Leif
>
>
>
> >
>



-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida

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

2007-11-20 Thread Julien

Thanks again Kamil for your help!

Ok, now I'm trying to put everything together. Sorry I'm just starting
with Django and I am still a bit lost.

What I am not sure about is:
- where to put the view?
- how to hook the view to the model
- how to hook the template with the view.

Could you provide a full example, based on the summarization below?

Thanks a lot!


models.py:
---

class Country(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Admin:
pass

class City(models.Model):
name = models.CharField(max_length=50)
country = models.ForeignKey(Country)
def __unicode__(self):
return self.name
class Admin:
pass

class Person(models.Model):
firstName = models.CharField(max_length=30)
lastName = models.CharField(max_length=30)
citiesLived = models.ManyToManyField(City, null=True, blank=True)
def __unicode__(self):
return self.firstName + " " + self.lastName
class Admin:
js = "http://mysite.com/custom_widget.js;


custom_widget.html (template)
--

var countries = {
{% regroup cities by country as grouped %}
{% for group in grouped %}
"{{ group.grouper.name }}: [
{% for city in group.list %}
'{{city.name}}' ,
{% endfor %}  ]
{% endfor %}

}


custom_widget.js


var countries = {'england': ['London','Manchester'], 'france':
['Paris'] }

document.forms['your_form'].id_country.onchange = function()
{ listCities(this.value) };

function listCities ( country ) {
document.forms['your_form'].id_city.options.length = 0
var l = countries[ country ].length;
for (var i = 0; l > i; i++) {
document.forms['your_form'].id_city.options[i] = new
Option( countries[ country ][i], countries[ country ][i]);
}

}



On Nov 21, 11:06 am, kamil <[EMAIL PROTECTED]> wrote:
> You would achieve it using "regroup" template tag
> First get cities in your view
> and create template with code:
>
> var countries = {
> {% regroup cities by country as grouped %}
> {% for group in grouped %}
> "{{ group.grouper.name }}: [
> {% for city in group.list %}
> '{{city.name}}' ,
> {% endfor %}  ]
> {% endfor %}
>
> }
>
> (If it dosnt work straigt away just look at  "regroup" template tag in
> the docs - idea is there)
>
> add url of this template to js list in model admin code and thats
> all :)
>
> On Nov 20, 11:54 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > When I look at the html source code generated for the regular
> > ManyToManyField's widget, it's an html form, not javascript...
> > Are you sure there is no other way?
>
> > Could you please give a full example?
>
> > I've spent quite sometime practicing with the tutorials but I'm a bit
> > lost on this one.
>
> > Thanks a lot!
>
> > On Nov 20, 9:04 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > > I dont think there is another way that making your hands dirty with
> > > javascript. ;)
> > > If you want to be fancy you can even make it ajax - getting the cities
> > > on demand
>
> > > On Nov 20, 9:35 am, kamil <[EMAIL PROTECTED]> wrote:
>
> > > > You can easily generate cities list to the javascript dynamically
> > > > writing the template for separate js file.
>
> > > > On Nov 20, 9:22 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Kamil,
>
> > > > > Thanks a lot for your suggestion!
>
> > > > > I have a few remarks though. The list of cities is dynamic, in the
> > > > > sense that you may add, remove cities from the database at any time
> > > > > using the admin interface.
> > > > > So how can we fetch dynamically the list of available cities to
> > > > > display them in the select widget?
>
> > > > > Also, isn't there a "recommended" way of doing? Hijacking with
> > > > > javascript seems more like a trick. I may be wrong.
>
> > > > > Thanks!  ;)
>
> > > > > On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi Julien
>
> > > > > > The simple way is hijack city select box with javascript.
> > > > > > You add
> > > > > > js=['http://herecomespathtoyourscript']
> > > > > > to admin options in your model
> > > > > > js can look like this:
>
> > > > > > var countries = {'england': ['London','Manchester'], 'france':
> > > > > > ['Paris'] }
>
> > > > > > document.forms['your_form'].id_country.onchange = function()
> > > > > > { listCities(this.value) };
>
> > > > > > function listCities ( country ) {
> > > > > > document.forms['your_form'].id_city.options.length = 0
> > > > > > var l = countries[ country ].length;
> > > > > > for (var i = 0; l > i; i++) {
> > > > > > document.forms['your_form'].id_city.options[i] = new
> > > > > > Option( countries[ country ][i], countries[ country ][i]);
> > > > > > 

Re: Custom ManyToManyField widget in admin

2007-11-20 Thread kamil

You would achieve it using "regroup" template tag
First get cities in your view
and create template with code:

var countries = {
{% regroup cities by country as grouped %}
{% for group in grouped %}
"{{ group.grouper.name }}: [
{% for city in group.list %}
'{{city.name}}' ,
{% endfor %}  ]
{% endfor %}
}


(If it dosnt work straigt away just look at  "regroup" template tag in
the docs - idea is there)

add url of this template to js list in model admin code and thats
all :)

On Nov 20, 11:54 am, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When I look at the html source code generated for the regular
> ManyToManyField's widget, it's an html form, not javascript...
> Are you sure there is no other way?
>
> Could you please give a full example?
>
> I've spent quite sometime practicing with the tutorials but I'm a bit
> lost on this one.
>
> Thanks a lot!
>
> On Nov 20, 9:04 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > I dont think there is another way that making your hands dirty with
> > javascript. ;)
> > If you want to be fancy you can even make it ajax - getting the cities
> > on demand
>
> > On Nov 20, 9:35 am, kamil <[EMAIL PROTECTED]> wrote:
>
> > > You can easily generate cities list to the javascript dynamically
> > > writing the template for separate js file.
>
> > > On Nov 20, 9:22 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Kamil,
>
> > > > Thanks a lot for your suggestion!
>
> > > > I have a few remarks though. The list of cities is dynamic, in the
> > > > sense that you may add, remove cities from the database at any time
> > > > using the admin interface.
> > > > So how can we fetch dynamically the list of available cities to
> > > > display them in the select widget?
>
> > > > Also, isn't there a "recommended" way of doing? Hijacking with
> > > > javascript seems more like a trick. I may be wrong.
>
> > > > Thanks!  ;)
>
> > > > On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Julien
>
> > > > > The simple way is hijack city select box with javascript.
> > > > > You add
> > > > > js=['http://herecomespathtoyourscript']
> > > > > to admin options in your model
> > > > > js can look like this:
>
> > > > > var countries = {'england': ['London','Manchester'], 'france':
> > > > > ['Paris'] }
>
> > > > > document.forms['your_form'].id_country.onchange = function()
> > > > > { listCities(this.value) };
>
> > > > > function listCities ( country ) {
> > > > > document.forms['your_form'].id_city.options.length = 0
> > > > > var l = countries[ country ].length;
> > > > > for (var i = 0; l > i; i++) {
> > > > > document.forms['your_form'].id_city.options[i] = new
> > > > > Option( countries[ country ][i], countries[ country ][i]);
> > > > > }
>
> > > > > }
>
> > > > > I hope it helps :)
>
> > > > > On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > > Sorry, my "drawing" came out a bit funny in my previous post. Here's
> > > > > > what I'd like the custom widget to look like:
>
> > > > > > England
> > > > > > [  ] London   [  ] Manchester
> > > > > > France
> > > > > > [  ] Paris
> > > > > > Russia
> > > > > > [  ] Moscow
> > > > > > USA
> > > > > > [  ] Los Angeles   [  ] New York
>
> > > > > > Thanks for your help!
>
> > > > > > On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Hi all,
>
> > > > > > > I'm a Django newbie, and I've been struggling on this for days. 
> > > > > > > I've
> > > > > > > also found posts on this group about similar subjects but none 
> > > > > > > that
> > > > > > > could directly help me...
>
> > > > > > > Here are the models I've got:
>
> > > > > > > class Country(models.Model):
> > > > > > > name = models.CharField(max_length=50)
> > > > > > > def __unicode__(self):
> > > > > > > return self.name
> > > > > > > class Admin:
> > > > > > > pass
>
> > > > > > > class City(models.Model):
> > > > > > > name = models.CharField(max_length=50)
> > > > > > > country = models.ForeignKey(Country)
> > > > > > > def __unicode__(self):
> > > > > > > return self.name
> > > > > > > class Admin:
> > > > > > > pass
>
> > > > > > > class Person(models.Model):
> > > > > > > firstName = models.CharField(max_length=30)
> > > > > > > lastName = models.CharField(max_length=30)
> > > > > > > citiesLived = models.ManyToManyField(City, null=True, 
> > > > > > > blank=True)
> > > > > > > def __unicode__(self):
> > > > > > > return self.firstName + " " + self.lastName
> > > > > > > class Admin:
> > > > > > > pass
>
> > > > > > > In the admin interface, when adding cities to a person's profile, 
> > > > > > > you
> > > > > > > get the usual ManyToMany select box.
>
> > > > > > > So you may have:
> > > > > > > New York
> > > > > > > Manchester
> > > > > > > Paris
> > > > > > > London
> > > > > > > Moscow

question about list_display

2007-11-20 Thread Lucemia

hello every one:

I have a simple question about list_display feature of Django's admin
site

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

class
Person(models.Model):
first_name =
models.CharField(max_length=50)
color_code =
models.CharField(max_length=6)

class
Admin:
list_display = ('first_name',
'colored_first_name')

def
colored_first_name(self):
return '%s'
%
(self.color_code,
self.first_name)
colored_first_name.allow_tags =
True
colored_first_name.admin_order_field = 'first_name'

It is about how to use color in list_display.
When i use it, I didn't correctly get the colored field of
first_name.
Only get strings like '%s'  in this
field.
Is there anything I misunderstand to make it work correctly?

thanks

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



Re: Freenode and django related channels

2007-11-20 Thread Kenneth Gonsalves


On 20-Nov-07, at 10:01 PM, ikks wrote:

> freenode, it's called #django-es , I would like to know if someone
> nicknamed dashinho is on the list

he was regular on english IRC channel about a year back

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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



Re: Street address normalisation

2007-11-20 Thread Jeremy Dunck

On Nov 20, 2007 3:26 PM, hajo <[EMAIL PROTECTED]> wrote:
>
> Thanks a lot; will defintely look into this one!
> The other solution I looked at was to send an address to google (We
> have a commercial deal with them; I work for a failry large
> newspaper); get it geocoded and then go from there... The issue here
> is one of time...

Time to implement, or run-time?  Implementing is not that hard...
http://www.google.com/uds/solutions/localsearch/reference.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: Django rocks: Key Ingredient

2007-11-20 Thread gordyt

Very nice site Jesse!

Just created an account and posted my first recipe.

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



Re: using make-messages in native non-english site

2007-11-20 Thread Malcolm Tredinnick


On Tue, 2007-11-20 at 14:20 -0800, shaunc wrote:
> Can I use make-messages to create english translation files for a site
> that is originally written in something other than english? I don't
> see how the "source" language is specified.

There's not really a concept of "source language" with gettext. Instead,
the strings you mark for translation are included verbatim in the PO
file (where they are called msgids). Your translators must be able to
read the msgid stringsto translate it, but that's the only requirement.

Regards,
Malcolm

-- 
Telepath required. You know where to apply... 
http://www.pointy-stick.com/blog/


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



Re: How to access method parameters

2007-11-20 Thread keithb

getattr returns a function, so you want to be sure to call it before
calling split.

var2 = var().split('\\')[1]

-keithb

Greg wrote:
> I tired doing that.  However I guess the end result for var is
> different for each way:
>
> var = getattr(self, 'get_%s_filename' % shape)
> var = self.get_round_filename()
>
> 
>
> Because, after I assign var I do the following:
>
> var2 = var.split('\\')[1]
>
> 
>
> When I use 'var = getattr(self, 'get_%s_filename' % shape)' I then get
> the following error:
>
> AttributeError at /admin/plush/photo/add/
> 'function' object has no attribute 'split'
>
>
>
>
> On Nov 20, 9:37 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > > self.create(50, 50, "round")
> >
> > > def create(self, wsize, hsize, shape):
> > > var = self.get_shape_filename()
> > > etc
> >
> > > ///
> >
> > > I get an error whenever it hits the line 'var =
> > > self.get_shape_filename()'.  The error is:
> >
> > > object has no attribute 'get_shape_filename'
> >
> > > 
> >
> > > In the above case I'm sending 'round' to the method.  So it's supposed
> > > to be get_round_filename.
> >
> > Sounds like you're looking for the getattr() call in the standard
> > library...something like
> >
> >get_filename = getattr(self,
> >  'get_%s_filename' % shape)
> >var = get_filename()
> >
> > -tim- 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: How to access method parameters

2007-11-20 Thread Greg

I tired doing that.  However I guess the end result for var is
different for each way:

var = getattr(self, 'get_%s_filename' % shape)
var = self.get_round_filename()



Because, after I assign var I do the following:

var2 = var.split('\\')[1]



When I use 'var = getattr(self, 'get_%s_filename' % shape)' I then get
the following error:

AttributeError at /admin/plush/photo/add/
'function' object has no attribute 'split'




On Nov 20, 9:37 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > self.create(50, 50, "round")
>
> > def create(self, wsize, hsize, shape):
> > var = self.get_shape_filename()
> > etc
>
> > ///
>
> > I get an error whenever it hits the line 'var =
> > self.get_shape_filename()'.  The error is:
>
> > object has no attribute 'get_shape_filename'
>
> > 
>
> > In the above case I'm sending 'round' to the method.  So it's supposed
> > to be get_round_filename.
>
> Sounds like you're looking for the getattr() call in the standard
> library...something like
>
>get_filename = getattr(self,
>  'get_%s_filename' % shape)
>var = get_filename()
>
> -tim- 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
-~--~~~~--~~--~--~---



File upload virus scanning

2007-11-20 Thread leifbyron

Hi there,

Is anyone aware of a command-line tool that can be used to scan file
uploads for viruses before they are saved to a file? I know this is
not specifically a Django question, but I'm sure a lot of people would
find the answer useful.

Thanks,
Leif



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



using make-messages in native non-english site

2007-11-20 Thread shaunc

Can I use make-messages to create english translation files for a site
that is originally written in something other than english? I don't
see how the "source" language is specified.

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

2007-11-20 Thread Jarek Zgoda

OK, filed a ticket, but really I do not have any idea as what might be
"usable information" in this case, just copied what I posted here.
What makes me thinking there's a bug somewhere, is that the code works
for psycopg and sqlite3, but fails for psycopg2.

On 20 Lis, 22:06, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> "Can't adapt" is quite a vague error that psycopg2 issues.
>
> Your issue is (apparently) something to do with encoding, and that's
> different than Sandro's issue.
>
> Please include more information, especially if you do decide to file a
> ticket.  I can't help with the info given so far...
>
> On Nov 20, 2007 2:55 PM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
>
>
> > The problem in my case seems to be strictly related to psycopg2
> > backend. I tried with psycopg and it does not happens.
>
> > Should I file a ticket?
>
> > On 20 Lis, 10:17, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > > I just started receiving the same problem when I try to save an object
> > > that has non-ASCII values in char field (the values are all properly
> > > decoded to unicode)> This seems related to psycopg2 backend, as I do
> > > not observe such behaviour on my dev server with sqlite3 backend. The
> > > model is similar to:
>
> > > class Label(models.Model):
> > > title = models.CharField(max_length=200, unique=True)
>
> > > the code that leads to exception is like:
>
> > > t = 'żołędzie'.decode('utf-8')
> > > label = Label(title=t)
> > > label.save()
>
> > > The traceback from ipython:
>
> > > /home/zgoda/www/zgodowie/blog/models.py in save(self)
> > >  42 if not self.slug:
> > >  43 self.slug = slughifi(self.title)
> > > ---> 44 super(Label, self).save()
> > >  45
> > >  46
>
> > > /home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
> > > base.py in save(self, raw)
> > > 257 cursor.execute("INSERT INTO %s (%s) VALUES
> > > (%s)" % \
> > > 258 (qn(self._meta.db_table),
> > > ','.join(field_names),
> > > --> 259 ','.join(placeholders)), db_values)
> > > 260 else:
> > > 261 # Create a new record with defaults for
> > > everything.
>
> > > ProgrammingError: can't adapt
>
> > > I use SVN trunk rev. 6702.
>
> > > On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
>
> > > > On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi,
>
> > > > >   I'm meeting a weird problem in adjangoapplication.
> > > > >   It works w/o any problem from my pc connecting remotely to my 
> > > > > customer's
> > > > >   apache but is not working inside the lan.
>
> > > > >   I'm connecting from firefox/ubuntu they're connecting from 
> > > > > firefox/XP.
>
> > > > >   the weird part is that:
>
> > > > > 1. they have being working w/o probelms for 10 days and no 
> > > > > modifications
> > > > >where made
>
> > > > > 2. the error complains "can'tadapt" as if trying to insert wrong 
> > > > > types
> > > > >into the db, but the error trace shows the values are correct
>
> > > > > 3. a restart of apache fixes the problem
>
> > > > > 4. this is the second time the error happens...
>
> > > > >   Any hints?
> > > > >   TIA
> > > > >   sandro
> > > > >   *:-)
>
> > > > Hi,
>
> > > >   once again I stumble into this problem. This time I gathered some
> > > > more
> > > >   info so I describe them.
>
> > > >   I try to insert a record it fails from a Windows pc with Firefox
> > > > (and
> > > >   IE). It works from linux (firefox or galeon).
>
> > > >   When it fails the error message is "can't adapt" but
>
> > > >   1. the params in the log are:
> > > >   ('2007-10-26 08:50:03.651993', '2007-10-26 08:50:03.652039', 1, 17,
> > > >   '2007-10-26', u'2', Decimal("100"), 'h', u'prova in fi'
>
> > > >   2. from my linux box I print params before a *working* insert and I
> > > > get:
> > > >   ['2007-10-26 09:17:44.744656', '2007-10-26 09:17:44.744682', 1, 17,
> > > > '2007-10-26', u'2', Decimal("100"), 'h', u'prova']
>
> > > >Not realy different
>
> > > >   3. When it fails the database is not hit. Db is postgres and I
> > > > switched on
> > > >  statement log on every log:
>
> > > >  log_min_duration_statement = 0
>
> > > >   4. If I restart apache the error is fixed
>
> > > >   I'm running mod_wsgi
>
> > > > What should I do, next time it happens to better investigate. It's
> > > > already
> > > > happened 4 times in 2 months and I cannot just accept it...
>
> > > > Thanks for any possible help
>
> > > > sandro
> > > > *:-)
>
> > > > the insert statement that worked follows:
>
> > > > INSERT INTO
> > > > "timereport_report" 
> > > > ("date_create","date_last_modify","status","user_id","date","job_id","qty","unit","description")
> > > > VALUES ('2007-10-26 10:09:07.721575','2007-10-26 10:09:07.721619',
> > > > 1,17,'2007-10-26','2',100,'h','prova in fi2')

Re: Complicated question

2007-11-20 Thread Grupo Django

On 20 nov, 21:54, RajeshD <[EMAIL PROTECTED]> wrote:
> > That's interesting, but I think that leaving the models untouched
> > would be better.
> > Do you think there is a different way?
>
> There might be. First, you'd have to explain what you didn't like
> about doing queries like:
>
> Image.objects.filter( book__library_owner=request.user)
>
> Since you don't want to change your models, only your Library model
> maintains the source of ownership and so, by definition, all your
> queries would have to lead to a check on the Library.owner field
> thereby ending up with filters like xyz__library_owner=some_user.

Is not that I don't want to use:
Image.objects.filter( book__library_owner=request.user)
but I can't use it if I want to create a generic funtion, because
depending of the distance from the model to the model who has the
owner field, it can be:
Image.objects.filter( book__library_owner=request.user) or
Book.objects.filter( library_owner=request.user)
I pass the module to the function:
very roughly:
def list_items_by_owner( module, parent_id ):
for field in module._meta.fields:
 if field.name == 'owner':
 return True
for field in module._meta.fields:
   if field.rel and not field.null:
   parent = field.rel.to
   new_parent_id
   out = list_items_by_owner( parent,  new_parent_id)
   ...

Anyway, what I'm trying to get is quite complicated and the code above
is not correct at all, it was only for trying to explain what I want.
I think I need somethig similar to django.db.query.fill_table_cache
but I'm not sure.

This could be used as a row-level permissions. it has some
inconvenient because depending on the number of ForeignKeys, the
recursive function might take longer.

I'm pretty sure I didn't explain myself clear, I do my best :-)

Thank you.


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



Re: how fixtures can be load in django tests?

2007-11-20 Thread michel bruavics



On 20 Nov., 17:37, "Joseph Kocherhans" <[EMAIL PROTECTED]> wrote:
> On 11/20/07, michel bruavics <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi djangos,
>
> > I check out the django.test.client and want to load a fixture file
> > called "myfixture.xml".
>
> > I added in my project setting a folder (called fixtures):
> > FIXTURE_DIRS = ('/workspace/project/fixtures/')
>
> > myfixture.xml is inside of the folder fixtures.
>
> > now I try to load the fixture in my tests.py:
>
> > class TestSurfer(unittest.TestCase):
> > fixtures = ['myfixture.xml']
> > 
>
> > But it doesn't load the fixture.
> > I try other names, other places but nothing works for me. I only can
> > load a file when it's named "initial_data.xml".
>
> You need to use django.test.TestCase, not unittest.TestCase. The
> latter knows nothing about fixtures. :)


upss, copyed and pasted the line from a other test file, sorry for me
blindness :)

thanks, regards michel


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



Re: Street address normalisation

2007-11-20 Thread hajo

Thanks a lot; will defintely look into this one!
The other solution I looked at was to send an address to google (We
have a commercial deal with them; I work for a failry large
newspaper); get it geocoded and then go from there... The issue here
is one of time...

Hajo

On Nov 20, 12:38 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I have an issue with users doing a lookup on street address.
> [snip]
> > This seems like asuch a common problem; are there any
> > libraries for this; what is the "correct" way to handle this?
> > How do google; Mapquest and Yahoo do this? (I don't have quite
> > their resources; but it would point me in the right
> > direction...)
>
> One common Python solution is to snag PyParsing and extend their
> streetAddressParser.py example
>
> http://pyparsing.wikispaces.com/Examples
>
> There are some holes in it (most notably "rd" missing from the
> numberSuffix definition, but the cardinal directions may need
> expansion too from just "N S E W" to include "NW SW NE SW"), but
> it should get you pointed in the right direction and be fairly
> easily extensible.
>
> I've tried with regexps, and it gets *really ugly*.
>
> An alternative might be using the USPS website (or ERSI, Google,
> or Yahoo's website(s)) to do the work for you, but that may not
> scale well and might violate their ToS.
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: weird "can't adapt" error

2007-11-20 Thread Jeremy Dunck
"Can't adapt" is quite a vague error that psycopg2 issues.

Your issue is (apparently) something to do with encoding, and that's
different than Sandro's issue.

Please include more information, especially if you do decide to file a
ticket.  I can't help with the info given so far...

On Nov 20, 2007 2:55 PM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> The problem in my case seems to be strictly related to psycopg2
> backend. I tried with psycopg and it does not happens.
>
> Should I file a ticket?
>
>
> On 20 Lis, 10:17, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > I just started receiving the same problem when I try to save an object
> > that has non-ASCII values in char field (the values are all properly
> > decoded to unicode)> This seems related to psycopg2 backend, as I do
> > not observe such behaviour on my dev server with sqlite3 backend. The
> > model is similar to:
> >
> > class Label(models.Model):
> > title = models.CharField(max_length=200, unique=True)
> >
> > the code that leads to exception is like:
> >
> > t = 'żołędzie'.decode('utf-8')
> > label = Label(title=t)
> > label.save()
> >
> > The traceback from ipython:
> >
> > /home/zgoda/www/zgodowie/blog/models.py in save(self)
> >  42 if not self.slug:
> >  43 self.slug = slughifi(self.title)
> > ---> 44 super(Label, self).save()
> >  45
> >  46
> >
> > /home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
> > base.py in save(self, raw)
> > 257 cursor.execute("INSERT INTO %s (%s) VALUES
> > (%s)" % \
> > 258 (qn(self._meta.db_table),
> > ','.join(field_names),
> > --> 259 ','.join(placeholders)), db_values)
> > 260 else:
> > 261 # Create a new record with defaults for
> > everything.
> >
> > ProgrammingError: can't adapt
> >
> > I use SVN trunk rev. 6702.
> >
> > On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
> >
> > > On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
> >
> > > > Hi,
> >
> > > >   I'm meeting a weird problem in adjangoapplication.
> > > >   It works w/o any problem from my pc connecting remotely to my 
> > > > customer's
> > > >   apache but is not working inside the lan.
> >
> > > >   I'm connecting from firefox/ubuntu they're connecting from firefox/XP.
> >
> > > >   the weird part is that:
> >
> > > > 1. they have being working w/o probelms for 10 days and no 
> > > > modifications
> > > >where made
> >
> > > > 2. the error complains "can'tadapt" as if trying to insert wrong 
> > > > types
> > > >into the db, but the error trace shows the values are correct
> >
> > > > 3. a restart of apache fixes the problem
> >
> > > > 4. this is the second time the error happens...
> >
> > > >   Any hints?
> > > >   TIA
> > > >   sandro
> > > >   *:-)
> >
> > > Hi,
> >
> > >   once again I stumble into this problem. This time I gathered some
> > > more
> > >   info so I describe them.
> >
> > >   I try to insert a record it fails from a Windows pc with Firefox
> > > (and
> > >   IE). It works from linux (firefox or galeon).
> >
> > >   When it fails the error message is "can't adapt" but
> >
> > >   1. the params in the log are:
> > >   ('2007-10-26 08:50:03.651993', '2007-10-26 08:50:03.652039', 1, 17,
> > >   '2007-10-26', u'2', Decimal("100"), 'h', u'prova in fi'
> >
> > >   2. from my linux box I print params before a *working* insert and I
> > > get:
> > >   ['2007-10-26 09:17:44.744656', '2007-10-26 09:17:44.744682', 1, 17,
> > > '2007-10-26', u'2', Decimal("100"), 'h', u'prova']
> >
> > >Not realy different
> >
> > >   3. When it fails the database is not hit. Db is postgres and I
> > > switched on
> > >  statement log on every log:
> >
> > >  log_min_duration_statement = 0
> >
> > >   4. If I restart apache the error is fixed
> >
> > >   I'm running mod_wsgi
> >
> > > What should I do, next time it happens to better investigate. It's
> > > already
> > > happened 4 times in 2 months and I cannot just accept it...
> >
> > > Thanks for any possible help
> >
> > > sandro
> > > *:-)
> >
> > > the insert statement that worked follows:
> >
> > > INSERT INTO
> > > "timereport_report" 
> > > ("date_create","date_last_modify","status","user_id","date","job_id","qty","unit","description")
> > > VALUES ('2007-10-26 10:09:07.721575','2007-10-26 10:09:07.721619',
> > > 1,17,'2007-10-26','2',100,'h','prova in fi2')
> >
>

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

2007-11-20 Thread Jeremy Dunck

On Oct 26, 2007 2:47 AM, sandro dentella <[EMAIL PROTECTED]> wrote:
...
>
>   once again I stumble into this problem. This time I gathered some
> more
>   info so I describe them.

http://groups.google.com/group/django-users/browse_thread/thread/091aa6c088f6c090

I understand you're running wsgi rather than mod_python, but if you're
running multiple interpreters, you'll still have the problem discussed
there.

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



Re: weird "can't adapt" error

2007-11-20 Thread Jarek Zgoda

The problem in my case seems to be strictly related to psycopg2
backend. I tried with psycopg and it does not happens.

Should I file a ticket?

On 20 Lis, 10:17, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> I just started receiving the same problem when I try to save an object
> that has non-ASCII values in char field (the values are all properly
> decoded to unicode)> This seems related to psycopg2 backend, as I do
> not observe such behaviour on my dev server with sqlite3 backend. The
> model is similar to:
>
> class Label(models.Model):
> title = models.CharField(max_length=200, unique=True)
>
> the code that leads to exception is like:
>
> t = 'żołędzie'.decode('utf-8')
> label = Label(title=t)
> label.save()
>
> The traceback from ipython:
>
> /home/zgoda/www/zgodowie/blog/models.py in save(self)
>  42 if not self.slug:
>  43 self.slug = slughifi(self.title)
> ---> 44 super(Label, self).save()
>  45
>  46
>
> /home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
> base.py in save(self, raw)
> 257 cursor.execute("INSERT INTO %s (%s) VALUES
> (%s)" % \
> 258 (qn(self._meta.db_table),
> ','.join(field_names),
> --> 259 ','.join(placeholders)), db_values)
> 260 else:
> 261 # Create a new record with defaults for
> everything.
>
> ProgrammingError: can't adapt
>
> I use SVN trunk rev. 6702.
>
> On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
>
> > On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > >   I'm meeting a weird problem in adjangoapplication.
> > >   It works w/o any problem from my pc connecting remotely to my customer's
> > >   apache but is not working inside the lan.
>
> > >   I'm connecting from firefox/ubuntu they're connecting from firefox/XP.
>
> > >   the weird part is that:
>
> > > 1. they have being working w/o probelms for 10 days and no 
> > > modifications
> > >where made
>
> > > 2. the error complains "can'tadapt" as if trying to insert wrong types
> > >into the db, but the error trace shows the values are correct
>
> > > 3. a restart of apache fixes the problem
>
> > > 4. this is the second time the error happens...
>
> > >   Any hints?
> > >   TIA
> > >   sandro
> > >   *:-)
>
> > Hi,
>
> >   once again I stumble into this problem. This time I gathered some
> > more
> >   info so I describe them.
>
> >   I try to insert a record it fails from a Windows pc with Firefox
> > (and
> >   IE). It works from linux (firefox or galeon).
>
> >   When it fails the error message is "can't adapt" but
>
> >   1. the params in the log are:
> >   ('2007-10-26 08:50:03.651993', '2007-10-26 08:50:03.652039', 1, 17,
> >   '2007-10-26', u'2', Decimal("100"), 'h', u'prova in fi'
>
> >   2. from my linux box I print params before a *working* insert and I
> > get:
> >   ['2007-10-26 09:17:44.744656', '2007-10-26 09:17:44.744682', 1, 17,
> > '2007-10-26', u'2', Decimal("100"), 'h', u'prova']
>
> >Not realy different
>
> >   3. When it fails the database is not hit. Db is postgres and I
> > switched on
> >  statement log on every log:
>
> >  log_min_duration_statement = 0
>
> >   4. If I restart apache the error is fixed
>
> >   I'm running mod_wsgi
>
> > What should I do, next time it happens to better investigate. It's
> > already
> > happened 4 times in 2 months and I cannot just accept it...
>
> > Thanks for any possible help
>
> > sandro
> > *:-)
>
> > the insert statement that worked follows:
>
> > INSERT INTO
> > "timereport_report" 
> > ("date_create","date_last_modify","status","user_id","date","job_id","qty","unit","description")
> > VALUES ('2007-10-26 10:09:07.721575','2007-10-26 10:09:07.721619',
> > 1,17,'2007-10-26','2',100,'h','prova in fi2')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Complicated question

2007-11-20 Thread RajeshD

>
> That's interesting, but I think that leaving the models untouched
> would be better.
> Do you think there is a different way?

There might be. First, you'd have to explain what you didn't like
about doing queries like:

Image.objects.filter( book__library_owner=request.user)

Since you don't want to change your models, only your Library model
maintains the source of ownership and so, by definition, all your
queries would have to lead to a check on the Library.owner field
thereby ending up with filters like xyz__library_owner=some_user.

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

2007-11-20 Thread Malcolm Tredinnick


On Tue, 2007-11-20 at 05:12 -0800, cesco wrote:
> Thanks for the reply.
> I'm actually trying to match a word boundary with "\\b" before and
> after the string, not a backspace. Still one thing is unclear to me:
> isn't the django API supposed to be portable across different database
> platforms? Does iregex make an exception because of SQLite lack of reg-
> exp support? If that's the case then the code has to be changed when
> moving to production (that is, likely to a different database
> platform)?

When you're passing in something to iregex, you're using the database's
syntax for regular expressions. So, yes, it varies across databases.

Malcolm

-- 
Everything is _not_ based on faith... take my word for it. 
http://www.pointy-stick.com/blog/


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



Re: Error Handeling

2007-11-20 Thread Malcolm Tredinnick


On Tue, 2007-11-20 at 02:22 -0800, Rufman wrote:
> Hey
> 
> I know that django has error handlers for errors 404 and 500.
> My question: Could I just make my own handler and add it to the
> defaults in django.conf.urls.defaults? (for example 403 Forbidden)

The question doesn't make sense. 404 and 500 status codes are special
cases in that they are generated in response to certain exceptions. All
other status codes are generated directly by your views by returning an
HttpResponse and setting the status code (or returning one of the
special classes in django/http/__init__.py).

So there's no reason to be generating the other status codes via the
default handlers: you're execution path will never get to the point
where the request/response handler (wsgi.py or modpython.py) is handling
an exception for some other response code.

Regards,
Malcolm


-- 
If you think nobody cares, try missing a couple of payments. 
http://www.pointy-stick.com/blog/


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



Re: choices option in input-field

2007-11-20 Thread Malcolm Tredinnick


On Tue, 2007-11-20 at 00:19 -0800, Nader wrote:
> Hallo,
> 
> I have a model in which I have to use a input-field with choices
> option.
> 
> ACCESS = (
>  ('RO', 'readonly'),
>  ('WO', 'writeonly'),
>  ('RW', 'readwrite'),
>  )
> 
> Class myClass (...)
>..
>...
>active = models.IntegerField(choices=ACCESS, radio_admin=True)
>...
> 
> The value for 'choices' is of tuple type, actually tuple of tuple. In
> some case I have to use some dynamic information, it means that I
> don't know in front how many element in tuple will be present. I can
> define a empty tuple and then assign the elements to the tuple, but
> tuple is a unmutuable type. I can't use also 'list' or dictionary.
> Would you like to help me to solve this problem.

If you mean that every single time you access the field the choices
might be different, then you don't want to be using 'choices' here. You
want a many-to-many field instead. If you mean that you won't know the
value of choices until the *first* time you access the field, read this:

http://www.pointy-stick.com/blog/2007/03/26/django-tips-variable-choice-lists/

Regards,
Malcolm

-- 
He who laughs last thinks slowest. 
http://www.pointy-stick.com/blog/


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



Re: problem with "python manage.py shell"

2007-11-20 Thread Marty Alchin

On Nov 20, 2007 3:36 PM, Nader <[EMAIL PROTECTED]> wrote:
> I have looked at my system and found that I has installed also
> Python-2.4.4 and IPython. I have firstly uninstalled Python-2.4.4 and
> tried once more the same command "python manage.py shell'' in project
> directory. I have got the same  problem. Then I have uninstalled the
> IPython also, and the problem is solved!
> If I do "python manage.py shell'' I get :
>
> Python 2.5.1 (r251:54863, Oct 26 2007, 01:35:31)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>>
> It is Ok! I don't understand what the problem was.

I think I understand now. I thought the error you mentioned was part
of your own code, so I apologize for my misunderstanding. It looks
like you had a version of IPython designed for Python 2.4, but it was
being run against Python 2.5. It was making an assumption about how
__builtin__.exit worked, which was no longer valid.

You should be able to use IPython again, as long as you make sure to
get a version that's compatible with Python 2.5.

I don't use IPython myself, so I can't verify any of this, but that
seems to be what happened to you.

-Gul

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



Re: Complicated question

2007-11-20 Thread Grupo Django

RajeshD ha escrito:
> From what I understand, you want a generic ability to declare an owner
> item for any model object.
>
> Django's generic relations work that way. Take a look at the examples
> here:
>
> http://www.djangoproject.com/documentation/models/generic_relations/
>
> Specially, instead of TaggedItem in that example, you could have an
> ObjectOwner model class. And instead of TaggedItem.tag you would have
> TaggedItem.owner_user
>
> Your other objects will not need an owner field anymore. They would be
> like the Mineral class in the example linked above.
>
> Hope this gives you a starting point.

That's interesting, but I think that leaving the models untouched
would be better.
Do you think there is a different way?
Thank you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ImageField file naming

2007-11-20 Thread Marty Alchin

On Nov 20, 2007 3:33 PM, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> It would be nice to be able to include this in the upload_to parameter.
> Something like
> 'upload/%(model_name)s/%(instance_id)s.%(mimetype_extension)s' perhaps?
> Maybe, if the parameter ends with a slash, the handler could know "ok.
> this is a directory. let's keep the original filename".

As usual, I'll respond to this as I've been doing a good bit of work
in this area lately. There's no "official" way to do this yet, but
there are ways to get the job done. Take a look at the links below for
more information on some techniques.

I'm doing a good bit of work on making Django handle renaming a bit
better, and I'm hoping it will land during the next sprint on December
1. There's no guarantee of that, of course, but that's my personal
goal. That will be documented thoroughly when it lands, and I'll make
an announcement here on django-users whenever that is, sprint or not.

-Gul

http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/
http://code.djangoproject.com/wiki/CustomUploadAndFilters
http://gulopine.gamemusic.org/2007/11/customizing-filenames-without-patching.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: problem with "python manage.py shell"

2007-11-20 Thread Nader

I have looked at my system and found that I has installed also
Python-2.4.4 and IPython. I have firstly uninstalled Python-2.4.4 and
tried once more the same command "python manage.py shell'' in project
directory. I have got the same  problem. Then I have uninstalled the
IPython also, and the problem is solved!
If I do "python manage.py shell'' I get :

Python 2.5.1 (r251:54863, Oct 26 2007, 01:35:31)
[GCC 4.1.2 (Gentoo 4.1.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
It is Ok! I don't understand what the problem was.

Thank for the giving some indication!

On Nov 20, 9:26 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> Well, all that tells me is that you're running Python 2.5, which i
> already knew from the nature of your error message.
>
> Allow me to rephrase. The message you saw *is expected* under Python
> 2.5. The code you listed probably worked before, but it *will not
> work* in Python 2.5 or future versions of Python.
>
> So the real issue is this: why are you trying to modify
> __builtin__.exit? It's not allowed, so you'll need to find another way
> to do whatever it is you're trying to do.
>
> Perhaps some more code could explain what you're trying to do, and how
> best to get around it.
>
> -Gul
>
> On Nov 20, 2007 3:17 PM, Nader <[EMAIL PROTECTED]> wrote:
>
>
>
> > It is a Linux machine with a Gentoo and Python in this is:
>
> > #pyhton
> > Python 2.5.1 (r251:54863, Oct 26 2007, 01:35:31)
> > [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
>
> > On Nov 20, 9:01 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
>
> > > On Nov 20, 2007 2:22 PM, Nader <[EMAIL PROTECTED]> wrote:
>
> > > > If I use the "python manage.py shell" to go to shell, I got the next
> > > > message:
>
> > > > _builtin__.exit += _exit
> > > > TypeError: unsupported operand type(s) for +=: 'Quitter' and 'str'
>
> > > > It is actually part of error.
> > > > Some idea what the problem is?
>
> > > I'm not sure what exactly you're trying to do here, but I'll hazard a
> > > guess as to what the "problem" is. Prior to Python 2.5,
> > > __builtin__.exit was a string containing something like "Use Ctrl-Z
> > > plus Return to exit." (on Windows anyway). In Python 2.5,
> > > __built__.exit is a class, which exits the interpreter, when called.
> > > So the following line was invalid under Python 2.4, but became
> > > possible with Python 2.5.
>
> > > >>> exit()
>
> > > It looks like you're relying on __builtin__.exit being a string, which
> > > is no longer the case if you recently upgraded to Python 2.5.
>
> > > -Gul
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ImageField file naming

2007-11-20 Thread Chris Hoeppner

Hi there!

I've seen this in patches and stuff before, but most don't work anymore.
Perhaps some Django-insider could advice me how to make Django rename
uploaded files according to some schema when saving them to disk?

Preserving the original filename is ok for most cases, but sometimes it
just doesn't make sense.

It would be nice to be able to include this in the upload_to parameter.
Something like
'upload/%(model_name)s/%(instance_id)s.%(mimetype_extension)s' perhaps?
Maybe, if the parameter ends with a slash, the handler could know "ok.
this is a directory. let's keep the original filename".

Just brainstorming, anyways. I don't know enough about Django internals
to come up with a patch like this.

~ Chris


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



Re: Complicated question

2007-11-20 Thread Grupo Django

On 20 nov, 20:46, RajeshD <[EMAIL PROTECTED]> wrote:
> From what I understand, you want a generic ability to declare an owner
> item for any model object.
>
> Django's generic relations work that way. Take a look at the examples
> here:
>
> http://www.djangoproject.com/documentation/models/generic_relations/
>
> Specially, instead of TaggedItem in that example, you could have an
> ObjectOwner model class. And instead of TaggedItem.tag you would have
> TaggedItem.owner_user
>
> Your other objects will not need an owner field anymore. They would be
> like the Mineral class in the example linked above.
>
> Hope this gives you a starting point.

That's interesting, but I think it would be better to leave the models
untouched would be better.
Do you think there is a different way?
Thank you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem with "python manage.py shell"

2007-11-20 Thread Marty Alchin

Well, all that tells me is that you're running Python 2.5, which i
already knew from the nature of your error message.

Allow me to rephrase. The message you saw *is expected* under Python
2.5. The code you listed probably worked before, but it *will not
work* in Python 2.5 or future versions of Python.

So the real issue is this: why are you trying to modify
__builtin__.exit? It's not allowed, so you'll need to find another way
to do whatever it is you're trying to do.

Perhaps some more code could explain what you're trying to do, and how
best to get around it.

-Gul

On Nov 20, 2007 3:17 PM, Nader <[EMAIL PROTECTED]> wrote:
>
> It is a Linux machine with a Gentoo and Python in this is:
>
> #pyhton
> Python 2.5.1 (r251:54863, Oct 26 2007, 01:35:31)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> On Nov 20, 9:01 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
>
> > On Nov 20, 2007 2:22 PM, Nader <[EMAIL PROTECTED]> wrote:
> >
> > > If I use the "python manage.py shell" to go to shell, I got the next
> > > message:
> >
> > > _builtin__.exit += _exit
> > > TypeError: unsupported operand type(s) for +=: 'Quitter' and 'str'
> >
> > > It is actually part of error.
> > > Some idea what the problem is?
> >
> > I'm not sure what exactly you're trying to do here, but I'll hazard a
> > guess as to what the "problem" is. Prior to Python 2.5,
> > __builtin__.exit was a string containing something like "Use Ctrl-Z
> > plus Return to exit." (on Windows anyway). In Python 2.5,
> > __built__.exit is a class, which exits the interpreter, when called.
> > So the following line was invalid under Python 2.4, but became
> > possible with Python 2.5.
> >
> > >>> exit()
> >
> > It looks like you're relying on __builtin__.exit being a string, which
> > is no longer the case if you recently upgraded to Python 2.5.
> >
> > -Gul
> >
>

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



Re: problem with "python manage.py shell"

2007-11-20 Thread Nader

It is a Linux machine with a Gentoo and Python in this is:

#pyhton
Python 2.5.1 (r251:54863, Oct 26 2007, 01:35:31)
[GCC 4.1.2 (Gentoo 4.1.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

On Nov 20, 9:01 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Nov 20, 2007 2:22 PM, Nader <[EMAIL PROTECTED]> wrote:
>
> > If I use the "python manage.py shell" to go to shell, I got the next
> > message:
>
> > _builtin__.exit += _exit
> > TypeError: unsupported operand type(s) for +=: 'Quitter' and 'str'
>
> > It is actually part of error.
> > Some idea what the problem is?
>
> I'm not sure what exactly you're trying to do here, but I'll hazard a
> guess as to what the "problem" is. Prior to Python 2.5,
> __builtin__.exit was a string containing something like "Use Ctrl-Z
> plus Return to exit." (on Windows anyway). In Python 2.5,
> __built__.exit is a class, which exits the interpreter, when called.
> So the following line was invalid under Python 2.4, but became
> possible with Python 2.5.
>
> >>> exit()
>
> It looks like you're relying on __builtin__.exit being a string, which
> is no longer the case if you recently upgraded to Python 2.5.
>
> -Gul
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: starting point?

2007-11-20 Thread [EMAIL PROTECTED]

thanks! hopefully my webhoster allows all the needed .htaccess stuff.
but it sounds promising...

how can i figure out if my webhoster uses fastcgi? can this info be
printed with a simple script?

On Nov 20, 8:28 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 11/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > but what i don't understand yet... if i move this to a webhoster,
> > where is the starting point then? isn't there some index.cgi needed or
> > so? or how will the server know that a certain url is supposed to be
> > handled by django?
>
> The tutorial simply covers first steps using the dev server; for
> production deployment behind a real web server, visit the
> documentation index:
>
> http://www.djangoproject.com/documentation/
>
> and scroll down to "Deployment".
>
> --
> "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: problem with "python manage.py shell"

2007-11-20 Thread Marty Alchin

On Nov 20, 2007 2:22 PM, Nader <[EMAIL PROTECTED]> wrote:
> If I use the "python manage.py shell" to go to shell, I got the next
> message:
>
> _builtin__.exit += _exit
> TypeError: unsupported operand type(s) for +=: 'Quitter' and 'str'
>
> It is actually part of error.
> Some idea what the problem is?

I'm not sure what exactly you're trying to do here, but I'll hazard a
guess as to what the "problem" is. Prior to Python 2.5,
__builtin__.exit was a string containing something like "Use Ctrl-Z
plus Return to exit." (on Windows anyway). In Python 2.5,
__built__.exit is a class, which exits the interpreter, when called.
So the following line was invalid under Python 2.4, but became
possible with Python 2.5.

>>> exit()

It looks like you're relying on __builtin__.exit being a string, which
is no longer the case if you recently upgraded to Python 2.5.

-Gul

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



Re: local dev them publish out to the real world

2007-11-20 Thread RajeshD

> hey I am new to django?

Welcome.

> so is it possable to devlop a django site on my mac and then publish
> to another webserver or EC2/S3

Yes, not only is it possible but it happens to be the most common
case: develop on your workstation (Mac, Windows, Linux, doesn't
matter) and then push to a production environment.

> would I face any problems along the way?

That depends on your experience with web application development and
deployment as well as how well your ISP supports Python and all other
dependencies of your application.

Start with the Deployment section under here: 
http://www.djangoproject.com/documentation/

You can always come back here if you experience any specific problems.


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

2007-11-20 Thread Gabriel Farrell

I don't know details on this, but there have been a lot of
improvements to the Unicode handling in versions since 0.96, so an
obvious suggestion would be to upgrade to the latest Subversion
trunk.  That will most likely solve your problem.

gsf

On Nov 20, 12:09 pm, cwurld <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a block of text that I load into a webpage using an {%
> include  %} tag. I have two versions of the include file. One in
> English, the other in Spanish. I have no problem loading either one.
> However the Spanish characters in the Spanish file are not displayed
> properly.
>
> I tried putting some of the Spanish text directly in the webpage and
> that text was properly displayed. So I am guessing that the include
> tag is getting the content from the file as if it were ascii and not
> utf-8.
>
> I am using version 0.96.
>
> Any suggestions?
>
> Thanks,
> Chuck
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Complicated question

2007-11-20 Thread RajeshD

>From what I understand, you want a generic ability to declare an owner
item for any model object.

Django's generic relations work that way. Take a look at the examples
here:

http://www.djangoproject.com/documentation/models/generic_relations/

Specially, instead of TaggedItem in that example, you could have an
ObjectOwner model class. And instead of TaggedItem.tag you would have
TaggedItem.owner_user

Your other objects will not need an owner field anymore. They would be
like the Mineral class in the example linked above.

Hope this gives you a starting point.

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



Free Mp3 Songs Download(www.mp3songshome.com)

2007-11-20 Thread Ahsan

mp3songshome.com

Mp3 Songs Home Music is your source for legal and free MP3
downloads.ALL latest English, Spanish , Greek, hindi and pakistani mp3
songs. Download MP3s from thousands of artists.
Free Indian , pakistani , English and spanish Mp3 Songs Download .
Listen Online and Download for free.

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



Re: starting point?

2007-11-20 Thread Gabriel Farrell

Hi Horace,

Depending on your webhost, you will need to use fastcgi or mod-
python.  See http://wiki.dreamhost.com/index.php/Django as an example
-- therein are the steps necessary to get Django running on DreamHost,
a large webhost that supports fastcgi.

Also see http://www.djangoproject.com/documentation/modpython/ and
http://www.djangoproject.com/documentation/fastcgi/.

gsf

On Nov 20, 2:21 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> hi,
>
> i am currently doing the tutorial. i am at the middle of part 3 and
> quickly skimmed through the rest of 3 and 4 already.
>
> so far so good. it works great locally and with django's own simple
> server.
>
> but what i don't understand yet... if i move this to a webhoster,
> where is the starting point then? isn't there some index.cgi needed or
> so? or how will the server know that a certain url is supposed to be
> handled by django?
>
> ~horace
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: starting point?

2007-11-20 Thread James Bennett

On 11/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> but what i don't understand yet... if i move this to a webhoster,
> where is the starting point then? isn't there some index.cgi needed or
> so? or how will the server know that a certain url is supposed to be
> handled by django?

The tutorial simply covers first steps using the dev server; for
production deployment behind a real web server, visit the
documentation index:

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

and scroll down to "Deployment".


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



problem with "python manage.py shell"

2007-11-20 Thread Nader

If I use the "python manage.py shell" to go to shell, I got the next
message:

_builtin__.exit += _exit
TypeError: unsupported operand type(s) for +=: 'Quitter' and 'str'

It is actually part of error.
Some idea what the problem is?

Regards,


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



local dev them publish out to the real world

2007-11-20 Thread sebey

hey I am new to django?

so is it possable to devlop a django site on my mac and then publish
to another webserver or EC2/S3

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



starting point?

2007-11-20 Thread [EMAIL PROTECTED]

hi,

i am currently doing the tutorial. i am at the middle of part 3 and
quickly skimmed through the rest of 3 and 4 already.

so far so good. it works great locally and with django's own simple
server.

but what i don't understand yet... if i move this to a webhoster,
where is the starting point then? isn't there some index.cgi needed or
so? or how will the server know that a certain url is supposed to be
handled by django?

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



Complicated question

2007-11-20 Thread Grupo Django

Hello, I'm programing a kind of admin zone for users, where users can
add, manage and delete objects.
I want to do it generic, but I have a big problem now.
Imagine these models:

from django.contrib.auth.models import User
class Library ( models.model ):
library_name = models.CharField(..)
owner = models.ForeignKey( User )

class Book( models.model ):
library = models.ForeignKey( Library )
title = models.CharField(...)

class Image ( models.model ):
front_page = models.ImageField(..)
book = models.ForeignKey( Book )

What I want is a function wich returns the class that have the field
owner, populating the fields tables and where to use it with the extra
method of the object. I have seen fill_table_cache in query.py, but I
don't really understand how it works and if it's suitable for my
needs.
I need it because I want to show only the images that belong to an
user, so I need to make something similar to:
images = Image.objects.filter( book__library_owner = request.user )
I started the recursive function but I almost got crazy and this
morning I deleted everything. As I'd like to do it general, It should
work for diferent models at diferents levels of distance from classes.
i.e.
words = Word.objects.filter( page__book__library__owner =
request.user ) or
libraries =Library.objects.filter( owner = request.user )

Do you have any suggestions?

Thank you very much.

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

2007-11-20 Thread Artiom Diomin

take a look here
http://www.djangoproject.com/documentation/model-api/#providing-initial-sql-data

PS: note, you can different formats for inial data, I'm for example
using pyyaml (it's database backend independent)

Jose Jiménez пишет:
> Hello everybody,
>
> I'm starting a project in django. I need some custom permissions that
> i created in the model with "class Meta". Now i need to create
> some groups. I've seen that i can create groups from the
> administration panel, but... i would like to create from source code,
> so, if other person downloads the code and installs django, could make
> a "syncdb" and automagically has the same groups.
>
> I've been looking for in google but i haven't found anything. Is it
> possible??
>
> Sorry for my english, i hope you understand me.
>
> Thanks.
>
> ---
> Jose Jiménez
> [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: Street address normalisation

2007-11-20 Thread Tim Chase

> I have an issue with users doing a lookup on street address.
[snip]
> This seems like asuch a common problem; are there any
> libraries for this; what is the "correct" way to handle this?
> How do google; Mapquest and Yahoo do this? (I don't have quite
> their resources; but it would point me in the right
> direction...)

One common Python solution is to snag PyParsing and extend their 
streetAddressParser.py example

http://pyparsing.wikispaces.com/Examples

There are some holes in it (most notably "rd" missing from the 
numberSuffix definition, but the cardinal directions may need 
expansion too from just "N S E W" to include "NW SW NE SW"), but 
it should get you pointed in the right direction and be fairly 
easily extensible.

I've tried with regexps, and it gets *really ugly*.

An alternative might be using the USPS website (or ERSI, Google, 
or Yahoo's website(s)) to do the work for you, but that may not 
scale well and might violate their ToS.

-tim




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



Street address normalisation

2007-11-20 Thread hajo

I have an issue with users doing a lookup on street address.

the issue is the following:

If the address the user wants is 123A mockingird st. It'll mess up on
street; str. etc...

My solution was to only look at the first "word" in the search box; So
if you have a mockingbird Lane and a mockingbird circle I would return
both. I also ignored street numbers; (This is for a market area
search; not one specific address)

My issues doing this right now are: I'm missing numbered streets
(F.ex: 14th street)

This seems like asuch a common problem; are there any libraries for
this; what is the "correct" way to handle this? How do google;
Mapquest and Yahoo do this? (I don't have quite their resources; but
it would point me in the right direction...)

Thank you very much and everybody have a great thanksgiving.

Hajo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 define choices that works in admin interface?

2007-11-20 Thread David Marko

Using this I could create a static list only. But what I mean is
dynamic list based on database query.
I have the following model for keeping the list of different choices .

class Choice(models.Model):
TYPES = (
('os_type','OS Types'),
('os_type','OS Types'),
)

type = models.CharField(verbose_name='Type', maxlength=30,
choices=TYPES, null=False, blank=False)
value = models.CharField(verbose_name='Key', maxlength=30,
null=False, blank=False)
label = models.CharField(verbose_name='Value', maxlength=30,
null=False, blank=False)

@classmethod
def get_choices_for(self, type):
l=[(k.value,k.label) for k in self.objects.filter(type=type)]
l.extend([('','- select -'),])
l.sort()
return (l)

 then on the another model I would like to make specific choices
available:
type = models.CharField(verbose_name='OS', maxlength=30, choices =
Choice.get_choices_for('os_type'), null=False, blank=False)


... but using this technique doesnt work as Django runs
Choice.get_choices_for('os_type')  only one time when application
starts up ... so it doesnt reflect changes made to Choices table.


David

On Nov 20, 4:57 pm, Michael <[EMAIL PROTECTED]> wrote:
> The following worked for me:
>
> model field:
> type = models.CharField(max_length=10, radio_admin=True,
> choices=CHOICE_LIST)
>
> where CHOICE_LIST is a tuple of tuples, defined inside the model if
> local, outside if you need it in multiple models,  like:
> CHOICE_LIST = (('dbasename1', 'displayname1'), ('dbasename2',
> 'displayname2'),)
>
> radio_admin=True causes the list to be displayed as a radio select
> list (instead of a select/drop list or something.)  The docs 
> athttp://www.djangoproject.com/documentation/model-api/say the
> radio_admin is new in the developmental version.
>
> Hope this helps,
>  Michael
>
> On Nov 20, 6:48 am, Christian Joergensen <[EMAIL PROTECTED]> wrote:
>
> > David Marko wrote:
> > > How to define choices for filed that works in admin interface? When I
> > > define CharField as below, the list of choices is computed intially
> > > and doesn't refresh when data changes in Choices table.
>
> > > type = models.CharField(verbose_name='Type', maxlength=30, choices =
> > > Choice.filter(""), null=False, blank=False)
>
> > Normally, one would use a foreign key in this case:
>
> > choice = models.ForeignKey(Choice)
>
> > Regards,
>
> > --
> > Christian Joergensen | Linux, programming or web 
> > consultancyhttp://www.razor.dk| Visit us at:http://www.gmta.info
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Include tag - encoding

2007-11-20 Thread cwurld

Hi,

I have a block of text that I load into a webpage using an {%
include  %} tag. I have two versions of the include file. One in
English, the other in Spanish. I have no problem loading either one.
However the Spanish characters in the Spanish file are not displayed
properly.

I tried putting some of the Spanish text directly in the webpage and
that text was properly displayed. So I am guessing that the include
tag is getting the content from the file as if it were ascii and not
utf-8.

I am using version 0.96.

Any suggestions?

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

2007-11-20 Thread James Bennett

On 11/20/07, Rufman <[EMAIL PROTECTED]> wrote:
> Is there some way to stop (reduce) the spam I get through a form? I
> was thinking of making a dropdown (html select) with a selection of
> subjects. Then I could easily define rules. I I guess dropdown menus
> are bit readable.

I use Akismet on my contact form, and it works pretty well.

-- 
"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: queryset-refactor branch merge

2007-11-20 Thread MichaelMartinides

Thanks for the information!

Low level worked for me :-)

Keep up the good work!

>>MM

On Nov 20, 12:48 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2007-11-19 at 08:50 -0800, MichaelMartinides wrote:
> > Hi James,
>
> > I entirely understand your point.
>
> > But for users as me, it makes a difference to know if a feature is in
> > very far distant or rather near future...
>
> > I tried the branch it worked in command mode line as expected but gave
> > an error when I tried it in the browser, so I simply asked.
>
> It's completely unready for testing. This is noted on the wiki page for
> the branch:http://code.djangoproject.com/wiki/QuerysetRefactorBranch
>
> Due to the very low-level technical nature of the changes, correctness
> at the SQL level is the first aim and *then* adjusting the rest of the
> code. So I wouldn't be testing it yet.
>
> As Karen said, end of the month is the rough target. It certainly won't
> be earlier than that, might be a bit later. Depends on how much Real
> Life I have between now and then.
>
> Malcolm
>
> --
> Success always occurs in private and failure in full 
> view.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to create groups from code?

2007-11-20 Thread Jose Jiménez

Hello everybody,

I'm starting a project in django. I need some custom permissions that
i created in the model with "class Meta". Now i need to create
some groups. I've seen that i can create groups from the
administration panel, but... i would like to create from source code,
so, if other person downloads the code and installs django, could make
a "syncdb" and automagically has the same groups.

I've been looking for in google but i haven't found anything. Is it
possible??

Sorry for my english, i hope you understand me.

Thanks.

---
Jose Jiménez
[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: how fixtures can be load in django tests?

2007-11-20 Thread Joseph Kocherhans

On 11/20/07, michel bruavics <[EMAIL PROTECTED]> wrote:
>
> Hi djangos,
>
> I check out the django.test.client and want to load a fixture file
> called "myfixture.xml".
>
> I added in my project setting a folder (called fixtures):
> FIXTURE_DIRS = ('/workspace/project/fixtures/')
>
> myfixture.xml is inside of the folder fixtures.
>
> now I try to load the fixture in my tests.py:
>
> class TestSurfer(unittest.TestCase):
> fixtures = ['myfixture.xml']
> 
>
> But it doesn't load the fixture.
> I try other names, other places but nothing works for me. I only can
> load a file when it's named "initial_data.xml".

You need to use django.test.TestCase, not unittest.TestCase. The
latter knows nothing about fixtures. :)

Joseph

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



Freenode and django related channels

2007-11-20 Thread ikks

Hi, some spanish speakers folks are resurrecting a channel on
freenode, it's called #django-es , I would like to know if someone
nicknamed dashinho is on the list.  Or is there a django-freenode
agreement ongoing for the django related channels.

/msg chanserv info #django-es

-ChanServ-  Channel: #django-es
-ChanServ-  Contact: dashinho, last seen: 1 year 47 weeks 3 days
(0h 28m 32s) ago
-ChanServ-   Registered: 1 year 48 weeks 1 day (17h 56m 37s) ago
-ChanServ-Mode Lock: -s+ntc
-ChanServ-  Channel: #django-es
-ChanServ-  Contact: dashinho, last seen: 1 year 47 weeks 3 days
(0h 31m 45s) ago
-ChanServ-   Registered: 1 year 48 weeks 1 day (17h 59m 50s) ago
-ChanServ-Mode Lock: -s+ntc

/msg nickserv info dashinho

-NickServ-Nickname: dashinho
-NickServ-  Registered: 2 years 11 weeks (21h 4m 29s) ago
-NickServ-   Last Seen: 26 weeks (17h 30m 6s) ago
-NickServ-   Last Seen Address: [EMAIL PROTECTED]
-NickServ-  Last Seen Quit Msg: Read error: 113 (No route to host)
-NickServ-Nickname Options: Secure, AllowMemos, MemoNotify,
MemoSignon

Then I went to freenode staff asking for help and I got the following:

 which channel?
 #django-es
 We are starting to meet there
 I would like to contact the op, asking for privileges
 He hasn't been online for 26 weeks currently
 or take control over the channel if s/he doesn't appear.
 There's an ongoing group registration for the django project I
believe.  Hopefully when that's completed we should be able to sort of
the channel for you.
 Ok, thanks, I will ask to django people, thanks

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



Re: How to define choices that works in admin interface?

2007-11-20 Thread Michael

The following worked for me:

model field:
type = models.CharField(max_length=10, radio_admin=True,
choices=CHOICE_LIST)

where CHOICE_LIST is a tuple of tuples, defined inside the model if
local, outside if you need it in multiple models,  like:
CHOICE_LIST = (('dbasename1', 'displayname1'), ('dbasename2',
'displayname2'),)

radio_admin=True causes the list to be displayed as a radio select
list (instead of a select/drop list or something.)  The docs at
http://www.djangoproject.com/documentation/model-api/ say the
radio_admin is new in the developmental version.

Hope this helps,
 Michael


On Nov 20, 6:48 am, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> David Marko wrote:
> > How to define choices for filed that works in admin interface? When I
> > define CharField as below, the list of choices is computed intially
> > and doesn't refresh when data changes in Choices table.
>
> > type = models.CharField(verbose_name='Type', maxlength=30, choices =
> > Choice.filter(""), null=False, blank=False)
>
> Normally, one would use a foreign key in this case:
>
> choice = models.ForeignKey(Choice)
>
> Regards,
>
> --
> Christian Joergensen | Linux, programming or web 
> consultancyhttp://www.razor.dk | Visit us at:http://www.gmta.info
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 rocks: Key Ingredient

2007-11-20 Thread [EMAIL PROTECTED]

Hi all, I just wanted to let you all know that we've recently opened
up http://keyingredient.com/ -- we're using django
(+linux,memcached,mysql,sphinx,perlbal,pound...) and things are
running pretty smoothly so far.  The site lets you find, add, and
collect recipes but also goes one step further and allows you to
publish (as in paper) and syndicate (via widgets) your recipes.  I'd
like to thank the Django team and contributors for all their hard
work!

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



Re: How to access method parameters

2007-11-20 Thread Tim Chase

> self.create(50, 50, "round")
> 
> def create(self, wsize, hsize, shape):
> var = self.get_shape_filename()
> etc
> 
> ///
> 
> I get an error whenever it hits the line 'var =
> self.get_shape_filename()'.  The error is:
> 
> object has no attribute 'get_shape_filename'
> 
> 
> 
> In the above case I'm sending 'round' to the method.  So it's supposed
> to be get_round_filename.


Sounds like you're looking for the getattr() call in the standard 
library...something like

   get_filename = getattr(self,
 'get_%s_filename' % shape)
   var = get_filename()

-tim




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



Re: How to access method parameters

2007-11-20 Thread Marty Alchin

On Nov 20, 2007 10:24 AM, Greg <[EMAIL PROTECTED]> wrote:
> self.create(50, 50, "round")
>
> def create(self, wsize, hsize, shape):
> var = self.get_shape_filename()
>
> In the above case I'm sending 'round' to the method.  So it's supposed
> to be get_round_filename.

Well, to be fair, it's doing what it's supposed to be doing, just not
what you want it to do. :) Try something like this instead:

def create(self, wsize, hsize, shape):
func = getattr(self, 'get_%s_filename' % shape)
var = func()

That will look for 'get_round_filename' if you pass in 'round', or
'get_square_filename' if you pass in 'square', etc. Hope it helps.

-Gul

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



How to access method parameters

2007-11-20 Thread Greg

Hello,
I have the following code in one of my classes

self.create(50, 50, "round")

def create(self, wsize, hsize, shape):
var = self.get_shape_filename()
etc

///

I get an error whenever it hits the line 'var =
self.get_shape_filename()'.  The error is:

object has no attribute 'get_shape_filename'



In the above case I'm sending 'round' to the method.  So it's supposed
to be get_round_filename.



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

2007-11-20 Thread Marcin Mierzejewski

Hi Rufman,

You can use third part software like http://recaptcha.net/ or you can
use this idea to write something similar.

Regards,
Marcin


On Nov 20, 4:15 pm, Rufman <[EMAIL PROTECTED]> wrote:
> Hey Guys
>
> Is there some way to stop (reduce) the spam I get through a form? I
> was thinking of making a dropdown (html select) with a selection of
> subjects. Then I could easily define rules. I I guess dropdown menus
> are bit readable.
>
> Any suggestions?
>
> Stephane Rufer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 / Apache Problem (ignores SetHandler)

2007-11-20 Thread Nils Herzog

Hi Marcin,

> You can use django.views.static.serve.
> In my application I have the following link in my urls.py

But this is not good for my production server.

Quote from http://www.djangoproject.com/documentation/static_files/

"Using this method is inefficient and insecure. Do not use this in a 
production setting."

Any other hints? :-)

Cheers,
Nils 


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



Spam mail in forms

2007-11-20 Thread Rufman

Hey Guys

Is there some way to stop (reduce) the spam I get through a form? I
was thinking of making a dropdown (html select) with a selection of
subjects. Then I could easily define rules. I I guess dropdown menus
are bit readable.

Any suggestions?


Stephane Rufer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 / Apache Problem (ignores SetHandler)

2007-11-20 Thread Marcin Mierzejewski

Hi,

You can use django.views.static.serve.
In my application I have the following link in my urls.py

(r'^css/(?P.*)$', 'django.views.static.serve', {'document_root':
'%s/templates/css' % APPLICATION_ROOT }),
(r'^javascript/(?P.*)$', 'django.views.static.serve',
{'document_root': '%s/templates/javascript' % APPLICATION_ROOT }),
(r'^images/(?P.*)$', 'django.views.static.serve',
{'document_root': '%s/templates/images' % APPLICATION_ROOT}),
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': '%s/media' % APPLICATION_ROOT}),

Where APPLICATION_ROOT is the physician path to my Django application.

And when I want to access to image file, I use the following link: /
images/image_name.jpg.

Regards,
Marcin


On Nov 20, 4:04 pm, idioglossiahh <[EMAIL PROTECTED]> wrote:
> Hi everybody,
> There are lots of discussions on the internet concerning this topic - but I
> couldn't find any information that helped me. I know that this is not
>
> necessarily a Django topic but perhaps there are more people here who find
> this information helpful.
>
> I am trying to get my Djano project to run on Apache with mod_python.
> Everything works fine - but static content like images and css files is not
>
> displayed/loaded properly.
>
> My directory structure looks like this:
> /home/websites/mydomain (root directory of my Django application)
> /home/websites/mydomain/static/images (dir for images)
> /home/websites/mydomain/static/css (dir for css files)
>
> At the end of my httpd.conf file I have added this:
>
> DocumentRoot "/home/websites/mydomain"
>
> 
> SetHandler python-program
> PythonPath "['/home/websites'] + sys.path"
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE mydomain.settings
> SetEnv PYTHON_EGG_CACHE /tmp/egg-cache
> PythonDebug On
> AuthType Basic
> AuthName "Administration"
> AuthUserFile /usr/admin/web/.htusers
> Require valid-user
> 
>
> 
> SetHandler None
> 
>
> 
> SetHandler None
> 
>
> But if I call this url in my 
> browser:http://www.mydomain.com/static/images/image.jpg
>
> I just see standard "Page not found (404)" error page generated by Django.
> Which is quite strange because the settings in my httpd.conf say that images
>
> and static content should NOT be handled by Python/Django.
>
> Any hints for me? I'm using Apache 2.2.0 and mod_python 3.1.3
> --
> View this message in 
> context:http://www.nabble.com/Django---Apache-Problem-%28ignores-SetHandler%2...
> Sent from the django-users mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django / Apache Problem (ignores SetHandler)

2007-11-20 Thread idioglossiahh


Hi everybody,
There are lots of discussions on the internet concerning this topic - but I
couldn't find any information that helped me. I know that this is not 

necessarily a Django topic but perhaps there are more people here who find
this information helpful.

I am trying to get my Djano project to run on Apache with mod_python.
Everything works fine - but static content like images and css files is not 

displayed/loaded properly.

My directory structure looks like this:
/home/websites/mydomain (root directory of my Django application)
/home/websites/mydomain/static/images (dir for images)
/home/websites/mydomain/static/css (dir for css files)

At the end of my httpd.conf file I have added this:

DocumentRoot "/home/websites/mydomain"


SetHandler python-program
PythonPath "['/home/websites'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mydomain.settings
SetEnv PYTHON_EGG_CACHE /tmp/egg-cache
PythonDebug On
AuthType Basic
AuthName "Administration"
AuthUserFile /usr/admin/web/.htusers
Require valid-user



SetHandler None



SetHandler None


But if I call this url in my browser:
http://www.mydomain.com/static/images/image.jpg

I just see standard "Page not found (404)" error page generated by Django.
Which is quite strange because the settings in my httpd.conf say that images 

and static content should NOT be handled by Python/Django.

Any hints for me? I'm using Apache 2.2.0 and mod_python 3.1.3
-- 
View this message in context: 
http://www.nabble.com/Django---Apache-Problem-%28ignores-SetHandler%29-tf4843939.html#a13858363
Sent from the django-users mailing list archive at Nabble.com.


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



Re: prepopulate_from delimiter

2007-11-20 Thread RajeshD



On Nov 20, 1:11 am, Mogga <[EMAIL PROTECTED]> wrote:
> great article... very interesting and answered some old questions...
> not using it for URLS...
> i'm developing some file system mgmt tools for software packages that
> don't like hyphens. i'll have to hack the slugifier or create my own
> js...

You could also override the save method of your model and simply
replace all hyphens with underscores there for the slugfield.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using "select_related" .Does it works?

2007-11-20 Thread RajeshD

> The docs say select_related() does not follow foreign keys that have
> null=True. In your example it would do nothing.
>

It would. As Samuel points out, select_related's only job is to save
you some database trips. The examples I cooked up above will work fine
with or without select_related(). In this case, select_related won't
save him any DB trips but the image.instrument and image.channel
statements would still lead to the related objects (Django will simply
make additional DB calls to follow those relations.)

You can also get the same DB savings as select_related() by explicitly
joining the instrument and channel tables using the .extra method and
its tables keyword[1]

[1] 
http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none

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

2007-11-20 Thread Jeremy Dunck

On Nov 20, 2007 7:12 AM, cesco <[EMAIL PROTECTED]> wrote:
...
> isn't the django API supposed to be portable across different database
> platforms? Does iregex make an exception because of SQLite lack of reg-
> exp support?

It tries, but isn't heroic.  The options for total portability would
be either no regex support at all (since SQLite doesn't support it),
or an adapting shim (as it currently does) or maybe even dropping
SQLite as an option.

I think the adaptation approach is a good option.

>If that's the case then the code has to be changed when
> moving to production (that is, likely to a different database
> platform)?

Not really-- you could build your regex based on the engine:

from django.conf import settings

if settings.DATABASE_ENGINE == 'sqlite':
   re = something
else:
  re = something_else

That may make you cringe, but it only makes explicit what is really
going on when you push to prod w/ modified code anyway.

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

2007-11-20 Thread michel bruavics

Hi djangos,

I check out the django.test.client and want to load a fixture file
called "myfixture.xml".

I added in my project setting a folder (called fixtures):
FIXTURE_DIRS = ('/workspace/project/fixtures/')

myfixture.xml is inside of the folder fixtures.

now I try to load the fixture in my tests.py:

class TestSurfer(unittest.TestCase):
fixtures = ['myfixture.xml']


But it doesn't load the fixture.
I try other names, other places but nothing works for me. I only can
load a file when it's named "initial_data.xml".

Can somebody tell me what I do wrong?


thanks, regards michel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 define choices that works in admin interface?

2007-11-20 Thread Christian Joergensen

David Marko wrote:
> How to define choices for filed that works in admin interface? When I
> define CharField as below, the list of choices is computed intially
> and doesn't refresh when data changes in Choices table.
> 
> type = models.CharField(verbose_name='Type', maxlength=30, choices =
> Choice.filter(""), null=False, blank=False)

Normally, one would use a foreign key in this case:

choice = models.ForeignKey(Choice)

Regards,

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  | Visit us at: http://www.gmta.info

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



Consistency between Django syndication framework & generic views (at least)

2007-11-20 Thread [EMAIL PROTECTED]

Hello,

After reading and viewing the screencast on syndication framework [1],
I let a comment on the site where the "obj" comes from ?

Michael points me to the right url and the answer in the doc [2]

[1] 
[2]  

My concerns is that even if it's two distinct features of Django,
naming convention should be the same I think and that "object" should
be used instead of "obj". At least for consistence purposes.

I do not know if it applies to other part of Django.

Does it make sense ?

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

2007-11-20 Thread cesco

Thanks for the reply.
I'm actually trying to match a word boundary with "\\b" before and
after the string, not a backspace. Still one thing is unclear to me:
isn't the django API supposed to be portable across different database
platforms? Does iregex make an exception because of SQLite lack of reg-
exp support? If that's the case then the code has to be changed when
moving to production (that is, likely to a different database
platform)?

Thanks again
Francesco

On Nov 20, 12:58 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2007-11-19 at 13:59 -0800, cesco wrote:
> > Sorry for the imprecise description of the problem.
>
> > After some filtering statements (which I don't show here) I derive a
> > qs containing about 1000 objects.
> > With the following statement I try to filter the query further
> > new_qs = qs.filter(models.Q(myField__iregex="\\b%s\\b" % myString)
> > and new_qs comes to have 93 objects.
> > This happens locally where I'm running sqlite3.
>
> > In the production server (which I currently can't access, so I can't
> > compare the sql statements) I have the same database (except that I'm
> > using Postgresql 8.2).
> > The qs which I have before the "critical" filter statement contains
> > the same objects (about 1000 of them). After I apply the same
> > filtering I get a resulting qs which is empty. So no error message or
> > infinite loop. Just a different unexpected result.
>
> Does the SQL produced by Django make sense for PostgreSQL? Once you know
> that it's likely to be an SQL selection problem, the next step is to
> look at the SQL generated and see if it's what you expect.
>
> The problem is almost certainly the '\b' in your regex, since that is
> trying to match "backspace" and I suspect you want '\m' in the first
> case and '\M' in the second one. SQLite doesn't have native regexp
> matching, so Django provides an interface to Python's regular expression
> module. However, this isn't the same as the reg-exp syntax used by
> PostgreSQL.
>
> Regards,
> Malcolm
>
> --
> I've got a mind like a... a... what's that thing 
> called?http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to define choices that works in admin interface?

2007-11-20 Thread David Marko

How to define choices for filed that works in admin interface? When I
define CharField as below, the list of choices is computed intially
and doesn't refresh when data changes in Choices table.

type = models.CharField(verbose_name='Type', maxlength=30, choices =
Choice.filter(""), null=False, blank=False)

Thanks for any hint.

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?hl=en
-~--~~~~--~~--~--~---



Re: Custom ManyToManyField widget in admin

2007-11-20 Thread Julien

Hi,

When I look at the html source code generated for the regular
ManyToManyField's widget, it's an html form, not javascript...
Are you sure there is no other way?

Could you please give a full example?

I've spent quite sometime practicing with the tutorials but I'm a bit
lost on this one.

Thanks a lot!


On Nov 20, 9:04 pm, kamil <[EMAIL PROTECTED]> wrote:
> I dont think there is another way that making your hands dirty with
> javascript. ;)
> If you want to be fancy you can even make it ajax - getting the cities
> on demand
>
> On Nov 20, 9:35 am, kamil <[EMAIL PROTECTED]> wrote:
>
> > You can easily generate cities list to the javascript dynamically
> > writing the template for separate js file.
>
> > On Nov 20, 9:22 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > Hi Kamil,
>
> > > Thanks a lot for your suggestion!
>
> > > I have a few remarks though. The list of cities is dynamic, in the
> > > sense that you may add, remove cities from the database at any time
> > > using the admin interface.
> > > So how can we fetch dynamically the list of available cities to
> > > display them in the select widget?
>
> > > Also, isn't there a "recommended" way of doing? Hijacking with
> > > javascript seems more like a trick. I may be wrong.
>
> > > Thanks!  ;)
>
> > > On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Julien
>
> > > > The simple way is hijack city select box with javascript.
> > > > You add
> > > > js=['http://herecomespathtoyour script']
> > > > to admin options in your model
> > > > js can look like this:
>
> > > > var countries = {'england': ['London','Manchester'], 'france':
> > > > ['Paris'] }
>
> > > > document.forms['your_form'].id_country.onchange = function()
> > > > { listCities(this.value) };
>
> > > > function listCities ( country ) {
> > > > document.forms['your_form'].id_city.options.length = 0
> > > > var l = countries[ country ].length;
> > > > for (var i = 0; l > i; i++) {
> > > > document.forms['your_form'].id_city.options[i] = new
> > > > Option( countries[ country ][i], countries[ country ][i]);
> > > > }
>
> > > > }
>
> > > > I hope it helps :)
>
> > > > On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > Sorry, my "drawing" came out a bit funny in my previous post. Here's
> > > > > what I'd like the custom widget to look like:
>
> > > > > England
> > > > > [  ] London   [  ] Manchester
> > > > > France
> > > > > [  ] Paris
> > > > > Russia
> > > > > [  ] Moscow
> > > > > USA
> > > > > [  ] Los Angeles   [  ] New York
>
> > > > > Thanks for your help!
>
> > > > > On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi all,
>
> > > > > > I'm a Django newbie, and I've been struggling on this for days. I've
> > > > > > also found posts on this group about similar subjects but none that
> > > > > > could directly help me...
>
> > > > > > Here are the models I've got:
>
> > > > > > class Country(models.Model):
> > > > > > name = models.CharField(max_length=50)
> > > > > > def __unicode__(self):
> > > > > > return self.name
> > > > > > class Admin:
> > > > > > pass
>
> > > > > > class City(models.Model):
> > > > > > name = models.CharField(max_length=50)
> > > > > > country = models.ForeignKey(Country)
> > > > > > def __unicode__(self):
> > > > > > return self.name
> > > > > > class Admin:
> > > > > > pass
>
> > > > > > class Person(models.Model):
> > > > > > firstName = models.CharField(max_length=30)
> > > > > > lastName = models.CharField(max_length=30)
> > > > > > citiesLived = models.ManyToManyField(City, null=True, 
> > > > > > blank=True)
> > > > > > def __unicode__(self):
> > > > > > return self.firstName + " " + self.lastName
> > > > > > class Admin:
> > > > > > pass
>
> > > > > > In the admin interface, when adding cities to a person's profile, 
> > > > > > you
> > > > > > get the usual ManyToMany select box.
>
> > > > > > So you may have:
> > > > > > New York
> > > > > > Manchester
> > > > > > Paris
> > > > > > London
> > > > > > Moscow
> > > > > > Los Angeles
>
> > > > > > What I'd like to get instead is a custom widget, that is a list of
> > > > > > checkboxes sorted by country, and in Alphabetic order. E.g.:
> > > > > > 
> > > > > > |
> > > > > > England
> > > > > > |
> > > > > > |[  ] London   [  ]
> > > > > > Manchester  |
> > > > > > |
> > > > > > France
> > > > > > |
> > > > > > |[  ]
> > > > > > Paris
> > > > > > |
> > > > > > |
> > > > > > Russia
> > > > > > |
> > > > > > |[  ]
> > > > > > Moscow
> > > > > > |
> > > > > > |
> > > > > > USA
> > > > > > |
> > > > > > |[  ] Los Angeles   [  ] New York
> > > > > > |
> > > > > > |___|
>
> > > > > > Could you give me some advice on how to implement that?
>
> > > > > > Many thanks!!
>
> > > > > > Julien

Re: Custom methods for ManyToManyManager

2007-11-20 Thread Tomi Pieviläinen

> I've been hacking some filtering for related managers, have a look at
> the BoxManager 
> here:http://django-pm.googlecode.com/svn/trunk/myproject/pm/models.py

Thanks for food for thoughts. Looking at your code got me thinking and
in the end my problem was really simple. I was using the examples in
the documentation a bit too literarily and tried:

def get_query_set(self):
return super(MaleManager,
self).get_query_set().filter(sex='M')

while I shouldn't use super but just self.get_query_set() which
returns the filtered 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?hl=en
-~--~~~~--~~--~--~---



Error Handeling

2007-11-20 Thread Rufman

Hey

I know that django has error handlers for errors 404 and 500.
My question: Could I just make my own handler and add it to the
defaults in django.conf.urls.defaults? (for example 403 Forbidden)

Thanks

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

2007-11-20 Thread kamil

I dont think there is another way that making your hands dirty with
javascript. ;)
If you want to be fancy you can even make it ajax - getting the cities
on demand

On Nov 20, 9:35 am, kamil <[EMAIL PROTECTED]> wrote:
> You can easily generate cities list to the javascript dynamically
> writing the template for separate js file.
>
> On Nov 20, 9:22 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > Hi Kamil,
>
> > Thanks a lot for your suggestion!
>
> > I have a few remarks though. The list of cities is dynamic, in the
> > sense that you may add, remove cities from the database at any time
> > using the admin interface.
> > So how can we fetch dynamically the list of available cities to
> > display them in the select widget?
>
> > Also, isn't there a "recommended" way of doing? Hijacking with
> > javascript seems more like a trick. I may be wrong.
>
> > Thanks!  ;)
>
> > On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > > Hi Julien
>
> > > The simple way is hijack city select box with javascript.
> > > You add
> > > js=['http://herecomespathto your script']
> > > to admin options in your model
> > > js can look like this:
>
> > > var countries = {'england': ['London','Manchester'], 'france':
> > > ['Paris'] }
>
> > > document.forms['your_form'].id_country.onchange = function()
> > > { listCities(this.value) };
>
> > > function listCities ( country ) {
> > > document.forms['your_form'].id_city.options.length = 0
> > > var l = countries[ country ].length;
> > > for (var i = 0; l > i; i++) {
> > > document.forms['your_form'].id_city.options[i] = new
> > > Option( countries[ country ][i], countries[ country ][i]);
> > > }
>
> > > }
>
> > > I hope it helps :)
>
> > > On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > Sorry, my "drawing" came out a bit funny in my previous post. Here's
> > > > what I'd like the custom widget to look like:
>
> > > > England
> > > > [  ] London   [  ] Manchester
> > > > France
> > > > [  ] Paris
> > > > Russia
> > > > [  ] Moscow
> > > > USA
> > > > [  ] Los Angeles   [  ] New York
>
> > > > Thanks for your help!
>
> > > > On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi all,
>
> > > > > I'm a Django newbie, and I've been struggling on this for days. I've
> > > > > also found posts on this group about similar subjects but none that
> > > > > could directly help me...
>
> > > > > Here are the models I've got:
>
> > > > > class Country(models.Model):
> > > > > name = models.CharField(max_length=50)
> > > > > def __unicode__(self):
> > > > > return self.name
> > > > > class Admin:
> > > > > pass
>
> > > > > class City(models.Model):
> > > > > name = models.CharField(max_length=50)
> > > > > country = models.ForeignKey(Country)
> > > > > def __unicode__(self):
> > > > > return self.name
> > > > > class Admin:
> > > > > pass
>
> > > > > class Person(models.Model):
> > > > > firstName = models.CharField(max_length=30)
> > > > > lastName = models.CharField(max_length=30)
> > > > > citiesLived = models.ManyToManyField(City, null=True, blank=True)
> > > > > def __unicode__(self):
> > > > > return self.firstName + " " + self.lastName
> > > > > class Admin:
> > > > > pass
>
> > > > > In the admin interface, when adding cities to a person's profile, you
> > > > > get the usual ManyToMany select box.
>
> > > > > So you may have:
> > > > > New York
> > > > > Manchester
> > > > > Paris
> > > > > London
> > > > > Moscow
> > > > > Los Angeles
>
> > > > > What I'd like to get instead is a custom widget, that is a list of
> > > > > checkboxes sorted by country, and in Alphabetic order. E.g.:
> > > > > 
> > > > > |
> > > > > England
> > > > > |
> > > > > |[  ] London   [  ]
> > > > > Manchester  |
> > > > > |
> > > > > France
> > > > > |
> > > > > |[  ]
> > > > > Paris
> > > > > |
> > > > > |
> > > > > Russia
> > > > > |
> > > > > |[  ]
> > > > > Moscow
> > > > > |
> > > > > |
> > > > > USA
> > > > > |
> > > > > |[  ] Los Angeles   [  ] New York
> > > > > |
> > > > > |___|
>
> > > > > Could you give me some advice on how to implement that?
>
> > > > > Many thanks!!
>
> > > > > Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Who wants to work when money comes for free

2007-11-20 Thread cschand

Hi Salim

  Please stop these type of stupid ads here


On Nov 20, 2:38 pm, Salimc <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> Finally a program that seriously pays for just watching the adds.
> You have to just click the links in their system and watch the add for
> 30 seconds and that's it your account will have the  allocated for
> that ad.
>
> Simple and sweet.
>
> It is really that easy. get a huge earning cheque every month sitting
> at home.
>
> Above all you don't have to pay anything to earn.
>
> just click the link below or copy and paste in your browser to get
> started.
>
> http://www.clixsense.com/?2279471
>
> Best Regards
>
> Salim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Who wants to work when money comes for free

2007-11-20 Thread Salimc

Dear All,

Finally a program that seriously pays for just watching the adds.
You have to just click the links in their system and watch the add for
30 seconds and that's it your account will have the  allocated for
that ad.

Simple and sweet.

It is really that easy. get a huge earning cheque every month sitting
at home.

Above all you don't have to pay anything to earn.

just click the link below or copy and paste in your browser to get
started.

http://www.clixsense.com/?2279471

Best Regards

Salim

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



Get free $3 to sign up and then sky is the limit

2007-11-20 Thread Salimc

Dear All,

Finally a program that seriously pays for just watching the adds.
US$ 3 free for just signing up.
You have to just click the links in their system and watch the add for
30 seconds and that's it your account will have the  allocated for
that ad.

You wanna earn more refer to others and get commission from their
earning as well.

Simple and sweet.

It is really that easy. get a huge earning every month sitting at
home.

Above all you don't have to pay anything to earn.

just click the link below or copy and paste it in your browser to get
started.

http://clix4coins.com/index1.php?ref=salimc


Best Regards

Salim

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

2007-11-20 Thread kamil

You can easily generate cities list to the javascript dynamically
writing the template for separate js file.



On Nov 20, 9:22 am, Julien <[EMAIL PROTECTED]> wrote:
> Hi Kamil,
>
> Thanks a lot for your suggestion!
>
> I have a few remarks though. The list of cities is dynamic, in the
> sense that you may add, remove cities from the database at any time
> using the admin interface.
> So how can we fetch dynamically the list of available cities to
> display them in the select widget?
>
> Also, isn't there a "recommended" way of doing? Hijacking with
> javascript seems more like a trick. I may be wrong.
>
> Thanks!  ;)
>
> On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > Hi Julien
>
> > The simple way is hijack city select box with javascript.
> > You add
> > js=['http://herecomespath to your script']
> > to admin options in your model
> > js can look like this:
>
> > var countries = {'england': ['London','Manchester'], 'france':
> > ['Paris'] }
>
> > document.forms['your_form'].id_country.onchange = function()
> > { listCities(this.value) };
>
> > function listCities ( country ) {
> > document.forms['your_form'].id_city.options.length = 0
> > var l = countries[ country ].length;
> > for (var i = 0; l > i; i++) {
> > document.forms['your_form'].id_city.options[i] = new
> > Option( countries[ country ][i], countries[ country ][i]);
> > }
>
> > }
>
> > I hope it helps :)
>
> > On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > > Sorry, my "drawing" came out a bit funny in my previous post. Here's
> > > what I'd like the custom widget to look like:
>
> > > England
> > > [  ] London   [  ] Manchester
> > > France
> > > [  ] Paris
> > > Russia
> > > [  ] Moscow
> > > USA
> > > [  ] Los Angeles   [  ] New York
>
> > > Thanks for your help!
>
> > > On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > Hi all,
>
> > > > I'm a Django newbie, and I've been struggling on this for days. I've
> > > > also found posts on this group about similar subjects but none that
> > > > could directly help me...
>
> > > > Here are the models I've got:
>
> > > > class Country(models.Model):
> > > > name = models.CharField(max_length=50)
> > > > def __unicode__(self):
> > > > return self.name
> > > > class Admin:
> > > > pass
>
> > > > class City(models.Model):
> > > > name = models.CharField(max_length=50)
> > > > country = models.ForeignKey(Country)
> > > > def __unicode__(self):
> > > > return self.name
> > > > class Admin:
> > > > pass
>
> > > > class Person(models.Model):
> > > > firstName = models.CharField(max_length=30)
> > > > lastName = models.CharField(max_length=30)
> > > > citiesLived = models.ManyToManyField(City, null=True, blank=True)
> > > > def __unicode__(self):
> > > > return self.firstName + " " + self.lastName
> > > > class Admin:
> > > > pass
>
> > > > In the admin interface, when adding cities to a person's profile, you
> > > > get the usual ManyToMany select box.
>
> > > > So you may have:
> > > > New York
> > > > Manchester
> > > > Paris
> > > > London
> > > > Moscow
> > > > Los Angeles
>
> > > > What I'd like to get instead is a custom widget, that is a list of
> > > > checkboxes sorted by country, and in Alphabetic order. E.g.:
> > > > 
> > > > |
> > > > England
> > > > |
> > > > |[  ] London   [  ]
> > > > Manchester  |
> > > > |
> > > > France
> > > > |
> > > > |[  ]
> > > > Paris
> > > > |
> > > > |
> > > > Russia
> > > > |
> > > > |[  ]
> > > > Moscow
> > > > |
> > > > |
> > > > USA
> > > > |
> > > > |[  ] Los Angeles   [  ] New York
> > > > |
> > > > |___|
>
> > > > Could you give me some advice on how to implement that?
>
> > > > Many thanks!!
>
> > > > Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: weird "can't adapt" error

2007-11-20 Thread Sandro Dentella

On Tue, Nov 20, 2007 at 01:17:50AM -0800, Jarek Zgoda wrote:
> 
> I just started receiving the same problem when I try to save an object
> that has non-ASCII values in char field (the values are all properly
> decoded to unicode)> This seems related to psycopg2 backend, as I do
> not observe such behaviour on my dev server with sqlite3 backend. The
> model is similar to:
> 
> class Label(models.Model):
> title = models.CharField(max_length=200, unique=True)
> 
> the code that leads to exception is like:
> 
> t = 'żołędzie'.decode('utf-8')
> label = Label(title=t)
> label.save()
> 
> The traceback from ipython:

what makes my case different from this is that the same code creates
probelm from one browser and not from another in a repeatable way. Both are
firefox but running on linux (no probelma) or windows (can't adapt).

I didn't solve it, but it's a month it doesn't happen again...

sandro
*:-)

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

2007-11-20 Thread kamil

Hi Julien

The simple way is hijack city select box with javascript.
You add
js=['http://here comes path to your script']
to admin options in your model
js can look like this:

var countries = {'england': ['London','Manchester'], 'france':
['Paris'] }

document.forms['your_form'].id_country.onchange = function()
{ listCities(this.value) };

function listCities ( country ) {
document.forms['your_form'].id_city.options.length = 0
var l = countries[ country ].length;
for (var i = 0; l > i; i++) {
document.forms['your_form'].id_city.options[i] = new
Option( countries[ country ][i], countries[ country ][i]);
}
}

I hope it helps :)

On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
> Sorry, my "drawing" came out a bit funny in my previous post. Here's
> what I'd like the custom widget to look like:
>
> England
> [  ] London   [  ] Manchester
> France
> [  ] Paris
> Russia
> [  ] Moscow
> USA
> [  ] Los Angeles   [  ] New York
>
> Thanks for your help!
>
> On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I'm a Django newbie, and I've been struggling on this for days. I've
> > also found posts on this group about similar subjects but none that
> > could directly help me...
>
> > Here are the models I've got:
>
> > class Country(models.Model):
> > name = models.CharField(max_length=50)
> > def __unicode__(self):
> > return self.name
> > class Admin:
> > pass
>
> > class City(models.Model):
> > name = models.CharField(max_length=50)
> > country = models.ForeignKey(Country)
> > def __unicode__(self):
> > return self.name
> > class Admin:
> > pass
>
> > class Person(models.Model):
> > firstName = models.CharField(max_length=30)
> > lastName = models.CharField(max_length=30)
> > citiesLived = models.ManyToManyField(City, null=True, blank=True)
> > def __unicode__(self):
> > return self.firstName + " " + self.lastName
> > class Admin:
> > pass
>
> > In the admin interface, when adding cities to a person's profile, you
> > get the usual ManyToMany select box.
>
> > So you may have:
> > New York
> > Manchester
> > Paris
> > London
> > Moscow
> > Los Angeles
>
> > What I'd like to get instead is a custom widget, that is a list of
> > checkboxes sorted by country, and in Alphabetic order. E.g.:
> > 
> > |
> > England
> > |
> > |[  ] London   [  ]
> > Manchester  |
> > |
> > France
> > |
> > |[  ]
> > Paris
> > |
> > |
> > Russia
> > |
> > |[  ]
> > Moscow
> > |
> > |
> > USA
> > |
> > |[  ] Los Angeles   [  ] New York
> > |
> > |___|
>
> > Could you give me some advice on how to implement that?
>
> > Many thanks!!
>
> > Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using "select_related" .Does it works?

2007-11-20 Thread Samuel Adam

The purpose of select_related() is to limit the number of connections
to the database server.

An analogy would be that if you have a webpage with 4 CSS file
inclusions ( >> from pm.models import Message
>>> from django.db import connection
>>> message = Message.objects.get(pk=1)
>>> '%s sent a message to %s' % (message.sender.username, message.recipient.user
name)
u'admin sent a message to admin'
>>> len(connection.queries)
3
>>>

With select_related(), only one:
>>> from pm.models import Message
>>> from django.db import connection
>>> message = Message.objects.select_related().get(pk=1)
>>> '%s sent a message to %s' % (message.sender.username, message.recipient.user
name)
u'admin sent a message to admin'
>>> len(connection.queries)
1
>>>



The footnote of the select_related chapter is very important:

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

Note that select_related() does not follow foreign keys that have
null=True.

Usually, using select_related() can vastly improve performance because
your app can avoid many database calls. However, in situations with
deeply nested sets of relationships select_related() can sometimes end
up following "too many" relations, and can generate queries so large
that they end up being slow.

In these situations, you can use the depth argument to
select_related() to control how many "levels" of relations
select_related() will actually follow:

b = Book.objects.select_related(depth=1).get(id=4)
p = b.author # Doesn't hit the database.
c = p.hometown   # Requires a database call.

The depth argument is new in the Django development version.


On Nov 20, 9:22 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Greg_IAP napisał(a):
>
>
>
> > Hello,
>
> > i have 3 classes.
>
> > class Image(models.Model):
> >name = models.CharField(max_length = 20,blank=True)
> >instrument = models.ForeignKey(Instrument,null=True,blank=
> > True,db_column='instrument_id')
> >channel = models.ForeignKey(Channel,null=True,blank=
> > True,db_column='channel_id')
> >...
>
> > class Instrument(models.Model):
> >name = models.CharField(max_length = 240, blank=True)
> >...
>
> > class Channel(models.Model):
> >name = models.CharField(max_length = 80,blank=True)
> >...
>
> > I just want to make a join through this tables with the select_related
> > to be able to print Image.name, Instrument.name, Channel.name
>
> The docs say select_related() does not follow foreign keys that have
> null=True. In your example it would do nothing.
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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 ManyToManyField widget in admin

2007-11-20 Thread Julien

Hi Kamil,

Thanks a lot for your suggestion!

I have a few remarks though. The list of cities is dynamic, in the
sense that you may add, remove cities from the database at any time
using the admin interface.
So how can we fetch dynamically the list of available cities to
display them in the select widget?

Also, isn't there a "recommended" way of doing? Hijacking with
javascript seems more like a trick. I may be wrong.

Thanks!  ;)

On Nov 20, 8:13 pm, kamil <[EMAIL PROTECTED]> wrote:
> Hi Julien
>
> The simple way is hijack city select box with javascript.
> You add
> js=['http://herecomes path to your script']
> to admin options in your model
> js can look like this:
>
> var countries = {'england': ['London','Manchester'], 'france':
> ['Paris'] }
>
> document.forms['your_form'].id_country.onchange = function()
> { listCities(this.value) };
>
> function listCities ( country ) {
> document.forms['your_form'].id_city.options.length = 0
> var l = countries[ country ].length;
> for (var i = 0; l > i; i++) {
> document.forms['your_form'].id_city.options[i] = new
> Option( countries[ country ][i], countries[ country ][i]);
> }
>
> }
>
> I hope it helps :)
>
> On Nov 19, 11:54 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > Sorry, my "drawing" came out a bit funny in my previous post. Here's
> > what I'd like the custom widget to look like:
>
> > England
> > [  ] London   [  ] Manchester
> > France
> > [  ] Paris
> > Russia
> > [  ] Moscow
> > USA
> > [  ] Los Angeles   [  ] New York
>
> > Thanks for your help!
>
> > On Nov 20, 10:51 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > Hi all,
>
> > > I'm a Django newbie, and I've been struggling on this for days. I've
> > > also found posts on this group about similar subjects but none that
> > > could directly help me...
>
> > > Here are the models I've got:
>
> > > class Country(models.Model):
> > > name = models.CharField(max_length=50)
> > > def __unicode__(self):
> > > return self.name
> > > class Admin:
> > > pass
>
> > > class City(models.Model):
> > > name = models.CharField(max_length=50)
> > > country = models.ForeignKey(Country)
> > > def __unicode__(self):
> > > return self.name
> > > class Admin:
> > > pass
>
> > > class Person(models.Model):
> > > firstName = models.CharField(max_length=30)
> > > lastName = models.CharField(max_length=30)
> > > citiesLived = models.ManyToManyField(City, null=True, blank=True)
> > > def __unicode__(self):
> > > return self.firstName + " " + self.lastName
> > > class Admin:
> > > pass
>
> > > In the admin interface, when adding cities to a person's profile, you
> > > get the usual ManyToMany select box.
>
> > > So you may have:
> > > New York
> > > Manchester
> > > Paris
> > > London
> > > Moscow
> > > Los Angeles
>
> > > What I'd like to get instead is a custom widget, that is a list of
> > > checkboxes sorted by country, and in Alphabetic order. E.g.:
> > > 
> > > |
> > > England
> > > |
> > > |[  ] London   [  ]
> > > Manchester  |
> > > |
> > > France
> > > |
> > > |[  ]
> > > Paris
> > > |
> > > |
> > > Russia
> > > |
> > > |[  ]
> > > Moscow
> > > |
> > > |
> > > USA
> > > |
> > > |[  ] Los Angeles   [  ] New York
> > > |
> > > |___|
>
> > > Could you give me some advice on how to implement that?
>
> > > Many thanks!!
>
> > > Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: weird "can't adapt" error

2007-11-20 Thread Jarek Zgoda

I just started receiving the same problem when I try to save an object
that has non-ASCII values in char field (the values are all properly
decoded to unicode)> This seems related to psycopg2 backend, as I do
not observe such behaviour on my dev server with sqlite3 backend. The
model is similar to:

class Label(models.Model):
title = models.CharField(max_length=200, unique=True)

the code that leads to exception is like:

t = 'żołędzie'.decode('utf-8')
label = Label(title=t)
label.save()

The traceback from ipython:

/home/zgoda/www/zgodowie/blog/models.py in save(self)
 42 if not self.slug:
 43 self.slug = slughifi(self.title)
---> 44 super(Label, self).save()
 45
 46

/home/zgoda/www/.python/lib/python2.4/site-packages/django/db/models/
base.py in save(self, raw)
257 cursor.execute("INSERT INTO %s (%s) VALUES
(%s)" % \
258 (qn(self._meta.db_table),
','.join(field_names),
--> 259 ','.join(placeholders)), db_values)
260 else:
261 # Create a new record with defaults for
everything.

ProgrammingError: can't adapt

I use SVN trunk rev. 6702.

On 26 Paź, 09:47, sandro dentella <[EMAIL PROTECTED]> wrote:
> On 26 Set, 12:59, Sandro Dentella <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> >   I'm meeting a weird problem in adjangoapplication.
> >   It works w/o any problem from my pc connecting remotely to my customer's
> >   apache but is not working inside the lan.
>
> >   I'm connecting from firefox/ubuntu they're connecting from firefox/XP.
>
> >   the weird part is that:
>
> > 1. they have being working w/o probelms for 10 days and no modifications
> >where made
>
> > 2. the error complains "can'tadapt" as if trying to insert wrong types
> >into the db, but the error trace shows the values are correct
>
> > 3. a restart of apache fixes the problem
>
> > 4. this is the second time the error happens...
>
> >   Any hints?
> >   TIA
> >   sandro
> >   *:-)
>
> Hi,
>
>   once again I stumble into this problem. This time I gathered some
> more
>   info so I describe them.
>
>   I try to insert a record it fails from a Windows pc with Firefox
> (and
>   IE). It works from linux (firefox or galeon).
>
>   When it fails the error message is "can't adapt" but
>
>   1. the params in the log are:
>   ('2007-10-26 08:50:03.651993', '2007-10-26 08:50:03.652039', 1, 17,
>   '2007-10-26', u'2', Decimal("100"), 'h', u'prova in fi'
>
>   2. from my linux box I print params before a *working* insert and I
> get:
>   ['2007-10-26 09:17:44.744656', '2007-10-26 09:17:44.744682', 1, 17,
> '2007-10-26', u'2', Decimal("100"), 'h', u'prova']
>
>Not realy different
>
>   3. When it fails the database is not hit. Db is postgres and I
> switched on
>  statement log on every log:
>
>  log_min_duration_statement = 0
>
>   4. If I restart apache the error is fixed
>
>   I'm running mod_wsgi
>
> What should I do, next time it happens to better investigate. It's
> already
> happened 4 times in 2 months and I cannot just accept it...
>
> Thanks for any possible help
>
> sandro
> *:-)
>
> the insert statement that worked follows:
>
> INSERT INTO
> "timereport_report" 
> ("date_create","date_last_modify","status","user_id","date","job_id","qty","unit","description")
> VALUES ('2007-10-26 10:09:07.721575','2007-10-26 10:09:07.721619',
> 1,17,'2007-10-26','2',100,'h','prova in fi2')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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-multilingual

2007-11-20 Thread Marcin Kaszynski



On Nov 20, 2:23 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> from the 'introduction' page, the links to the 'installation' and
> 'usage' pages are broken

Fixed, thanks!

-mk

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



Re: using "select_related" .Does it works?

2007-11-20 Thread Jarek Zgoda

Greg_IAP napisał(a):
> Hello,
> 
> i have 3 classes.
> 
> class Image(models.Model):
>name = models.CharField(max_length = 20,blank=True)
>instrument = models.ForeignKey(Instrument,null=True,blank=
> True,db_column='instrument_id')
>channel = models.ForeignKey(Channel,null=True,blank=
> True,db_column='channel_id')
>...
> 
> class Instrument(models.Model):
>name = models.CharField(max_length = 240, blank=True)
>...
> 
> class Channel(models.Model):
>name = models.CharField(max_length = 80,blank=True)
>...
> 
> I just want to make a join through this tables with the select_related
> to be able to print Image.name, Instrument.name, Channel.name

The docs say select_related() does not follow foreign keys that have
null=True. In your example it would do nothing.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



  1   2   >