Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck

Malcolm,

Thanks for the comment.
I truly understand where this is coming from. This issue is completely
my issue of taking things for granted.
I have been coding around in Django for a while now (hooked on in the
0.95 days), and have been coding most of the form stuff (including
inlines) all by hand.
When I noticed the Formset class, I tried to make it work in the wrong
place.
Brian pointed me to the inlineformsets documentation and I have not
been happier.
It really is easy now to build forms with inlines.

This stuff has come a long way, and life will be much easier than it
was before.

Thanks for Django,

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



Re: Django Training

2008-12-11 Thread Steve Holden

Thanks to everyone for the feedback. This list is invaluable for
discovering the answer to questions, and many of the more active
contributors could write and/or present classes themselves. I guess I
am lucky that they have day jobs :). But it takes time to climb the
learning curve by asking questions via a list, and some people would
like to get a more focused start.

Though I think a one-day class that runs through the tutorial might
fly, I was thinking two or three days would be more appropriate, as it
would give time to get into rather more of the framework and leave
students closer to "production-ready". My own experience after
completing the tutorial was that there was a vast expanse of stuff
still to learn, and not too much guidance in the documentation (though
this is improving over time).

I just finished presenting our fourth public Python class, and the
students there expressed an interest in Django training second only to
"more advanced Python". So I think there's likely to be a market. It's
just a question of the content and sequencing.

regards
 Steve

On Dec 10, 2:28 am, "Skylar Saveland" 
wrote:
> +1, Perhaps building a fully-working site using all parts of Django,
> implementing interesting and useful features.  Also setting-up with reverse
> proxy/static server with lean, fast networking.  Depends on how long the
> class is I suppose.
>
> On Tue, Dec 9, 2008 at 3:32 PM, Jane  wrote:
>
> > I think it would be good to ask students how they plan to use django.
> > For myself, we'd like to deploy databases on a web page, and I'm
> > interested to learn how much of that can be done in python and django,
> > then what do you add to make the database look pretty for outside
> > users.
>
> > On Dec 8, 11:06 am, Steve Holden  wrote:
> > > I am looking at expanding our training offerings for the coming year,
> > > and a short course in Django looks like it might be popular. There
> > > don't seem to be many Django classes at the moment, and several of the
> > > students from our introductory Python classes expressed interest in
> > > Django.
>
> > > Without wanting anyone on the list to do my work for me, it would be
> > > useful to see some opinions about what to include. The tutorial gives
> > > people a good start: should we assume that anyone who wants to take
> > > the class has already run through that, or would it be better to start
> > > from scratch?
>
> > > Django is such a rich platform it would be possible to write several
> > > classes: what material do readers regard as the "essentials of
> > > Django", and what should be relegated to more advanced classes? What
> > > can I do to put a compelling introductory class together?
>
> > > regards
> > >  Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 20:55 -0800, maeck wrote:
[...]
> Now I can pass the fieldnames as values('parent') for now, It would be
> easier if initial did not care if the _id is provided or not.
> Or am I missing something else?

What you're missing, or rather, assuming, is that querysets are ideal or
intended to be used directly as initial data, and that isn't the case.
Forms are separate pieces of code from models and shouldn't have to
understand all the foibles of models (i.e. enforce loose coupling). If
you want to pass in the results of a queryset directly, it's easy, but
you do have to take care and pass in the right values by specifying the
names of the fields. You know the models you are using, so writing down
their field names isn't particularly onerous.

It happens that values(), by default, returns "parent_id" for historical
reasons. However, we set things up so that you an also ask it to return
"parent" by specifying that in the fields list. So use that
functionality.

If you still think that's all just nit-picking and we should compromise
to avoid the inconvenience, realise how bad it is: first you have to
teach Form's initial data that when they expect "foo", it might really
be spelt "foo_id". The form doesn't know this is a foreign key, it just
knows it's a choice field. But since "_id" isn't the only possible
suffix, now the form has to be able to handle any possible suffix --
"foo_blah", for example -- since the database column name can be
specified in the model. So we're looking at all sorts of possible
alternate names for the key. Thus, the form really needs to have
reference to the full model to inspect all that. Now we're passing in
models and tying the form to the model and it's starting to look like
you really should be using ModelFormSet. Short version: it's just not
worth all the complexity. We have ModelFormSets for standard model->
form conversions and an easy way to produce sequences of dictionaries if
you have other situations where a FormSet is more useful.

These things have a way of being much more complicated than they look on
the surface. :-)

Regards,
Malcolm


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



Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Brian Rosner

On Thu, Dec 11, 2008 at 9:55 PM, maeck  wrote:
> Now I can pass the fieldnames as values('parent') for now, It would be
> easier if initial did not care if the _id is provided or not.
> Or am I missing something else?

You shouldn't be using a regular formset. Django provides model
formsets that know how to deal with this internally. Go read up on
inline formsets which is a layer on top of model formsets.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets

-- 
Brian Rosner
http://oebfare.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Import Error On appache

2008-12-11 Thread Lee

Hi, Malcolm


Thanks a lot. It works!

cheers
Lee


On Dec 12, 12:30 pm, Malcolm Tredinnick 
wrote:
> I've trimmed all but the pertinent bits below.
>
> On Thu, 2008-12-11 at 15:16 -0800, Lee wrote:
>
> [...]
>
> > The django Project folder is IntelligentNotesSystem ( created by
> > django-admin.py startproject IntelligentNotesSystem  ), which is
> > located in C:\Django\IntelligentNotesSystem.
>
> > The application folder is Core (created by python manage.py startapp
> > Core), which is located in C:\Django\IntelligentNotesSystem\Core.
>
> [...]
>
> > 
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     SetEnv DJANGO_SETTINGS_MODULE IntelligentNotesSystem.settings
> >     PythonOption django.root /IntelligentNotesSystem
> >     PythonDebug On
> >     PythonPath "['C:/Django'] + sys.path"
> > 
>
> [...]
>
> > The application runs well in the django server(in this 
> > urlhttp://127.0.0.1:8000/).
> > However, it displays :
>
> > ImportError at /
>
> > No module named Core.forms
>
> To be able to write "import Core" (or "from Core import ..."), the Core
> directory's parent directory needs to be on your Python path. However,
> you only added the parent of IntelligentSystemNotes to your Python path.
> So you can write "from IntelligentSystemNotes import ..." and Python
> will know what to do, since it can see that directory inside one of the
> Python path directories. However, Python has no idea where Core is
> located.
>
> Solution: Add c:/Django/IntelligentSystemNotes/ to your Python path in
> the Apache configuration.
>
> The answer to almost every problem like this when configuring Apache and
> seeing "no module named" is "check your Python path; you've almost
> certainly left out something". :-)
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck

Thanks Malcolm,

Just figured out the values transformation on querysets myself.
Nevertheless, in my experience there seems to be an issue with
foreignkeys when using queryset values in combination with formsets.
Values returns keys like 'parent_id', however formsets expect the
fieldname as 'parent'.
(I am using Django 1.0.2)

Now I can pass the fieldnames as values('parent') for now, It would be
easier if initial did not care if the _id is provided or not.
Or am I missing something else?

Maeck


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



Re: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Glad to help :-)  I know that problem messed us (my coworker and I)
for a while, so I'm glad to see that our fumbling around led to
someone else's solved problem.

-Jeff

On Dec 11, 1:58 pm, Norm Aleks  wrote:
> THANK YOU THANK YOU THANK YOU!!  Oh man, oh man, was that frustrating,
> but hopefully now it won't bite me again.  Yes, I had made a "root"
> user and a "norm" user, I was logged in as norm, and norm's not an
> admin.
>
> All set now!  Thanks again!
>
> Norm
>
> On Dec 11, 10:13 am, Jeff FW  wrote:
>
> > Well, here's another possibly silly question--are you logging into the
> > admin as an admin user?  Otherwise, it's possible you don't have
> > privileges to see the new model.  My coworker did that--took a long
> > time for us to figure out what he was doing wrong ;-)
>
> > Other than that... I dunno.
>
> > On Dec 11, 11:37 am, Norm Aleks  wrote:
>
> > > Thanks, it's not silly.  Yes, I did that (and tables were created, so
> > > the models files at least got seen).
> > > Something else I should have mentioned is that the problem still
> > > occurs when I'm using the internal development server, so I feel like
> > > it's unlikely to be a Dreamhost issue.
> > > Norm
>
> > > On Dec 11, 6:11 am, Jeff FW  wrote:
>
> > > > Possibly a silly question--but did you run syncdb after adding
> > > > staticimage2 to your INSTALLED_APPS?
>
> > > > -Jeff
>
> > > > On Dec 10, 9:49 pm, Norm Aleks  wrote:
>
> > > > > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > > > > trouble getting a new model to show up.  I'm cringing a little because
> > > > > I know this has been a FAQ -- know that I *have* put some effort into
> > > > > Googling this problem, and I read up on the changes to the admin setup
> > > > > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > > > > model that *does* show up in the admin interface, but even though I
> > > > > seem to be setting up the new model completely identically, it's not
> > > > > showing.
>
> > > > > So, here's what I have.  "root.staticimages" is the app that does show
> > > > > up in admin, and "root.staticimages2" is the one that does not.
>
> > > > > First, Django is running under dispatch.fcgi.  When I make changes to
> > > > > the configuration, I kill any running Python processes and also touch
> > > > > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > > > > standard Django error pages.
>
> > > > > Now, my application is named "root" ...
>
> > > > > root/settings.py:
> > > > > 
> > > > > [...]
> > > > > INSTALLED_APPS = (
> > > > >     'django.contrib.auth',
> > > > >     'django.contrib.contenttypes',
> > > > >     'django.contrib.sessions',
> > > > >     'django.contrib.sites',
> > > > >     'treemenus',
> > > > >     'root.staticimages',
> > > > >     'root.staticimages2',
> > > > >     'django.contrib.admin',
> > > > >     'django.contrib.admindocs',
> > > > > )
>
> > > > > root/urls.py:
> > > > > 
> > > > > from django.contrib import admin
> > > > > from views import *
> > > > > from root.songs.models import Artist
>
> > > > > admin.autodiscover()
>
> > > > > urlpatterns = patterns('',
> > > > >     (r'^$', main),
> > > > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > > > >     (r'^admin/(.*)', admin.site.root),
> > > > > )
>
> > > > > root/staticimages/models.py:
> > > > > 
> > > > > from django.db import models
>
> > > > > class StaticImage(models.Model):
> > > > >     image = models.ImageField(upload_to='static_image',
> > > > > height_field='T', width_field='T')
> > > > >     altText = models.TextField()
>
> > > > >     def __unicode__(self):
> > > > >         return self.image.name
>
> > > > > root/staticimages/admin.py:
> > > > > 
> > > > > from django.contrib import admin
> > > > > from root.staticimages.models import StaticImage
>
> > > > > class StaticImageAdmin(admin.ModelAdmin):
> > > > >     pass
>
> > > > > admin.site.register(StaticImage, StaticImageAdmin)
>
> > > > > root/staticimages2/models.py:
> > > > > 
> > > > > from django.db import models
>
> > > > > class StaticImage2(models.Model):
> > > > >     image = models.ImageField(upload_to='static_image',
> > > > > height_field='T', width_field='T')
> > > > >     altText = models.TextField()
>
> > > > >     def __unicode__(self):
> > > > >         return self.image.name
>
> > > > > root/staticimages2/admin.py:
> > > > > 
> > > > > from django.contrib import admin
> > > > > from root.staticimages2.models import StaticImage2
>
> > > > > class StaticImage2Admin(admin.ModelAdmin):
> > > > >     pass
>
> > > > > admin.site.register(StaticImage2, StaticImage2Admin)
>
> > > > > Any help at all would be appreciated, even if it's a suggestion for a
> > > > > better Google search.
>
> > > > > Thanks,
>
> > > > > Norm Aleks
--~--~-~--~~~---~--~~
Yo

Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 20:19 -0800, maeck wrote:
> The example below is a snippet from a view where I use a form to show
> 'Parent' and a formset to show its 'Children'.
> If I get the children as a queryset and pass it on to the formsets
> initial property, it errors out with: 'Parent' object is not iterable
> 
> InlineFormSet   = formset_factory(InlineForm)
> data  = Parent.objects.get(id = data_id)
> form  = ParentForm(instance=data)
> inlinedata= Child.objects.filter(parent_id  = data_id)
> inlineform= InlineChildFormSet(initial=inlinedata)

Initial for data should be a something that is, or at least behaves
like, a sequence of dictionaries. A queryset is behaves like a sequence,
but the elements of that sequence don't behave like dictionaries
(they're objects -- in this case, Parent objects).

So whilst, "for key in obj:" works when "obj" is a dictionary, it
doesn't work when "obj" is a Django Model subclass (e.g. a Parent).

Since the requirement is to pass in a list of dictionaries, using the
values() method on your inlinedata call will get you a long way there.

Regards,
Malcolm



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



FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck

The example below is a snippet from a view where I use a form to show
'Parent' and a formset to show its 'Children'.
If I get the children as a queryset and pass it on to the formsets
initial property, it errors out with: 'Parent' object is not iterable

InlineFormSet   = formset_factory(InlineForm)
data= Parent.objects.get(id = data_id)
form= ParentForm(instance=data)
inlinedata  = Child.objects.filter(parent_id  = data_id)
inlineform  = InlineChildFormSet(initial=inlinedata)



However, the following works (same data, just a list of dicts):

InlineFormSet   = formset_factory(InlineForm)
data= Parent.objects.get(id = data_id)
form= ParentForm(instance=data)
inlinedata  = [ {'a':10, 'b':20}
  {'a':11, 'b':21}
]
inlineform  = InlineChildFormSet(initial=inlinedata)


What am I missing in the first example?


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



Re: unicode/ut8 input in mysql via django models

2008-12-11 Thread I.A

Hi,

I see the documentation pointed out by Karen says:

"All of Django's database backends automatically convert Unicode
strings into the appropriate encoding for talking to the database.
They also automatically convert strings retrieved from the database
into Python Unicode strings. You don't even need to tell Django what
encoding your database uses: that is handled transparently."

All is clear and the sky is blue now.
Thank you Karen and Malcolm!


On 12月12日, 午後12:13, "Karen Tracey"  wrote:
> On Thu, Dec 11, 2008 at 10:02 PM, I.A  wrote:
>
> > Hi,
>
> > I'm wondering the correct way to save unicode data in MySQL through
> > django's models.
> > The application I'm building reads a raw email and then stores the
> > text data into the database. I process the email like so:
>
> > import email
> > mess822 = email.message_from_string(email_raw_data)
> > mail_unicode_data = unicode(mess822.get_payload(),
> > mess822.get_content_charset('utf-8'))
>
> > Nearly all of the email that I get are from Japanese clients emails,
> > mess822.get_content_charset() will usually return 'iso-2022-jp'
>
> > Below is the model i'm using
>
> > class ClientsEmail(models.Model):
> >mail_text = models.CharField(max_length=255)
>
> > And below is the mysql character settings:
>
> > mysql> SHOW VARIABLES LIKE 'char%';
>
> > +--+--+
> > | Variable_name| Value|
> > +--+--+
> > | character_set_client | utf8 |
> > | character_set_connection | utf8 |
> > | character_set_database   | utf8 |
> > | character_set_filesystem | binary   |
> > | character_set_results| utf8 |
> > | character_set_server | utf8 |
> > | character_set_system | utf8 |
> > | character_sets_dir   | /usr/local/share/mysql/charsets/ |
> > +--+--+
>
> > After getting the payload data from the email, I do
>
> > ce = ClientsEmail(mail_text = mail_unicode_data)
> > ce.save()
>
> > and everything looks fine. My question is, is it required/better to
> > do
> > ce = ClientsEmail(mail_text = mail_unicode_data.encode('utf-8'))
> > instead since the db is set for utf-8? or is this part silently
> > handled by django models?
>
> > From what I gather in this thread
>
> >http://groups.google.com/group/django-users/browse_thread/thread/9ba1...
>
> > It looks like it's required, but I would like to be sure.
>
> Better to rely on the current documentation:
>
> http://docs.djangoproject.com/en/dev/ref/unicode/
>
> than a 2.5 year old conversation on the user's list (there have been many
> changes in 2.5 years, including Unicode support throughout Django).
>
> In short, no you don't have to re-encode into a utf-8 bytestring to create
> your model instance.  Django accepts unicode, and the unicode will be
> encoded to a bytestring using the correct encoding before it gets stored in
> the DB.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unicode/ut8 input in mysql via django models

2008-12-11 Thread Karen Tracey
On Thu, Dec 11, 2008 at 10:02 PM, I.A  wrote:

>
> Hi,
>
> I'm wondering the correct way to save unicode data in MySQL through
> django's models.
> The application I'm building reads a raw email and then stores the
> text data into the database. I process the email like so:
>
> import email
> mess822 = email.message_from_string(email_raw_data)
> mail_unicode_data = unicode(mess822.get_payload(),
> mess822.get_content_charset('utf-8'))
>
> Nearly all of the email that I get are from Japanese clients emails,
> mess822.get_content_charset() will usually return 'iso-2022-jp'
>
> Below is the model i'm using
>
> class ClientsEmail(models.Model):
>mail_text = models.CharField(max_length=255)
>
> And below is the mysql character settings:
>
> mysql> SHOW VARIABLES LIKE 'char%';
>
> +--+--+
> | Variable_name| Value|
> +--+--+
> | character_set_client | utf8 |
> | character_set_connection | utf8 |
> | character_set_database   | utf8 |
> | character_set_filesystem | binary   |
> | character_set_results| utf8 |
> | character_set_server | utf8 |
> | character_set_system | utf8 |
> | character_sets_dir   | /usr/local/share/mysql/charsets/ |
> +--+--+
>
> After getting the payload data from the email, I do
>
> ce = ClientsEmail(mail_text = mail_unicode_data)
> ce.save()
>
> and everything looks fine. My question is, is it required/better to
> do
> ce = ClientsEmail(mail_text = mail_unicode_data.encode('utf-8'))
> instead since the db is set for utf-8? or is this part silently
> handled by django models?
>
> From what I gather in this thread
>
> http://groups.google.com/group/django-users/browse_thread/thread/9ba1edf317a9c3e7/caf70ecc9ea72d97?lnk=gst&q=unicode+mysql#caf70ecc9ea72d97
>
> It looks like it's required, but I would like to be sure.
>
>
Better to rely on the current documentation:

http://docs.djangoproject.com/en/dev/ref/unicode/

than a 2.5 year old conversation on the user's list (there have been many
changes in 2.5 years, including Unicode support throughout Django).

In short, no you don't have to re-encode into a utf-8 bytestring to create
your model instance.  Django accepts unicode, and the unicode will be
encoded to a bytestring using the correct encoding before it gets stored in
the DB.

Karen

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



Re: unicode/ut8 input in mysql via django models

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 19:02 -0800, I.A wrote:
> Hi,
> 
> I'm wondering the correct way to save unicode data in MySQL through
> django's models.
> The application I'm building reads a raw email and then stores the
> text data into the database. I process the email like so:
> 
> import email
> mess822 = email.message_from_string(email_raw_data)
> mail_unicode_data = unicode(mess822.get_payload(),
> mess822.get_content_charset('utf-8'))
> 
> Nearly all of the email that I get are from Japanese clients emails,
> mess822.get_content_charset() will usually return 'iso-2022-jp'

[...]


> After getting the payload data from the email, I do
> 
> ce = ClientsEmail(mail_text = mail_unicode_data)
> ce.save()

This is fine. Passing unicode objects to Django will always work.
Converting it back to a UTF-8 encoded bytestring (a Python "str") is
unnecessary.

Regards,
Malcolm



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



unicode/ut8 input in mysql via django models

2008-12-11 Thread I.A

Hi,

I'm wondering the correct way to save unicode data in MySQL through
django's models.
The application I'm building reads a raw email and then stores the
text data into the database. I process the email like so:

import email
mess822 = email.message_from_string(email_raw_data)
mail_unicode_data = unicode(mess822.get_payload(),
mess822.get_content_charset('utf-8'))

Nearly all of the email that I get are from Japanese clients emails,
mess822.get_content_charset() will usually return 'iso-2022-jp'

Below is the model i'm using

class ClientsEmail(models.Model):
mail_text = models.CharField(max_length=255)

And below is the mysql character settings:

mysql> SHOW VARIABLES LIKE 'char%';

+--+--+
| Variable_name| Value|
+--+--+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database   | utf8 |
| character_set_filesystem | binary   |
| character_set_results| utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir   | /usr/local/share/mysql/charsets/ |
+--+--+

After getting the payload data from the email, I do

ce = ClientsEmail(mail_text = mail_unicode_data)
ce.save()

and everything looks fine. My question is, is it required/better to
do
ce = ClientsEmail(mail_text = mail_unicode_data.encode('utf-8'))
instead since the db is set for utf-8? or is this part silently
handled by django models?

>From what I gather in this thread
http://groups.google.com/group/django-users/browse_thread/thread/9ba1edf317a9c3e7/caf70ecc9ea72d97?lnk=gst&q=unicode+mysql#caf70ecc9ea72d97

It looks like it's required, but I would like to be sure.

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



Re: Import Error On appache

2008-12-11 Thread Malcolm Tredinnick

I've trimmed all but the pertinent bits below.

On Thu, 2008-12-11 at 15:16 -0800, Lee wrote:
[...]
> The django Project folder is IntelligentNotesSystem ( created by
> django-admin.py startproject IntelligentNotesSystem  ), which is
> located in C:\Django\IntelligentNotesSystem.
> 
> The application folder is Core (created by python manage.py startapp
> Core), which is located in C:\Django\IntelligentNotesSystem\Core.

[...]
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE IntelligentNotesSystem.settings
> PythonOption django.root /IntelligentNotesSystem
> PythonDebug On
> PythonPath "['C:/Django'] + sys.path"
> 

[...]
> The application runs well in the django server(in this url 
> http://127.0.0.1:8000/).
> However, it displays :
> 
> 
> ImportError at /
> 
> No module named Core.forms

To be able to write "import Core" (or "from Core import ..."), the Core
directory's parent directory needs to be on your Python path. However,
you only added the parent of IntelligentSystemNotes to your Python path.
So you can write "from IntelligentSystemNotes import ..." and Python
will know what to do, since it can see that directory inside one of the
Python path directories. However, Python has no idea where Core is
located.

Solution: Add c:/Django/IntelligentSystemNotes/ to your Python path in
the Apache configuration.

The answer to almost every problem like this when configuring Apache and
seeing "no module named" is "check your Python path; you've almost
certainly left out something". :-)

Regards,
Malcolm


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



Re: how to make the label of form international

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 07:50 -0800, Lucas wrote:
> Hi,
> 
> 
> Now i'm confused with the following point about the international.
> 1. When running make-messages.py,it's showing that xgettext isn't a
> command.
> Does xgettext means xgettext.py or a exe file? Where i can download
> it.

"xgettext" is one of the binaries in the gettext package, which is
external to Python. Since it sounds like you're on Windows, have a read
of this:

http://docs.djangoproject.com/en/dev/topics/i18n/#gettext-on-windows

> 2. For a form, how can i make the label international,for example the
> following name.
> class ContactForm(forms.Form):
> name=forms.CharField()
> I have tired with help_text,but it doesn't work.
> name=forms.CharField(help_text,_('msgid'))

You don't specify what you actually tried to do with help_text. However,
it's not too hard to make this work:

Form fields accept an optional label parameter. If you don't specify it,
the label is derived from the form class attribute, but for
internationalization purposes, you need to specify the label.
Documentation about the label is here:
http://docs.djangoproject.com/en/dev/ref/forms/fields/#label

Your little code sample suggests that you may be guessing the label is
the first positional argument. That isn't correct. Best to write it as
"label=" to avoid any problems.

So, you specify the label and wrap it in a ugettext_lazy() call so that
the string is marked for translation. Thus:

from django.utils.translation import ugettext_lazy as _

class ContactForm(forms.Form):
   name = forms.CharField(label=_("name"))

Best wishes,
Malcolm



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



Re: Is it possible to reverse() into the admin edit views?

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 08:08 -0800, Roy wrote:
> For example, I want to provide a link to edit a comment using the
> admin, so the link should be /admin/comments/comment/{{ comment.id}}/
> using contrib.comments. But can I use the {% url %} tag instead of
> hardcoding this link?

At the moment, no, you can't do this. It's on the design table for 1.1,
but it's a hard-ish problem (amongst other things is the issue that you
can have more than one admin site, so reverse() needs to know which
admin site you're trying to reverse into).

Regards,
Malcolm



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



Re: Strage Url Tag Problem

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 04:01 -0800, madhav wrote:
> I am facing a strage error while using 'url' tag. I am using {%url
> logout%} for getting the logout url in the template. It is telling
> "Reverse for 'PROD_settings.logout' with arguments '()' and keyword
> arguments '{}' not found". Why is it referring logout as
> PROD_settings.logout???

The reverse resolver looks in a few places to work out where the URL
configuration file could be. The last place it looked was the
project-level directory (if one exists) and that's the error it reports.
It's a little misleading, in that it only reports one location that may
not even exist, but the key take-away from the error is that it didn't
find the pattern to reverse.

Regards,
Malcolm



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



Re: model instance version numbering, or concurrent model editing

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 17:28 +0700, Ronny Haryanto wrote:
> G'day all,
> 
> Let say I have a wiki-like Django app. I wanted to allow many people
> edit a wiki page without any locking, yet have the system prevent two
> people saving page updates at almost the same time (one of the updates
> would be lost, overwritten by the other one).
> 
> This is what I have in mind. Add a version field to the WikiPage model
> which is automatically incremented on every update. The system should
> not allow saving an existing page with version (in db) >= version (in
> data to be saved). This is probably done in save().
> 
> I've tried overriding the models's save() method, but I'm always stuck
> at how to get the guaranteed-most-recent version number (lock the
> row/table?) from the db (as opposed to self.version, which could
> already be stale by the time save() is called).

In some respects, the most natural way to do this, if you were using raw
SQL, would be a "SELECT FOR UPDATE..." query. You reserve the page row
that you're working on before attempting any changes. At the current
time, Django doesn't have a wrapper for that functionality, although
there's a proto-patch in Trac. The error handling is a little fiddly for
this API, so it's not finished yet, but this is on the list of Version
1.1 features.

> My questions are:
> * Is my approach reasonable? (or Have I missed a more obvious/easier way?)

Absolutely reasonable. It's the natural way to do this kind of
optimistic locking.

Thinking in SQL (and not using "SELECT FOR UPDATE"), you want to execute

UPDATE  SET ... WHERE pk =  AND version = 

and then check that one row (as opposed to none) was updated. With
transaction support, that will ensure only one update takes place, even
with concurrent users. It's the second part of the WHERE clause that you
can't do with Model.save() in Django. That method only constrains
updates based on the pk value. You could, however, fake it by using the
update method on Querysets. I suspect this does the write thing:

num_rows = WikiPage.objects.filter(pk=pk_val, 
version=version_val).update(...)
if num_rows != 1:
# No update happened.
# ...   

There's also a secondary problem here that the same update statement
needs to increment the version field atomically. So part of the "SET"
clause is, ideally, "version = version + 1" and that requires ticket
#7210, which is, again a 1.1 feature. However, with the above filtering,
since you know the value of "version" before the update, you could
manually set it to "version_val + 1" in the update(...) call.

Essentially, you use the above instead of calling Model.save() -- which
would be super(WikiPage, self).save(...). You're in the special
situation of knowing you have an existing object and wanting to update.
So you do more or less exactly what save(force_update=True) does, but
with extra filtering.

Having thought about this for a few minutes, it all sounds like it
should work. Django's automatic transaction management will even do the
right thing for you (the transaction will be committed right after the
update, so any concurrent threads will see it immediately).

Regards,
Malcolm


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



Re: Access to Many-To-Many intermediary table from django

2008-12-11 Thread Malcolm Tredinnick


On Thu, 2008-12-11 at 09:43 +0100, Elvis Stansvik wrote:
> 2008/12/11 Malcolm Tredinnick :
> >
> >
> > On Wed, 2008-12-10 at 06:22 -0800, nucles wrote:
> >> Hello,
> >>
> >> If we create 2 models with many-to-many relationship django creates
> >> the intermediary table automatically for us.
> >> How can i use this intermediate table to relate other entities?
> >
> > What do you mean? Normally you don't need to worry about the
> > intermediate table at all; it's an implementation detail at the database
> > level.
> >
> > So what is the problem you're trying to solve here?
> 
> I agree this question should be asked, but there are valid use cases.
> I recently had a Book model and Contributor model which I joined with
> a Contribution table, which in turn had a ForeignKey into a
> ContributitionType model. This lets me add more types of contributions
> to a book in the future, such as author, editor, translator,
> illustrator et.c.

Yes, I know about that kind of situation. If the original poster meant
"adding extra attributes to the intermediate table to link to other
tables" when he said "relate other entities" then using "through" on
ManyToManyField or doing it manually is a good answer. No problems
there. But it depends on whether that's the intended interpretation. I
was asking for a rephrasing of the question, in more concrete terms --
hence a description of the actual problem instead of something abstract
-- to work out what the question really was.

If he's doing what you're guessing, then I'm behind you 100%. Your
answer is correct. If not, well... :-)

Regards,
Malcolm



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



Import Error On appache

2008-12-11 Thread Lee

Hi, everyone.

My environment is python 2.52, mod_python-3.3.1, Apache2.2, PostgreSQL
8.3 and psycopg2-2.0.8. The Operation System is vista x64 ultimate.


The django Project folder is IntelligentNotesSystem ( created by
django-admin.py startproject IntelligentNotesSystem  ), which is
located in C:\Django\IntelligentNotesSystem.

The application folder is Core (created by python manage.py startapp
Core), which is located in C:\Django\IntelligentNotesSystem\Core.

All the template file is in C:\Django\IntelligentNotesSystem\Template

All the stylesheets and images are in C:\Django\IntelligentNotesSystem
\Site_media

The following is the sentences which I added to  Apache configuration:


LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE IntelligentNotesSystem.settings
PythonOption django.root /IntelligentNotesSystem
PythonDebug On
PythonPath "['C:/Django'] + sys.path"



SetHandler None



SetHandler None


---

There is  a custom django form (forms.py) in the Core folder.

the content is that:

import re
from django import forms
from django.contrib.auth.models import User


class RegistrationForm(forms.Form):
  username = forms.CharField(label='Username', max_length=30)
  email = forms.EmailField(label='Email')
  password1 = forms.CharField(
label='Password',
widget=forms.PasswordInput()
  )
  password2 = forms.CharField(
label='Password (Again)',
widget=forms.PasswordInput()
  )

  def clean_username(self):
username = self.cleaned_data['username']
if not re.search(r'^\w+$', username):
  raise forms.ValidationError('Username can only contain
alphanumeric characters and the underscore.')
try:
  User.objects.get(username=username)
except:
  return username
raise forms.ValidationError('Username is already taken.')

  def clean_password2(self):
if 'password1' in self.cleaned_data:
  password1 = self.cleaned_data['password1']
  password2 = self.cleaned_data['password2']
  if password1 == password2:
return password2
raise forms.ValidationError('Passwords do not match.')

--


The application runs well in the django server(in this url 
http://127.0.0.1:8000/).
However, it displays :


ImportError at /

No module named Core.forms

Request Method: GET
Request URL:http://localhost/
Exception Type: ImportError
Exception Value:

No module named Core.forms

Exception Location: C:/Django\IntelligentNotesSystem\Core\views.py in
, line 6
Python Executable:  C:\Apache2.2\bin\httpd.exe
Python Version: 2.5.2
Python Path:['C:/Django', 'C:\\Windows\\system32\\python25.zip', 'C:\
\Python25\\Lib', 'C:\\Python25\\DLLs', 'C:\\Python25\\Lib\\lib-tk', 'C:
\\Apache2.2', 'C:\\Apache2.2\\bin', 'C:\\Python25', 'C:\\Python25\\lib\
\site-packages']
Server time:Fri, 12 Dec 2008 09:37:40 +1100


when I use the appache server to run it.(In this url
http://localhost/IntelligentNotesSystem/)


The following text is the views.py

from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.template import RequestContext
from django.shortcuts import render_to_response
from Core.forms import *
from django.template.loader import get_template

def main_page(request):
  return render_to_response('main_page.html', RequestContext(request))


def user_page(request,username):
try:
user = User.objects.get(username = username)
except:
raise Http404('Requested user not found.')
bookmarks = user.bookmark_set.all()
template = get_template('user_page.html')
variables = RequestContext(request, {
'username': username,
'bookmarks': bookmarks
})
return render_to_response('user_page.html', variables)



def logout_page(request):
  logout(request)
  return HttpResponseRedirect('/')


def register_page(request):
  if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
  user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email']
  )
  return HttpResponseRedirect('/register/success/')
  else:
form = RegistrationForm()

  variables = RequestContext(request, {
'form': form
  })
  return render_to_response('registration/register.html', variables)


Re: custom distinct() method

2008-12-11 Thread Russell Keith-Magee

On Wed, Dec 10, 2008 at 7:58 PM, jamesjacksonn...@gmail.com
 wrote:
>
> One example is worth thousand explanations, so, let's say the
> situation is as follows:
>
> class example(models.Model):
>artist = models.CharField(max_length=765, blank=True)
>song_name = models.CharField(max_length=765, blank=True)
>id = models.IntegerField(primary_key=True)
>
> Three objects are created/save to a mysql db:
> 1 Django Reinhardt Liza
> 2 Django Reinhardt Minor Swing
> 3 Django Reinhardt Nuages
>
> example.objects.filter(artist="Django Reinhardt").distinct() returns
> all three objects, by making SQL query:
> SELECT DISTINCT `mainapp_example`.`artist`,
> `mainapp_example`.`song_name`, `mainapp_example`.`id` FROM
> `mainapp_example` WHERE `mainapp_example`.`artist` = Django
> Reinhardt .
>
> Lets say my goal is to get the list of (distinct) artists in a
> database, and it is reached by commiting query:
> SELECT DISTINCT `mainapp_example`.`artist` FROM `mainapp_example`
> WHERE `mainapp_example`.`artist` = Django Reinhardt .
> Only one row is returned - Django Reinhardt. Is it possible to get the
> same value using django-orm?
> That's probably how i was supposed to ask before.

Ok; now I understand the problem...

> Now i'm trying to get why this might be impossible - django queryset
> is probably supposed to (always) return objects, and in this case, its
> tuple ('Django Reinhardt',) or dictionary {'column': 'artist,
> 'row1':'Django Reinhardt'} i do expect to be returned. But please
> correct me if i'm wrong in past sentence, or anywhere in the post.

... and you've preempted my answer. What you're asking for can't be
retrieved with a simple query.

In order to get the distinct artist names, you need to restrict the
columns named in the select. You can do this with a values()
statement:

Song.objects.values('artist').distinct().

This will return a ValuesQuerySet, which acts much like a list of
dictionaries; each dictionary will have a single key-value pair. In
your example, the result would be something like:

[{'artist': 'Django Reinhardt'}]

If you're dealing with a single unique field (artist, in this case),
you can simplify the structure of the return value this by using a
call to values_list(), instead of values(). See the docs for more
details.

If all you want is the list of unique names, that's all you need to
so. However, in order to retrieve a QuerySet populated with full
Django objects, you need to put every column name in the SELECT. This
is done implicitly when you run Model.objects.all(), or any other
non-values() queryset.

This means that the requirements for the distinct call conflict with
the requirements for the object call. You can't make a simple 'SELECT
x FROM y WHERE z' where x satisfies both requirements.

However, you can do it by embedding one query in another - that is,
issue one query to get a list of unique names, then a second query to
retrieve a list of full objects that match those names. This can be
achieved in several ways, but something like the following should do
the trick:

Song.objects.filter(name__in=Song.objects.values_list('artist', flat=True))

Yours,
Russ Magee %-)

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



Can someone look at this code and let me know how crappy it is?

2008-12-11 Thread issya

I know I am probably going about this the wrong way. Can someone
please help me rewrite this code so it is the right way? I am also
having a problem doing pagination. When I click on the next page link,
nothing is coming up. This is even if I pass through a ?city=
{{ request.GET.city }} in the next page url.

I cannot find any good examples that use custom searches and
pagination. Thank you in advance for any help or criticism you may
give.

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



Re: setting the proper file permisions chmod

2008-12-11 Thread Graham Dumpleton



On Dec 12, 9:07 am, garagefan  wrote:
> which would actually result in keeping my server more secure... i
> would assume leaving other with rwx would be paramount to keeping my
> front door wide open?

The risk is more from users who have shell accounts on the same
system, or have web applications running as different user. Those
users would be able to modify stuff in that directory even though they
aren't owner.

It doesn't change the risk in respect of other web application code
running under mod_python or PHP which also runs as Apache user. Such
code because runs as Apache user would be able to write to the
directory even if owned by Apache user and not o+rwx.

> I'll look into mod_wsgi... but i can't imagine that every person
> running mod_python and working with file uploads hasn't had to combat
> this little issue.

Based on posts one sees, a lot of people just make it o+rwx and leave
it at that.

> is there really a safety concern?

If you are fully in control of the system and no other users on it, it
is not good, but not disastrous.

> or is there another way around this?

Make the user owned by Apache user instead and don't have o+rwx.

I am biased, but arguable that mod_wsgi is a better overall choice
these days than mod_python anyway and with mod_python fading away to a
degree, better long term choice.

Graham

> On Dec 11, 4:59 pm, Graham Dumpleton 
> wrote:
>
> > On Dec 12, 8:52 am, garagefan  wrote:
>
> > > this is my first time working this closely to the server for a live
> > > environment :)
>
> > > "apache" appears as owner of the file once uploaded. is there a way to
> > > set the default on this to be another user?
>
> > Only by using Apache/mod_wsgi (not mod_python) and specifically using
> > mod_wsgi daemon mode, with a distinct user defined for the daemon
> > process and thus your Django application to run as.
>
> > Graham
>
> > > On Dec 11, 4:45 pm, Graham Dumpleton 
> > > wrote:
>
> > > > On Dec 12, 8:32 am, garagefan  wrote:
>
> > > > > I figured out my issue with the "access denied, suspicious operation"
> > > > > bull...
>
> > > > > apparently the only way the admin side of my site can upload an image
> > > > > to a directory is by having "other" set to have full rwx set... ie
> > > > > chmod **7 I'm not so sure this is a good thing to keep set as that
> > > > > would give everyone, logged in or other, access to overwriting data,
> > > > > adding stuff, etc... right?
>
> > > > Who owns the files once uploaded?
>
> > > > Whoever that is should be the owner of the directory. Sounds like you
> > > > are running under Apache and don't understand that your code runs as
> > > > the Apache user.
>
> > > > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



generating an image?

2008-12-11 Thread garagefan

Is it possible to generate an image, to save it on my server, of a web
page by passing through the url only?

say perhaps I want to link to a few sites from mine, and i'd like to
include a thumbnail of the site... and instead of taking a screen
capture, and uploading it, i pass through the url of the page, and the
image of the homepage is generated from that.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: setting the proper file permisions chmod

2008-12-11 Thread garagefan

which would actually result in keeping my server more secure... i
would assume leaving other with rwx would be paramount to keeping my
front door wide open?

I'll look into mod_wsgi... but i can't imagine that every person
running mod_python and working with file uploads hasn't had to combat
this little issue.

is there really a safety concern? or is there another way around this?

On Dec 11, 4:59 pm, Graham Dumpleton 
wrote:
> On Dec 12, 8:52 am, garagefan  wrote:
>
> > this is my first time working this closely to the server for a live
> > environment :)
>
> > "apache" appears as owner of the file once uploaded. is there a way to
> > set the default on this to be another user?
>
> Only by using Apache/mod_wsgi (not mod_python) and specifically using
> mod_wsgi daemon mode, with a distinct user defined for the daemon
> process and thus your Django application to run as.
>
> Graham
>
> > On Dec 11, 4:45 pm, Graham Dumpleton 
> > wrote:
>
> > > On Dec 12, 8:32 am, garagefan  wrote:
>
> > > > I figured out my issue with the "access denied, suspicious operation"
> > > > bull...
>
> > > > apparently the only way the admin side of my site can upload an image
> > > > to a directory is by having "other" set to have full rwx set... ie
> > > > chmod **7 I'm not so sure this is a good thing to keep set as that
> > > > would give everyone, logged in or other, access to overwriting data,
> > > > adding stuff, etc... right?
>
> > > Who owns the files once uploaded?
>
> > > Whoever that is should be the owner of the directory. Sounds like you
> > > are running under Apache and don't understand that your code runs as
> > > the Apache user.
>
> > > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: setting the proper file permisions chmod

2008-12-11 Thread Graham Dumpleton



On Dec 12, 8:52 am, garagefan  wrote:
> this is my first time working this closely to the server for a live
> environment :)
>
> "apache" appears as owner of the file once uploaded. is there a way to
> set the default on this to be another user?

Only by using Apache/mod_wsgi (not mod_python) and specifically using
mod_wsgi daemon mode, with a distinct user defined for the daemon
process and thus your Django application to run as.

Graham

> On Dec 11, 4:45 pm, Graham Dumpleton 
> wrote:
>
> > On Dec 12, 8:32 am, garagefan  wrote:
>
> > > I figured out my issue with the "access denied, suspicious operation"
> > > bull...
>
> > > apparently the only way the admin side of my site can upload an image
> > > to a directory is by having "other" set to have full rwx set... ie
> > > chmod **7 I'm not so sure this is a good thing to keep set as that
> > > would give everyone, logged in or other, access to overwriting data,
> > > adding stuff, etc... right?
>
> > Who owns the files once uploaded?
>
> > Whoever that is should be the owner of the directory. Sounds like you
> > are running under Apache and don't understand that your code runs as
> > the Apache user.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: setting the proper file permisions chmod

2008-12-11 Thread garagefan

this is my first time working this closely to the server for a live
environment :)

"apache" appears as owner of the file once uploaded. is there a way to
set the default on this to be another user?

On Dec 11, 4:45 pm, Graham Dumpleton 
wrote:
> On Dec 12, 8:32 am, garagefan  wrote:
>
> > I figured out my issue with the "access denied, suspicious operation"
> > bull...
>
> > apparently the only way the admin side of my site can upload an image
> > to a directory is by having "other" set to have full rwx set... ie
> > chmod **7 I'm not so sure this is a good thing to keep set as that
> > would give everyone, logged in or other, access to overwriting data,
> > adding stuff, etc... right?
>
> Who owns the files once uploaded?
>
> Whoever that is should be the owner of the directory. Sounds like you
> are running under Apache and don't understand that your code runs as
> the Apache user.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: setting the proper file permisions chmod

2008-12-11 Thread Graham Dumpleton



On Dec 12, 8:32 am, garagefan  wrote:
> I figured out my issue with the "access denied, suspicious operation"
> bull...
>
> apparently the only way the admin side of my site can upload an image
> to a directory is by having "other" set to have full rwx set... ie
> chmod **7 I'm not so sure this is a good thing to keep set as that
> would give everyone, logged in or other, access to overwriting data,
> adding stuff, etc... right?

Who owns the files once uploaded?

Whoever that is should be the owner of the directory. Sounds like you
are running under Apache and don't understand that your code runs as
the Apache user.

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



Generating a slug from an m2m field

2008-12-11 Thread Delta20

I'm trying to generate a slug for a model, based on the contents of
many2many field, but my approaches so far don't seem to work. I'd be
grateful if anyone point me towards a better approach. Here's a simple
example of what I'm doing:

class Item(models.Model):
name = models.CharField()
def __unicode__(self):
return self.name

class Ticket(models.Model)
items = models.ManyToManyField(Item)
slug = models.CharField(editable=False)

def update_ticket_slug(**kwargs):
instance = kwargs['instance']
# concatenate the names of all the items into a string
instance.slug = ", ".join([str(i) for i in instance.items.all()])
instance.save()

post_save.connect(update_ticket_slug, sender=Ticket)

The post_save signal is correctly fired, but  instance.items.all()
always returns an empty set. I guess the m2m relation hasn't been
saved yet. Question: how do I do what I'm trying to do above? Is there
a different approach I can use?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



setting the proper file permisions chmod

2008-12-11 Thread garagefan

I figured out my issue with the "access denied, suspicious operation"
bull...

apparently the only way the admin side of my site can upload an image
to a directory is by having "other" set to have full rwx set... ie
chmod **7 I'm not so sure this is a good thing to keep set as that
would give everyone, logged in or other, access to overwriting data,
adding stuff, etc... right?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pyamf, mod_wsgi and session caching

2008-12-11 Thread oggie rob

On Nov 11, 11:38 am, oggie rob  wrote:
> Hi all,
> I'm working on a project which uses pyamf and produces the following
> exception during login:
>
> AttributeError: 'LazyModule' object has no attribute 'Manager'

I'm a bit late in responding here, but if anybody else runs into this,
here's how I solved this:
 a) explicitly imported ContentType in my wsgi.py file (referenced
from WSGIScriptAlias):
from django.contrib.contenttypes.models import ContentType
 b) expanded the pyamf egg

With (a), it was causing the actual import error due to some magic in
pyamf's importing (and although I didn't find it, probably affected by
some caching voodoo). With (b), there was some other obscure issue to
do with importing.

Debugging was very difficult with pyamf. My recommendation after going
through all of that is to turn off DEBUG & have mail set up (otherwise
you won't see the errors) and isolate your testing parameters (I build
a flex test client) - obvious stuff, really.

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



Re: A custom field that populates other models

2008-12-11 Thread bruno desthuilliers



On 11 déc, 16:30, pielgrzym  wrote:
> Thanks for your suggestions! Now I made the tagging work without any
> inside changes due to proper url escaping :)

Fine !-)

> Unfortunately tagging
> crashes multilingual app on postgresql database (I posted an issue
> here:http://code.google.com/p/django-multilingual/issues/detail?id=79
> ). I think I should write some simple content translation app, since
> this error I get seems to be just to complex for me :(

Too bad. Well... shit happens :(



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



Re: models.FileField and InMemoryUploadedFile

2008-12-11 Thread Rajesh Dhawan



On Dec 11, 1:35 pm, rtelep  wrote:
> I have a model Foo with an ImageField.  I want to create new Foo
> object from request.FILES and POST from inside a view function.
>
> Ordinarily I would bind a form to request.FILES and request.POST to
> get that data:
>
> form = FooForm(request.FILES, request.POST)
>
> But I cannot do that in this case (circumstances.)
>
> I can do "manually" like this:
>
> foo = Foo(
>bar = request.POST.get('bar')
> )
>
> But not in the case of request.FILES
>
> request.FILES['img'] is an InMemoryUploadedFile object:
>
> 
>
> How can I feed that to my model's ImageField?
>
> I guess that what I'm basically asking is how can a person do:
>
>
>
> >>>from mysite.myapp.models import Foo
> >>>foo = Foo(bar = 'baz', img = )
> >>>foo.save()

from mysite.myapp.models import Foo
foo = Foo(bar='baz')
file_content = request.FILES['img']
foo.img.save(file_content.name, file_content, save=True)

For more, see: http://docs.djangoproject.com/en/dev//ref/files/file/

-Rajesh D

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



Re: can't get new model to show up in admin

2008-12-11 Thread Norm Aleks

THANK YOU THANK YOU THANK YOU!!  Oh man, oh man, was that frustrating,
but hopefully now it won't bite me again.  Yes, I had made a "root"
user and a "norm" user, I was logged in as norm, and norm's not an
admin.

All set now!  Thanks again!

Norm


On Dec 11, 10:13 am, Jeff FW  wrote:
> Well, here's another possibly silly question--are you logging into the
> admin as an admin user?  Otherwise, it's possible you don't have
> privileges to see the new model.  My coworker did that--took a long
> time for us to figure out what he was doing wrong ;-)
>
> Other than that... I dunno.
>
> On Dec 11, 11:37 am, Norm Aleks  wrote:
>
> > Thanks, it's not silly.  Yes, I did that (and tables were created, so
> > the models files at least got seen).
> > Something else I should have mentioned is that the problem still
> > occurs when I'm using the internal development server, so I feel like
> > it's unlikely to be a Dreamhost issue.
> > Norm
>
> > On Dec 11, 6:11 am, Jeff FW  wrote:
>
> > > Possibly a silly question--but did you run syncdb after adding
> > > staticimage2 to your INSTALLED_APPS?
>
> > > -Jeff
>
> > > On Dec 10, 9:49 pm, Norm Aleks  wrote:
>
> > > > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > > > trouble getting a new model to show up.  I'm cringing a little because
> > > > I know this has been a FAQ -- know that I *have* put some effort into
> > > > Googling this problem, and I read up on the changes to the admin setup
> > > > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > > > model that *does* show up in the admin interface, but even though I
> > > > seem to be setting up the new model completely identically, it's not
> > > > showing.
>
> > > > So, here's what I have.  "root.staticimages" is the app that does show
> > > > up in admin, and "root.staticimages2" is the one that does not.
>
> > > > First, Django is running under dispatch.fcgi.  When I make changes to
> > > > the configuration, I kill any running Python processes and also touch
> > > > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > > > standard Django error pages.
>
> > > > Now, my application is named "root" ...
>
> > > > root/settings.py:
> > > > 
> > > > [...]
> > > > INSTALLED_APPS = (
> > > >     'django.contrib.auth',
> > > >     'django.contrib.contenttypes',
> > > >     'django.contrib.sessions',
> > > >     'django.contrib.sites',
> > > >     'treemenus',
> > > >     'root.staticimages',
> > > >     'root.staticimages2',
> > > >     'django.contrib.admin',
> > > >     'django.contrib.admindocs',
> > > > )
>
> > > > root/urls.py:
> > > > 
> > > > from django.contrib import admin
> > > > from views import *
> > > > from root.songs.models import Artist
>
> > > > admin.autodiscover()
>
> > > > urlpatterns = patterns('',
> > > >     (r'^$', main),
> > > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > > >     (r'^admin/(.*)', admin.site.root),
> > > > )
>
> > > > root/staticimages/models.py:
> > > > 
> > > > from django.db import models
>
> > > > class StaticImage(models.Model):
> > > >     image = models.ImageField(upload_to='static_image',
> > > > height_field='T', width_field='T')
> > > >     altText = models.TextField()
>
> > > >     def __unicode__(self):
> > > >         return self.image.name
>
> > > > root/staticimages/admin.py:
> > > > 
> > > > from django.contrib import admin
> > > > from root.staticimages.models import StaticImage
>
> > > > class StaticImageAdmin(admin.ModelAdmin):
> > > >     pass
>
> > > > admin.site.register(StaticImage, StaticImageAdmin)
>
> > > > root/staticimages2/models.py:
> > > > 
> > > > from django.db import models
>
> > > > class StaticImage2(models.Model):
> > > >     image = models.ImageField(upload_to='static_image',
> > > > height_field='T', width_field='T')
> > > >     altText = models.TextField()
>
> > > >     def __unicode__(self):
> > > >         return self.image.name
>
> > > > root/staticimages2/admin.py:
> > > > 
> > > > from django.contrib import admin
> > > > from root.staticimages2.models import StaticImage2
>
> > > > class StaticImage2Admin(admin.ModelAdmin):
> > > >     pass
>
> > > > admin.site.register(StaticImage2, StaticImage2Admin)
>
> > > > Any help at all would be appreciated, even if it's a suggestion for a
> > > > better Google search.
>
> > > > Thanks,
>
> > > > Norm Aleks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



models.FileField and InMemoryUploadedFile

2008-12-11 Thread rtelep

I have a model Foo with an ImageField.  I want to create new Foo
object from request.FILES and POST from inside a view function.

Ordinarily I would bind a form to request.FILES and request.POST to
get that data:

form = FooForm(request.FILES, request.POST)

But I cannot do that in this case (circumstances.)

I can do "manually" like this:

foo = Foo(
   bar = request.POST.get('bar')
)

But not in the case of request.FILES

request.FILES['img'] is an InMemoryUploadedFile object:



How can I feed that to my model's ImageField?

I guess that what I'm basically asking is how can a person do:

>>>from mysite.myapp.models import Foo
>>>foo = Foo(bar = 'baz', img = )
>>>foo.save()



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



Re: Using Django authentication for phpBB

2008-12-11 Thread Giles Thomas

Hi all,

All of the code to support Django logins for phpBB is now up available 
in a Google code project:

http://code.google.com/p/django-login-for-phpbb/

Drop me a line if you find it useful or have any questions.


Cheers,

Giles


Giles Thomas wrote:
> Hi all,
>
> I've written some glue code so that people who are logged in to the 
> Django portions of our website [1] can post to our phpBB-based forums 
> without having to log in again - basically a django-auth plugin for 
> phpBB.  I'm wrapping it up as a project on Google Code (MIT license) 
> [2] so that other people can use it, but for anyone who's interested, 
> I've described how it works in a blog post [3].
>
> Any comments very welcome!
>
> Cheers,
>
> Giles
>
> [1] http://www.resolversystems.com/
> [2] http://code.google.com/p/django-login-for-phpbb/
> [3] http://www.gilesthomas.com/?p=63
>

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
giles.tho...@resolversystems.com
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



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



Re: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Well, here's another possibly silly question--are you logging into the
admin as an admin user?  Otherwise, it's possible you don't have
privileges to see the new model.  My coworker did that--took a long
time for us to figure out what he was doing wrong ;-)

Other than that... I dunno.

On Dec 11, 11:37 am, Norm Aleks  wrote:
> Thanks, it's not silly.  Yes, I did that (and tables were created, so
> the models files at least got seen).
> Something else I should have mentioned is that the problem still
> occurs when I'm using the internal development server, so I feel like
> it's unlikely to be a Dreamhost issue.
> Norm
>
> On Dec 11, 6:11 am, Jeff FW  wrote:
>
> > Possibly a silly question--but did you run syncdb after adding
> > staticimage2 to your INSTALLED_APPS?
>
> > -Jeff
>
> > On Dec 10, 9:49 pm, Norm Aleks  wrote:
>
> > > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > > trouble getting a new model to show up.  I'm cringing a little because
> > > I know this has been a FAQ -- know that I *have* put some effort into
> > > Googling this problem, and I read up on the changes to the admin setup
> > > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > > model that *does* show up in the admin interface, but even though I
> > > seem to be setting up the new model completely identically, it's not
> > > showing.
>
> > > So, here's what I have.  "root.staticimages" is the app that does show
> > > up in admin, and "root.staticimages2" is the one that does not.
>
> > > First, Django is running under dispatch.fcgi.  When I make changes to
> > > the configuration, I kill any running Python processes and also touch
> > > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > > standard Django error pages.
>
> > > Now, my application is named "root" ...
>
> > > root/settings.py:
> > > 
> > > [...]
> > > INSTALLED_APPS = (
> > >     'django.contrib.auth',
> > >     'django.contrib.contenttypes',
> > >     'django.contrib.sessions',
> > >     'django.contrib.sites',
> > >     'treemenus',
> > >     'root.staticimages',
> > >     'root.staticimages2',
> > >     'django.contrib.admin',
> > >     'django.contrib.admindocs',
> > > )
>
> > > root/urls.py:
> > > 
> > > from django.contrib import admin
> > > from views import *
> > > from root.songs.models import Artist
>
> > > admin.autodiscover()
>
> > > urlpatterns = patterns('',
> > >     (r'^$', main),
> > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > >     (r'^admin/(.*)', admin.site.root),
> > > )
>
> > > root/staticimages/models.py:
> > > 
> > > from django.db import models
>
> > > class StaticImage(models.Model):
> > >     image = models.ImageField(upload_to='static_image',
> > > height_field='T', width_field='T')
> > >     altText = models.TextField()
>
> > >     def __unicode__(self):
> > >         return self.image.name
>
> > > root/staticimages/admin.py:
> > > 
> > > from django.contrib import admin
> > > from root.staticimages.models import StaticImage
>
> > > class StaticImageAdmin(admin.ModelAdmin):
> > >     pass
>
> > > admin.site.register(StaticImage, StaticImageAdmin)
>
> > > root/staticimages2/models.py:
> > > 
> > > from django.db import models
>
> > > class StaticImage2(models.Model):
> > >     image = models.ImageField(upload_to='static_image',
> > > height_field='T', width_field='T')
> > >     altText = models.TextField()
>
> > >     def __unicode__(self):
> > >         return self.image.name
>
> > > root/staticimages2/admin.py:
> > > 
> > > from django.contrib import admin
> > > from root.staticimages2.models import StaticImage2
>
> > > class StaticImage2Admin(admin.ModelAdmin):
> > >     pass
>
> > > admin.site.register(StaticImage2, StaticImage2Admin)
>
> > > Any help at all would be appreciated, even if it's a suggestion for a
> > > better Google search.
>
> > > Thanks,
>
> > > Norm Aleks
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



include

2008-12-11 Thread Vince

Hi guys,

I have a fileupload template and I would like to show a .gif picture
during the upload process once the user submits a file to upload, it's
working already but .gif is not animated while waiting for fileupload
completion. On the other hand, if I include a frame in the form action
call, the gif gets animated but it doesn't go further to the
upload_success template, I mean it stays showing the ...loading
withthe animated .gif forever.

here is the piece of the template (like this it stays showing the
animated .gif forever):





[...]



 {% if not is_ok %}
 {{ msg }} 
 {% else %}

 {% endif %}
 Cargando...
 

 
  {{ form }}
 
 
 
 
 


Then I have my view from what I'm calling the template, as I said
everything works (with unanimated loader.gif if I don't include the
target parameter inside the form action line. Without the target, as
soon as it finishes uploading goes to POST and executes the django
view.

I would like to know if this approach is valid, I mean if I can
combine calling a frametarget and going to my django view after the
process has been completed. if not How can I show the animated .gif ??

Thanks a lot in advance

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



Re: how to make the label of form international

2008-12-11 Thread Karen Tracey
On Thu, Dec 11, 2008 at 10:50 AM, Lucas  wrote:

>
> Hi,
>
>
> Now i'm confused with the following point about the international.
> 1. When running make-messages.py,it's showing that xgettext isn't a
> command.
> Does xgettext means xgettext.py or a exe file? Where i can download
> it.


Since you mention .exe I'm guessing your are running on Windows.  If so you
need to install a gettext utilities package.  One is mentioned here:

http://docs.djangoproject.com/en/dev/topics/i18n/#gettext-on-windows

A more recent (with fewer bugs) level of that package can be obtained via
cygwin.  I'd recommend the cygwin version over the other one, particularlly
if you've already got cygwin stuff installed.  If you don't, cygwin is a bit
more involved to install than just that other package, but that other
package has known bugs (e.g. ticket #9753) that you might have to watch out
for.


>
> 2. For a form, how can i make the label international,for example the
> following name.
> class ContactForm(forms.Form):
>name=forms.CharField()
> I have tired with help_text,but it doesn't work.
> name=forms.CharField(help_text,_('msgid'))
>
>
If you want a translated label, specify the label argument and mark the
value for translation.  See:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#label
http://docs.djangoproject.com/en/dev/topics/i18n/#in-python-code

Karen

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



Re: One to Many insert into Postgres

2008-12-11 Thread Karen Tracey
On Thu, Dec 11, 2008 at 10:45 AM, Ana <[EMAIL PROTECTED]> wrote:

>
> [snip]
> My admin form - publication shows more than one pathology on the edit
> page, which means the above code works up to this point.  It also
> gives me 3 empty fields that allows me to continue to add pathologies
> to the publication.  When I add a new pathology and then save I
> receive the following error:
>
> duplicate key value violates unique constraint
> "fsafety_pathpubcombo_pkey"
>
> Can anyone please help?  This is the first python code I've written.
>

I do not have time to look in any detail at your models, etc. but I can say
that there have been problems like this with inlines and Postgres due to
models without any ordering specified coming back in different orders for
different calls (e.g. different when the form is submitted vs. when it was
first created).  A workaround is to specify an ordering for your models, so
you could try that and see if that avoids the problem for your case.

Karen

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

2008-12-11 Thread Raymond Cote

Malcolm Tredinnick wrote:
> On Wed, 2008-12-10 at 16:01 -0500, Raymond Cote wrote:
>   
>> Hi Everyone,
>>
>> I'm having problems loading a custom PostgreSQL trigger function during 
>> syncdb and not sure how to address this:
>> ...
> I suspect this is because the initial SQL option isn't really ideal for
> custom functions like this. Rather, it's for things like populating
> initial data (straightforward insert statements).
>
> Django works line-by-line, each line of the file is passed in a
> cursor.excecute() call to the database.
Hi Malcolm:
Thanks. This saved me a lot of time trying to determine what the problem 
was.
For my little function, unrolling it and putting it all on one line 
worked just fine.
> We aren't ever really going to fix this, ...requires SQL parser...
>
> The alternative approach is to listen for the post_syncdb signal to be
> emitted for your model and then call cursor.execute() yourself,
Will definitely take a look at the use of signals in management.py.
( for documentation, this link looks useful:
   
)


I realize that triggers and database methods come in and out of vogue, 
but it is really convenient (and frequently suitable) to do some tasks 
within the database itself. I'm also looking at being able to create 
tables with custom parameters (such as partitioning).

Thanks again for your response.
--Ray

>  
> Regards,
> Malcolm
>
>   


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



Re: TypeError at admin: unpack non-sequence

2008-12-11 Thread Daniel Roseman

On Dec 11, 3:35 pm, Bluemilkshake <[EMAIL PROTECTED]>
wrote:
> Hi! Apologies for what is in no doubt a complete noob question.
>
> Just installed CentOS 5 with Python 2.4, Apache2 and the latest SVN
> release of Django. Also copied the mysql-python stuff, mod_python etc.
>
> I've setup my first Django project to test, and when I request the
> root URL I get no problems, however after adding the admin app to my
> INSTALLED_APPS setting and running syncdb, I get the following:
>
> TypeError at admin
> unpack non-sequenceRequest Method: GET
> Request URL:http://djangotest.bluemilkshake.co.ukadmin
> Exception Type: TypeError
> Exception Value: unpack non-sequence
> Exception Location: /usr/lib/python2.4/site-packages/django/core/
> handlers/base.py in get_response, line 76
> Python Executable: /usr/bin/python
> Python Version: 2.4.3
> Python Path: ['/home/Bluemilkshake/djangotest.bluemilkshake.co.uk/user/
> django', '/usr/lib/python2.4/site-packages/setuptools-0.6c5-
> py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4-
> linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/
> lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/
> python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/
> python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/
> gtk-2.0']
> Server time: Thu, 11 Dec 2008 09:28:30 -0600
>
> Have had a look round this group and the Web but have found no
> details. Also checked the mod_python docs on the Django Website and am
> sure I've configured everything to the letter (apart from specifying
> the PYTHON_EGG_CACHE in my httpd.conf (via SetEnv) instead of in a
> separate .py file.)
>
> Would really appreciate any pointers. I'm usually a Windows guy so
> don't assume I know anything about Linux :)
>
> Thanks a lot,
> -Mark

You haven't posted enough information to be able to answer the
question. For instance, you say the error occurred after you added the
admin app to INSTALLED_APPS, but you haven't posted that part of the
settings file. FWIW, I suspect you've missed off a comma before or
after the 'django.contrib.admin' line, which is preventing Python from
parsing the file.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: can't get new model to show up in admin

2008-12-11 Thread Norm Aleks

Thanks, it's not silly.  Yes, I did that (and tables were created, so
the models files at least got seen).
Something else I should have mentioned is that the problem still
occurs when I'm using the internal development server, so I feel like
it's unlikely to be a Dreamhost issue.
Norm


On Dec 11, 6:11 am, Jeff FW <[EMAIL PROTECTED]> wrote:
> Possibly a silly question--but did you run syncdb after adding
> staticimage2 to your INSTALLED_APPS?
>
> -Jeff
>
> On Dec 10, 9:49 pm, Norm Aleks <[EMAIL PROTECTED]> wrote:
>
> > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > trouble getting a new model to show up.  I'm cringing a little because
> > I know this has been a FAQ -- know that I *have* put some effort into
> > Googling this problem, and I read up on the changes to the admin setup
> > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > model that *does* show up in the admin interface, but even though I
> > seem to be setting up the new model completely identically, it's not
> > showing.
>
> > So, here's what I have.  "root.staticimages" is the app that does show
> > up in admin, and "root.staticimages2" is the one that does not.
>
> > First, Django is running under dispatch.fcgi.  When I make changes to
> > the configuration, I kill any running Python processes and also touch
> > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > standard Django error pages.
>
> > Now, my application is named "root" ...
>
> > root/settings.py:
> > 
> > [...]
> > INSTALLED_APPS = (
> >     'django.contrib.auth',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> >     'django.contrib.sites',
> >     'treemenus',
> >     'root.staticimages',
> >     'root.staticimages2',
> >     'django.contrib.admin',
> >     'django.contrib.admindocs',
> > )
>
> > root/urls.py:
> > 
> > from django.contrib import admin
> > from views import *
> > from root.songs.models import Artist
>
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >     (r'^$', main),
> >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> >     (r'^admin/(.*)', admin.site.root),
> > )
>
> > root/staticimages/models.py:
> > 
> > from django.db import models
>
> > class StaticImage(models.Model):
> >     image = models.ImageField(upload_to='static_image',
> > height_field='T', width_field='T')
> >     altText = models.TextField()
>
> >     def __unicode__(self):
> >         return self.image.name
>
> > root/staticimages/admin.py:
> > 
> > from django.contrib import admin
> > from root.staticimages.models import StaticImage
>
> > class StaticImageAdmin(admin.ModelAdmin):
> >     pass
>
> > admin.site.register(StaticImage, StaticImageAdmin)
>
> > root/staticimages2/models.py:
> > 
> > from django.db import models
>
> > class StaticImage2(models.Model):
> >     image = models.ImageField(upload_to='static_image',
> > height_field='T', width_field='T')
> >     altText = models.TextField()
>
> >     def __unicode__(self):
> >         return self.image.name
>
> > root/staticimages2/admin.py:
> > 
> > from django.contrib import admin
> > from root.staticimages2.models import StaticImage2
>
> > class StaticImage2Admin(admin.ModelAdmin):
> >     pass
>
> > admin.site.register(StaticImage2, StaticImage2Admin)
>
> > Any help at all would be appreciated, even if it's a suggestion for a
> > better Google search.
>
> > Thanks,
>
> > Norm Aleks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is it possible to reverse() into the admin edit views?

2008-12-11 Thread Roy

For example, I want to provide a link to edit a comment using the
admin, so the link should be /admin/comments/comment/{{ comment.id}}/
using contrib.comments. But can I use the {% url %} tag instead of
hardcoding this link?

Or should I just not bother since I'm not going to change the url
bindings for the admin?

I just felt like making all my links use {% url %} :D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Count is different when using custom SQL?

2008-12-11 Thread Darthmahon

Hi Malcolm,

Weird. I managed to fix this problem by using the distinct filter
which I didn't know existed but does what I actually wanted anyway :)


// get results
friends_albums = Albums.objects.filter(users__in=friend_list,
date__gte=today).distinct().select_related()
// count results
count['friends'] = friends_albums.count()


Thanks for your help though :)

Cheers,
Chris

On Dec 11, 1:56 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-12-10 at 02:11 -0800,Darthmahonwrote:
>
> [...]
>
>
>
> > Now what I've noticed is that the number of results (count) is
> > different between the results that have not been group and those that
> > have. Hopefully the code below makes some sense:
>
> > ###
>
> > // get results
> > friends_albums = Albums.objects.filter(users__in=friend_list,
> > date__gte=today).extra(select={'count': 'count(1)'}).select_related()
>
> > // count results
> > count['friends1'] = friends_albums.count()
>
> > // now group by
> > friends_albums.query.group_by = ['album_id']
>
> > // count results again once grouped
> > count['friends2'] = friends_albums.count()
>
> > ###
>
> > So count['friends1'] counts the results before being grouped, but once
> > I group them in the line after, count['friends2'] returns a different
> > number.
>
> Details below, but the first one is wrong and the second one is right.
>
> > The count in the extra parameter in the query is the correct number I
> > want, but I can't figure out how to access this within the View.pm
> > file?
>
> > Any ideas? I'll try and provide some examples of data when I get home
> > if this isn't enough information.
>
> I found it a bit hard to follow what you were doing, but I think the
> explanation is the same regardless. To understand what's going on here,
> if I were you, I'd look at the SQL generated in both cases (look at
> friends_album.query.as_sql()) and run that SQL directly in an SQL shell
> to see what the database returns.
>
> I'm kind of surprised your first attempt works at all, since it almost
> certainly is generating invalid SQL. However when I tested a similar
> situation, PostgreSQL raised the sort of error I was expecting (you
> can't do counting on a specific select column unless it's grouped), but
> SQLite returned an answer. The answer in the latter case was almost
> totally bogus, in the sense of not meaning much, but it didn't raise an
> error.
>
> So I think you should throw away your first query and only use the
> grouped version, as that's the correct SQL and going to do what you
> want. By way of example (using SQLite), here's a similar case, using a
> Tag model that has a parent_id field (it's just the tagging model and
> test data for my blog):
>
> (1) This is the normal sort of situation, grouping by the independent
> column(s):
>
>         sqlite> select parent_id, count(1) from weblog_tag group by parent_id;
>         parent_id   count(1)  
>         --  --
>                     5        
>         2           3        
>         8           2        
>         9           2        
>         10          1        
>
> (2) This is the nonsensical case. No grouping, but still attempting to
> count by the first column:
>
>         sqlite> select parent_id, count(1) from weblog_tag;
>         parent_id   count(1)  
>         --  --
>         8           13        
>
> The "8" for the parent_id column here is odd (well, any answer is as
> valid as any other in this "doesn't make sense" situation). It turns out
> to be the result of count(parent_id) -- in other words, the number of
> non-NULL occurrences of parent_id.
>
> Note that if I try to run the second query on a stricter database
> (PostgreSQL), I get this:
>
>         website=# select parent_id, count(1) from weblog_tag;
>         ERROR:  column "weblog_tag.parent_id" must appear in the GROUP BY 
> clause or be used in an aggregate function
>
> Hopefully that explains why you're seeing different results and which
> one to trust. But, again, play around with the queries in an SQL shell
> and see what's going on
>
> Good eye, picking up the difference, though, and at least wondering what
> on earth was going on.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to make the label of form international

2008-12-11 Thread Lucas

Hi,


Now i'm confused with the following point about the international.
1. When running make-messages.py,it's showing that xgettext isn't a
command.
Does xgettext means xgettext.py or a exe file? Where i can download
it.
2. For a form, how can i make the label international,for example the
following name.
class ContactForm(forms.Form):
name=forms.CharField()
I have tired with help_text,but it doesn't work.
name=forms.CharField(help_text,_('msgid'))


Thank for your help.



Regards,
Lucas

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



One to Many insert into Postgres

2008-12-11 Thread Ana

Hello,

I am converting from PHP to Django.  In my Postgres database I have
three tables:

models.py code:
class Publication(models.Model):
pubtitle = models.TextField()
def __unicode__(self):
return self.pubtitle

class Pathology(models.Model):
pathology = models.CharField(max_length=100)
def __unicode__(self):
return self.pathology

class Pathpubcombo(models.Model):
pathology = models.ForeignKey(Pathology)
publication = models.ForeignKey(Publication)

One publication can have many instances of pathology (one to many).
The pathology list is used by another table (researchpub), as well.

admin.py code:
from mysite.fsafety.models import Pathology
admin.site.register(Pathology)

from mysite.fsafety.models import Pathpubcombo
admin.site.register(Pathpubcombo)

class PathpubInline(admin.TabularInline):
model = Pathpubcombo
fk_name = "publication"

from mysite.fsafety.models import Publication
class PublicationAdmin(admin.ModelAdmin):
# ...
list_display = ('pubtitle', 'year')
search_fields = ['pubtitle', 'pubauthors']
fieldsets = [
(None,  {'fields': ['active', 'pubtitle',
'pubauthors', 'pubcitationnum', 'pubwebaddress', 'month', 'year']}),
('Abstract',{'fields': ['pubabstract'], 'classes':
['collapse']}),
]
inlines = [PathpubInline]

admin.site.register(Publication,PublicationAdmin)

My admin form - publication shows more than one pathology on the edit
page, which means the above code works up to this point.  It also
gives me 3 empty fields that allows me to continue to add pathologies
to the publication.  When I add a new pathology and then save I
receive the following error:

duplicate key value violates unique constraint
"fsafety_pathpubcombo_pkey"

Can anyone please help?  This is the first python code I've written.

Thanks,

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



TypeError at admin: unpack non-sequence

2008-12-11 Thread Bluemilkshake

Hi! Apologies for what is in no doubt a complete noob question.

Just installed CentOS 5 with Python 2.4, Apache2 and the latest SVN
release of Django. Also copied the mysql-python stuff, mod_python etc.

I've setup my first Django project to test, and when I request the
root URL I get no problems, however after adding the admin app to my
INSTALLED_APPS setting and running syncdb, I get the following:

TypeError at admin
unpack non-sequenceRequest Method: GET
Request URL: http://djangotest.bluemilkshake.co.ukadmin
Exception Type: TypeError
Exception Value: unpack non-sequence
Exception Location: /usr/lib/python2.4/site-packages/django/core/
handlers/base.py in get_response, line 76
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/home/Bluemilkshake/djangotest.bluemilkshake.co.uk/user/
django', '/usr/lib/python2.4/site-packages/setuptools-0.6c5-
py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4-
linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/
lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/
python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/
python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/
gtk-2.0']
Server time: Thu, 11 Dec 2008 09:28:30 -0600

Have had a look round this group and the Web but have found no
details. Also checked the mod_python docs on the Django Website and am
sure I've configured everything to the letter (apart from specifying
the PYTHON_EGG_CACHE in my httpd.conf (via SetEnv) instead of in a
separate .py file.)

Would really appreciate any pointers. I'm usually a Windows guy so
don't assume I know anything about Linux :)

Thanks a lot,
-Mark

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

2008-12-11 Thread pielgrzym

Thanks for your suggestions! Now I made the tagging work without any
inside changes due to proper url escaping :) Unfortunately tagging
crashes multilingual app on postgresql database (I posted an issue
here: http://code.google.com/p/django-multilingual/issues/detail?id=79
). I think I should write some simple content translation app, since
this error I get seems to be just to complex for me :(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Possibly a silly question--but did you run syncdb after adding
staticimage2 to your INSTALLED_APPS?

-Jeff

On Dec 10, 9:49 pm, Norm Aleks <[EMAIL PROTECTED]> wrote:
> I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> trouble getting a new model to show up.  I'm cringing a little because
> I know this has been a FAQ -- know that I *have* put some effort into
> Googling this problem, and I read up on the changes to the admin setup
> between 0.96 and 1.0.  What's more, I even got it right once on a test
> model that *does* show up in the admin interface, but even though I
> seem to be setting up the new model completely identically, it's not
> showing.
>
> So, here's what I have.  "root.staticimages" is the app that does show
> up in admin, and "root.staticimages2" is the one that does not.
>
> First, Django is running under dispatch.fcgi.  When I make changes to
> the configuration, I kill any running Python processes and also touch
> dispatch.fcgi.  If I make errors in the configuration, I do get the
> standard Django error pages.
>
> Now, my application is named "root" ...
>
> root/settings.py:
> 
> [...]
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'treemenus',
>     'root.staticimages',
>     'root.staticimages2',
>     'django.contrib.admin',
>     'django.contrib.admindocs',
> )
>
> root/urls.py:
> 
> from django.contrib import admin
> from views import *
> from root.songs.models import Artist
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^$', main),
>     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>     (r'^admin/(.*)', admin.site.root),
> )
>
> root/staticimages/models.py:
> 
> from django.db import models
>
> class StaticImage(models.Model):
>     image = models.ImageField(upload_to='static_image',
> height_field='T', width_field='T')
>     altText = models.TextField()
>
>     def __unicode__(self):
>         return self.image.name
>
> root/staticimages/admin.py:
> 
> from django.contrib import admin
> from root.staticimages.models import StaticImage
>
> class StaticImageAdmin(admin.ModelAdmin):
>     pass
>
> admin.site.register(StaticImage, StaticImageAdmin)
>
> root/staticimages2/models.py:
> 
> from django.db import models
>
> class StaticImage2(models.Model):
>     image = models.ImageField(upload_to='static_image',
> height_field='T', width_field='T')
>     altText = models.TextField()
>
>     def __unicode__(self):
>         return self.image.name
>
> root/staticimages2/admin.py:
> 
> from django.contrib import admin
> from root.staticimages2.models import StaticImage2
>
> class StaticImage2Admin(admin.ModelAdmin):
>     pass
>
> admin.site.register(StaticImage2, StaticImage2Admin)
>
> Any help at all would be appreciated, even if it's a suggestion for a
> better Google search.
>
> Thanks,
>
> Norm Aleks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: SOAPpy and pyxml installation/usage

2008-12-11 Thread Paul Nendick

Hello Steve,
SOAPy appears to be moribund. I was once using it within a Python SOA
I'd worked with and chose to abandon it when we moved that system to
Python 2.5. It wasn't an issue for us as SOAP was going nowhere (for
us anyway).
Good news for you (possibly) is the SOAP infrastructure generally
discussed by the Twisted Matrix community: ZSI.

Relevant code:
http://tinyurl.com/betterthansoapy

Full project:
http://pywebsvcs.sourceforge.net/

What I feel is the best XML library for Python:
http://uche.ogbuji.net/tech/4suite/amara/


regards,

/p


2008/12/11 Steve <[EMAIL PROTECTED]>
>
> This may be a more of a generic Python question, but I'm working with
> Django so thought that I'd see if there's a Django specific solution
> to it.
>
> I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
> well. From Dive into Python it has this great example about how to
> handle SOAP calls.
> http://www.diveintopython.org/soap_web_services/index.html
>
> The problem is that I'm trying to install the SOAPpy module and it
> requires pyxml, which appears to be no longer available or supported.
> http://pyxml.sourceforge.net/
>
> My main goal is to configuremy system to get this code, from the dive
> into python link above, to run. Or to find an equivalent set of
> packages that work instead. I'm working on windows with python 2.5.1,
> with Django .96. I deploy on ubuntu linux. Any thoughts?
>
> ...
> from SOAPpy import WSDL
>
> # you'll need to configure these two values;
> # see http://www.google.com/apis/
> WSDLFILE = '/path/to/copy/of/GoogleSearch.wsdl'
> APIKEY = 'YOUR_GOOGLE_API_KEY'
>
> _server = WSDL.Proxy(WSDLFILE)
> def search(q):
>"""Search Google and return list of {title, link, description}"""
>results = _server.doGoogleSearch(
>APIKEY, q, 0, 10, False, "", False, "", "utf-8", "utf-8")
>return [{"title": r.title.encode("utf-8"),
> "link": r.URL.encode("utf-8"),
> "description": r.snippet.encode("utf-8")}
>for r in results.resultElements]
>
>
>
>
> >

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

2008-12-11 Thread The Agregator

I will use google before asking a dumb question, I will use google
before asking a dumb question, I will use google before asking a dumb
question, I will use google before asking a dumb question, I will use
google before asking a dumb question, I will use google before asking
a dumb question, I will use google before asking a dumb question, I
will use google before asking a dumb question, I will use google
before asking a dumb question!

here's the solution: 
http://groups.google.com/group/django-users/browse_thread/thread/5b45241040291392

apparently all i needed was to ad to my __unicode__ function "u'%s' %"

I don't know why, but it worked!



On Dec 11, 2:05 pm, "Nitzan Brumer" <[EMAIL PROTECTED]> wrote:
> I have 2 classes - skill and qualification:
>
> class Skill(models.Model):
>     StageID = models.AutoField(primary_key=True)
>     StageNumber = models.IntegerField(_('Stage Number'), max_length=5)
>     StageDescription = models.CharField(_('Stage
> Description'),max_length=50)
>
> class Qualification(models.Model):
>     skillsID = models.AutoField(primary_key=True)
>     EmployeeID = models.ForeignKey(Employee, verbose_name=_('Employee ID'))
>     StageID = models.ForeignKey(Skill, verbose_name=_('Stage ID'))
>     DateOfSkill = models.DateTimeField('Date Of Skill')
>
>     class Meta:
>         unique_together = ('EmployeeID', 'StageID')
>
> both are registered with admin panel:
> admin.site.register(Skill)
> admin.site.register(Qualification)
>
> The skills admin screen works great, I can add skill, delete skill and
> modify skill.
> But, when I try to see the Qualification admin panel I get this error
> message:
> Request Method: GET  Request 
> URL:http://localhost:8000/admin/proposal/qualification/ Exception Type:
> TemplateSyntaxError  Exception Value:
>
> Caught an exception while rendering: coercing to Unicode: need string
> or buffer, Skill found
>
> What am I doing wrong? why is it not working?
>
> Template error:
> In template
> /usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/change_list.html,
> error at line 34
>    Caught an exception while rendering: coercing to Unicode: need string or
> buffer, Skill found
>    24 : {% if cl.has_filters %}
>    25 : 
>    26 : {% trans 'Filter' %}
>    27 : {% for spec in cl.filter_specs %}
>    28 :    {% admin_list_filter cl spec %}
>    29 : {% endfor %}
>    30 : 
>    31 : {% endif %}
>    32 : {% endblock %}
>    33 :
>    34 : {% block result_list %} {% result_list cl %} {% endblock %}
>    35 : {% block pagination %}{% pagination cl %}{% endblock %}
>    36 : 
>    37 : 
>    38 : {% endblock %}
>    39 :
>
> --
> Nitzan Brumer
> Http://n2b.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template Error

2008-12-11 Thread Nitzan Brumer
I have 2 classes - skill and qualification:

class Skill(models.Model):
StageID = models.AutoField(primary_key=True)
StageNumber = models.IntegerField(_('Stage Number'), max_length=5)
StageDescription = models.CharField(_('Stage
Description'),max_length=50)


class Qualification(models.Model):
skillsID = models.AutoField(primary_key=True)
EmployeeID = models.ForeignKey(Employee, verbose_name=_('Employee ID'))
StageID = models.ForeignKey(Skill, verbose_name=_('Stage ID'))
DateOfSkill = models.DateTimeField('Date Of Skill')

class Meta:
unique_together = ('EmployeeID', 'StageID')

both are registered with admin panel:
admin.site.register(Skill)
admin.site.register(Qualification)

The skills admin screen works great, I can add skill, delete skill and
modify skill.
But, when I try to see the Qualification admin panel I get this error
message:
Request Method: GET  Request URL:
http://localhost:8000/admin/proposal/qualification/  Exception Type:
TemplateSyntaxError  Exception Value:

Caught an exception while rendering: coercing to Unicode: need string
or buffer, Skill found


What am I doing wrong? why is it not working?

Template error:
In template
/usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/change_list.html,
error at line 34
   Caught an exception while rendering: coercing to Unicode: need string or
buffer, Skill found
   24 : {% if cl.has_filters %}
   25 : 
   26 : {% trans 'Filter' %}
   27 : {% for spec in cl.filter_specs %}
   28 :{% admin_list_filter cl spec %}
   29 : {% endfor %}
   30 : 
   31 : {% endif %}
   32 : {% endblock %}
   33 :
   34 : {% block result_list %} {% result_list cl %} {% endblock %}
   35 : {% block pagination %}{% pagination cl %}{% endblock %}
   36 : 
   37 : 
   38 : {% endblock %}
   39 :

-- 
Nitzan Brumer
Http://n2b.org

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



Strage Url Tag Problem

2008-12-11 Thread madhav

I am facing a strage error while using 'url' tag. I am using {%url
logout%} for getting the logout url in the template. It is telling
"Reverse for 'PROD_settings.logout' with arguments '()' and keyword
arguments '{}' not found". Why is it referring logout as
PROD_settings.logout???
and by the way PROD_settings is the settings file I use for running
the server. and this error is coming only once in a while. But its
really frustrating. Please help me out
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: models.FileField() vs. forms.FileField()

2008-12-11 Thread Alex Koshelev
models.FileField realy requires `upload_to` param. And it can be callable
with `instance` argument [1]. Using this feature you can generate upload
path by the instance fields.

[1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

On Thu, Dec 11, 2008 at 13:47, Alan <[EMAIL PROTECTED]> wrote:

> Hello there!
> So, I am trying to build a model and from it build a form. I have something
> like:
>
> class Job(models.Model):
>
> juser = models.CharField(max_length=40)
>
> jname = models.CharField(max_length=255)
>
> title = models.CharField(max_length=255, null=True, blank=True)
>
> file = models.FileField()
>
> jdate = models.DateTimeField('Job start date and time')
>
> jobdir = models.FilePathField(path='.')
>
> class JobForm(ModelForm):
>
> class Meta:
>
> model = Job
>
> fields = ('title', 'file')
>
> So, I want in 'view', a form asking for a 'title' (optional) and a file
> (mandatory).
> fields juser, jname, jdate and jobdir  should be filled automatically.
>
> The first problem I have here is that while using a variant of way, calling
> UploadFileForm instead of JobForm:
>
> class UploadFileForm(forms.Form):
>
> title = forms.CharField(max_length=50)
>
> file = forms.FileField()
>
> It works fine with UploadFileForm but if with JobForm, it complains about
> "FileFields require an "upload_to" attribute."
>
> In the end, what I want is from 'view', submit a file and from that derive
> jname, jdate, compose a path (e.g. 'user/jname_jdate') and pass it to jobdir
> and save 'file' in this path (that will be created of course). So, if this
> 'path' still doesn't exist before instantiating 'Job', how can I pass this
> attribute? With UploadFileForm I don't have this problem but then I didn't
> figure out how to feed my DB with juser, jname, title (which may be Null or
> not), jobdir and I don't want file in DB.
>
> Any suggestion? I really would appreciate any help here. Many thanks in
> advance.
>
> Alan
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> >>http://www.bio.cam.ac.uk/~awd28 <<
>
> >
>

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



models.FileField() vs. forms.FileField()

2008-12-11 Thread Alan
Hello there!
So, I am trying to build a model and from it build a form. I have something
like:

class Job(models.Model):

juser = models.CharField(max_length=40)

jname = models.CharField(max_length=255)

title = models.CharField(max_length=255, null=True, blank=True)

file = models.FileField()

jdate = models.DateTimeField('Job start date and time')

jobdir = models.FilePathField(path='.')

class JobForm(ModelForm):

class Meta:

model = Job

fields = ('title', 'file')

So, I want in 'view', a form asking for a 'title' (optional) and a file
(mandatory).
fields juser, jname, jdate and jobdir  should be filled automatically.

The first problem I have here is that while using a variant of way, calling
UploadFileForm instead of JobForm:

class UploadFileForm(forms.Form):

title = forms.CharField(max_length=50)

file = forms.FileField()

It works fine with UploadFileForm but if with JobForm, it complains about
"FileFields require an "upload_to" attribute."

In the end, what I want is from 'view', submit a file and from that derive
jname, jdate, compose a path (e.g. 'user/jname_jdate') and pass it to jobdir
and save 'file' in this path (that will be created of course). So, if this
'path' still doesn't exist before instantiating 'Job', how can I pass this
attribute? With UploadFileForm I don't have this problem but then I didn't
figure out how to feed my DB with juser, jname, title (which may be Null or
not), jobdir and I don't want file in DB.

Any suggestion? I really would appreciate any help here. Many thanks in
advance.

Alan
-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

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



model instance version numbering, or concurrent model editing

2008-12-11 Thread Ronny Haryanto

G'day all,

Let say I have a wiki-like Django app. I wanted to allow many people
edit a wiki page without any locking, yet have the system prevent two
people saving page updates at almost the same time (one of the updates
would be lost, overwritten by the other one).

This is what I have in mind. Add a version field to the WikiPage model
which is automatically incremented on every update. The system should
not allow saving an existing page with version (in db) >= version (in
data to be saved). This is probably done in save().

I've tried overriding the models's save() method, but I'm always stuck
at how to get the guaranteed-most-recent version number (lock the
row/table?) from the db (as opposed to self.version, which could
already be stale by the time save() is called).

My questions are:
* Is my approach reasonable? (or Have I missed a more obvious/easier way?)
* Can this be achieved in Django? If so, any ideas how?
* Should this be done in Django, or better implemented on the database
level as ON UPDATE trigger(s)?

I checked django-wiki app in google code, but it doesn't seem to have
this feature.

I wanted to keep my question focused on one particular issue first,
but if the bigger picture makes any difference: my WikiPage model is
actually an abstract model, and I wanted to provide this feature for
all of its subclasses.

I would appreciate any help.

Cheers,
Ronny

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



designing search functionality

2008-12-11 Thread ReneMarxis

Hi

I have one question reguarding design of an app.
I have one model that has about 10 fields and 3 relations (foreign
key) and i need to make one "Add new" and "Edit" form of it.
My question reguards those relations in the model. How would you
realize a search functionality for those related
model-fields? Selecting the right relation involves a new search form,
as there are 100's of entries one should filter first
before selecting the right on.

Till now i thought of opening a new js window that includes the search
form, and on completition of that search i would set the
result in one hidden field in the parent window.

An other approach would be to have one "Search button" inside the
form, which redirects to one new search form
(in the same window). But then i would have to save the data allready
entered in the form inside my session,
or is there some possibility to pass the whole form from one view to
another? That would be best.


PS: the search functionality will be reused in many other forms...

Any hints would be very welcome :)

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

2008-12-11 Thread Tobias Kräntzer

Am Donnerstag, den 11.12.2008, 10:29 +0100 schrieb Graham Dumpleton:
> A problem recently highlighted with the geos stuff though is that it
> likes to crash if using it on 64 bit Linux architecture.

Good to know. While switching from development to production, we also
switched from 64 to 32 bit.

. . . Tobias


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

2008-12-11 Thread David Reynolds


On 6 Dec 2008, at 19:59, Jeff FW wrote:

> Do you mean when a user is added via the admin interface, or when a
> user registers on the site through a view you have set up?  If it's
> through a view you've made, then just add the call to send_mail() in
> the view.  For the admin site, you'll want to look at signals:
> http://docs.djangoproject.com/en/dev/topics/signals/


Or of course, just overriding the save() method and sticking the  
send_mail() call in there.

At one point signals were said to me quite expensive to use, so  
overriding the save() method was always suggested as being better -  
not sure if that is still true though.

-- 
David Reynolds
[EMAIL PROTECTED]


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



Re: Development server crash with no error message

2008-12-11 Thread Graham Dumpleton



On Dec 11, 8:06 pm, Tobias Kräntzer
<[EMAIL PROTECTED]> wrote:
> Am Donnerstag, den 11.12.2008, 00:05 +0100 schrieb Andrew Fong:
>
> > I'm using MySQLdb, cmemcache, PIL, and the django.contrib.gis stuff.
>
> Hi, we had a similar problem. It turns out, that in our case it was a
> multithreading issue with geos/gdal. For instance using apache2 with
> wsgi and and allowing only one thread per process was helpful.

The development server is single threaded though, so threading
shouldn't be an issue.

A problem recently highlighted with the geos stuff though is that it
likes to crash if using it on 64 bit Linux architecture.  That was
part of asking what platform, although forgot to ask about whether 32
bit or 64 bit version of Python.

Recent threads about this at:

  http://groups.google.com/group/django-users/browse_frm/thread/e337057e9df9bb9
  http://groups.google.com/group/modwsgi/browse_frm/thread/a488d2551c4c7df0

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



Re: Development server crash with no error message

2008-12-11 Thread Tobias Kräntzer

Am Donnerstag, den 11.12.2008, 00:05 +0100 schrieb Andrew Fong:
> I'm using MySQLdb, cmemcache, PIL, and the django.contrib.gis stuff.

Hi, we had a similar problem. It turns out, that in our case it was a
multithreading issue with geos/gdal. For instance using apache2 with
wsgi and and allowing only one thread per process was helpful.

. . . Tobias 



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

2008-12-11 Thread Elvis Stansvik

2008/12/11 Malcolm Tredinnick <[EMAIL PROTECTED]>:
>
>
> On Wed, 2008-12-10 at 06:22 -0800, nucles wrote:
>> Hello,
>>
>> If we create 2 models with many-to-many relationship django creates
>> the intermediary table automatically for us.
>> How can i use this intermediate table to relate other entities?
>
> What do you mean? Normally you don't need to worry about the
> intermediate table at all; it's an implementation detail at the database
> level.
>
> So what is the problem you're trying to solve here?

I agree this question should be asked, but there are valid use cases.
I recently had a Book model and Contributor model which I joined with
a Contribution table, which in turn had a ForeignKey into a
ContributitionType model. This lets me add more types of contributions
to a book in the future, such as author, editor, translator,
illustrator et.c.

Regards,
Elvis

>
> Regards,
> Malcolm
>
>
>
> >
>

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



Re: Access to Many-To-Many intermediary table from django

2008-12-11 Thread Elvis Stansvik

2008/12/10 nucles <[EMAIL PROTECTED]>:
>
> Hello,
>
> If we create 2 models with many-to-many relationship django creates
> the intermediary table automatically for us.
> How can i use this intermediate table to relate other entities? Can i
> access to the primary field of the intermediary table?
> Should i create two One-to-Many relations manually and then use the
> intermediary table?

No, you should still use a ManyToManyField, but use the 'through'
argument to specify the intermediate model, on which you should have
two ForeignKey fields referencing each of your two models. This way
you will have full control over the intermediate table. Read more
about this at:

http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

I'll have to quietly ask the same question as Malcolm though; is this
really what you want?

Regards,
Elvis

>
> Thank you for any suggest
>
> Regardes,
> Dennis
> >
>

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

2008-12-11 Thread bruno desthuilliers



On 11 déc, 01:11, pielgrzym <[EMAIL PROTECTED]> wrote:
(snip)
> The problem with saving is that when I try to save a post instance I
> recieve:
>
> AttributeError: 'TagField' object has no attribute '_meta'
> (link to full error report:http://wklej.org/hash/098a9cbd7a/)
>
> I'm not sure if passing 'self' as content object isn't the reason,

It is, clearly. You're passing a Field object ('self') where a Model
object is expected. It's not the TagField you want to pass but the
Model instance it's bound to. Which should probably be done in pre_save
() - which gets the instance as parm -, not in get_db_prep_value().

For the record and if I may ask : did you investigate solving your
initial problem with the existing tagging app and urllib.quote
instead ?

Also and FWIW : the existing tagging app (just like Django and Python)
is free software. This means that you have the right to read, modify
and redistribute the source code. If tagging is quite close but not
exactly what you want, why don't you start with the existing source
code and improve / taylor to your needs ?


> yet
> I have no idea how to achieve this :(

You could have a look at how tagging implemented TagField, and/or at
django/db/models/fields/__init__.py. Reading the source is most of the
time the best way to understand how something works !-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



SOAPpy and pyxml installation/usage

2008-12-11 Thread Steve

This may be a more of a generic Python question, but I'm working with
Django so thought that I'd see if there's a Django specific solution
to it.

I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
well. From Dive into Python it has this great example about how to
handle SOAP calls.
http://www.diveintopython.org/soap_web_services/index.html

The problem is that I'm trying to install the SOAPpy module and it
requires pyxml, which appears to be no longer available or supported.
http://pyxml.sourceforge.net/

My main goal is to configuremy system to get this code, from the dive
into python link above, to run. Or to find an equivalent set of
packages that work instead. I'm working on windows with python 2.5.1,
with Django .96. I deploy on ubuntu linux. Any thoughts?

...
from SOAPpy import WSDL

# you'll need to configure these two values;
# see http://www.google.com/apis/
WSDLFILE = '/path/to/copy/of/GoogleSearch.wsdl'
APIKEY = 'YOUR_GOOGLE_API_KEY'

_server = WSDL.Proxy(WSDLFILE)
def search(q):
"""Search Google and return list of {title, link, description}"""
results = _server.doGoogleSearch(
APIKEY, q, 0, 10, False, "", False, "", "utf-8", "utf-8")
return [{"title": r.title.encode("utf-8"),
 "link": r.URL.encode("utf-8"),
 "description": r.snippet.encode("utf-8")}
for r in results.resultElements]




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