Re: user registration

2006-07-14 Thread Kenneth Gonsalves


On 14-Jul-06, at 11:50 PM, patrickk wrote:

> 1. how do I save the password (seems that I have to change new_data
> which doesn´t look clean to me ...) - note: I know how to generate
> the password from a raw string though.

create_user generates the password from the raw string
then you manually add the other fields life firstname, lastname etc  
and save

-- 

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



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



Re: debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread Keith Dart
Scott Chapman wrote the following on 2006-07-14 at 10:34 PDT:
===
> 3) If neither of the above is possible, give me some suggestions how to debug 
> these "blind" POST's

===

If you are using mod_python under Apache, you can do this:

from mod_python import apache
apache.log_error(str(request)) # or whatever

Then you will see your message appear in your apache error log. This is
a simple equivalent of a "print" statement for mod_python. Not as good
as a debugger, but might help you.
 


-- 

-- -
Keith Dart
<[EMAIL PROTECTED]>
GPG Key Id: 57C0417D



signature.asc
Description: PGP signature


Re: Custom Manipulator problem

2006-07-14 Thread Robert

Hello Jorge,

Adding save() method solved the problem.
Seems like I misunderstood the documentation.

As for using Entry.AddManipulator: I can't use it as I want to use my
own additional validation methods like: (`nr` starting from 023, etc.).
Maybe this could be done the other way (validation methods defined in
my model,
and validator_list= for specified field in my model definition), but
I've decided to play (and learn the) with
manipulators.

Thanks!

Robert

Jorge Gajon napisal(a):
> Hi,
> You need to implement the save() method in your custom manipulator.
>
> Cheers
>
>
> On 7/14/06, Robert <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > When using custom Manipulator (which in fact does nothing.. I've cut
> > some additional custom validation here) I'm getting error as follows:
> > 
> > Traceback (most recent call last):
> > File
> > "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py"
> > in get_response
> >   74. response = callback(request, *callback_args, **callback_kwargs)
> > File "/usr/local/www/data/django/projects/pbook/../pbook/book/views.py"
> > in create_entry
> >   23. new_entry = manipulator.save(new_data)
> > File
> > "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/forms/__init__.py"
> > in save
> >   92. raise NotImplementedError
> >
> >   NotImplementedError at /
> > -
> >
> > Python 2.4.2, DB: SQLite, svn from trunk as of July 13th
> >
> > Error occurs on POST when submitting, I am able to see & fill in the
> > form.
> >
> > This is my code:
> >
> > ---> book/models.py
> > from django.db import models
> >
> > class Entry(models.Model):
> > name = models.CharField(blank=False, maxlength=30)
> > last = models.CharField(blank=False, maxlength=50)
> > nr = models.IntegerField(unique=True, blank=True, maxlength=10)
> > nr_mobile = models.IntegerField(unique=True, blank=True,
> > maxlength=9)
> >
> > def __str__(self):
> > return self.name
> >
> > class Admin:
> > pass
> >
> > --> book/views.py
> > from django.shortcuts import render_to_response
> > from django.core import validators
> > from django import forms
> > from pbook.book.models import Entry
> > from django.http import Http404, HttpResponse, HttpResponseRedirect
> >
> > def create_entry(request):
> > manipulator = EntryManipulator()
> >
> > if request.POST:
> > new_data = request.POST.copy()
> >
> > errors = manipulator.get_validation_errors(new_data)
> >
> > if not errors:
> > manipulator.do_html2python(new_data)
> > new_entry = manipulator.save(new_data)
> > return HttpResponse("Entry created: %s" % new_entry)
> > else:
> > errors = new_data = {}
> >
> > form = forms.FormWrapper(manipulator, new_data, errors)
> > return render_to_response('book/entry_form.html', {'form': form })
> >
> > class EntryManipulator(forms.Manipulator):
> > def __init__(self):
> > self.fields = (
> > forms.TextField(field_name='name',
> > is_required=True, maxlength=30),
> > forms.TextField(field_name='last',
> > is_required=True, maxlength=50),
> > forms.IntegerField(field_name='nr',
> > maxlength=10),
> > forms.IntegerField(field_name='nr_mobile',
> > maxlength=9),
> >   )
> >
> > ---> urls.py
> > from django.conf.urls.defaults import *
> > from pbook.book.models import Entry
> >
> > urlpatterns = patterns('',
> >  (r'^$', 'pbook.book.views.create_entry'),
> >  (r'^admin/', include('django.contrib.admin.urls')),
> > )
> >
> > ---> templates/book/entry_form.html
> > {% if form.has_errors %}
> > Please correct the following error{{ form.error_dict|pluralize
> > }}:
> > {% endif %}
> >
> > 
> > 
> > Name: {{ form.name }}
> > {% if form.name.errors %}*** {{ form.name.errors|join:", " }}{%
> > endif %}
> > 
> > 
> > Last: {{ form.last }}
> > {% if form.last.errors %}*** {{ form.last.errors|join:", " }}{%
> > endif %}
> > 
> > 
> > Phone nr: {{ form.nr }}
> > {% if form.nr.errors %}*** {{ form.nr.errors|join:", " }}{% endif
> > %}
> > 
> > 
> > Mobile nr: {{ form.nr_mobile }}
> > {% if form.nr_mobile.errors %}*** {{ form.nr_mobile.errors|join:",
> > " }}{% endif %}
> > 
> > 
> > 
> >
> > Thanks,
> > Robert
> >
> >
> > >
> >


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



Re: Perspective on building a community blog in a short timeframe

2006-07-14 Thread arthur debert

Hi Joe.

Also if you don't fell like reinventing the wheel, you might want to
take a look at limodou's multi-user  blog app written in django.
It's been a while since I haven't played with it, but it's probably
worth a look. More info here:
http://groups.google.com/group/django-users/browse_frm/thread/cc39700cc7147ed9/0675e2d713071f39?q=limodou=3#0675e2d713071f39

cheers
Arthur


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



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread [EMAIL PROTECTED]

nice, very nice :) pylons and Turbogears benchmark would add a bit of
flamish excitement to it... (and it would be quite interesting)


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



Re: recursive transaction support

2006-07-14 Thread Alan Green

On 7/15/06, Panard <[EMAIL PROTECTED]> wrote:
>snip<

> So, is it only the sqlite backend wich doesn't support recursive transactions,
> or is django missing that point ?
> If it's only a sqlite problem, is there a workaround?

In this situation, I'd be looking at writing my own decorator which
counts how many transactons have been nested and only commits when
control returns through the "outermost" level. You could store the
nesting level in a thread local variable. You will need to be careful
to define the semantics of exception recovery - for example, if method
a raises an exception, which b catches and doesn't re-raise.

a

-- 
Alan Green
[EMAIL PROTECTED] - http://bright-green.com

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



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Iain Duncan



Andy Dustman wrote:
> On 7/14/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> 
>>On Jul 14, 2006, at 1:18 PM, Adrian Holovaty wrote:
>>
>>>Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
>>>the fastest.
>>
>>By over 30% -- hell yeah!
>>
>>Now, I've always known in my gut that Django's pretty damn fast, but
>>seeing it verified by the RoR website...
>>
>>Priceless :)
> 
> 
> And with MySQL, to boot.

This is not surprising, it was a "many small hit" benchmark, and mysql
has long outperformed PostGress in that department. I've also seen
shootouts of python vs perl vs php for backending and mod_python just
plain hauls ass. ;)

Iain

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



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Rafael Jorge
On 7/14/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
And with MySQL, to boot.
Nothing is perfect..xD

-- SDM UnderlinuxGarimpar.com--PEP-8"Mais vale um ponteiro na mao do que duas classes voando"

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


Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Andy Dustman

On 7/14/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Jul 14, 2006, at 1:18 PM, Adrian Holovaty wrote:
> > Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
> > the fastest.
>
> By over 30% -- hell yeah!
>
> Now, I've always known in my gut that Django's pretty damn fast, but
> seeing it verified by the RoR website...
>
> Priceless :)

And with MySQL, to boot.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

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



Re: Perspective on building a community blog in a short timeframe

2006-07-14 Thread Joe Murphy

Ah, thanks for the perspective Julio.

We're looking to do more a local test-of-concept, which makes it easy
to cut down on the bells / whistles.

However, my boss doesn't get angry, he gets stabby. It may be best to
play it safe.

I'm going to play with Django more this weekend on some other projects
and see how I do...


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



Re: debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread [EMAIL PROTECTED]

This might be of use:

http://code.djangoproject.com/wiki/CookBookDeveloperTools

Also, maybe modifying what the debug tag might help, print it to the
console instead of HTML:

25  class DebugNode(Node):
26  def render(self, context):
27  from pprint import pformat
28  output = [pformat(val) for val in context]
29  output.append('\n\n')
30  output.append(pformat(sys.modules))
31  return ''.join(output)

Can also just set up a print statement, if you haven't already tried
it: print request.POST

Chris

Scott Chapman wrote:
> I am building a new site and my view has some code in it that blows up.
>
> It's in an xmlhttprequest call so I never get to see the blow up, and it's a
> form POST so I can't simply call it with some command line parms in the
> browser to see it - so I'm flying blind a bit.
>
> When I set DEBUG=True, the tracebacks get output in the browser but I never
> see that.  I want them in my log file on the console.
>
> When I set DEBUG=False, it yells at me that there's no 500.html around, which
> I again don't need because I'll never see it and don't want to worry about
> that right now as I'm a ways from going production here.
>
> 1) Is there a way to call my views in the django shell and emulate a POST?
>
> 2) Is there a way to get the tracebacks into my console log when DEBUG=True?
>
> 3) If neither of the above is possible, give me some suggestions how to debug
> these "blind" POST's
>
> 4) If none of the 3 above - where's the docs on setting up a 500.html that
> I'll not need to see.
> 
> Thanks!
> Scott


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



Re: debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread Jeremy Dunck

On 7/14/06, Scott Chapman <[EMAIL PROTECTED]> wrote:
> 3) If neither of the above is possible, give me some suggestions how to debug
> these "blind" POST's

Run with the built-in server and put this in your view code:

import pdb
pdb.set_trace()

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



Re: user registration

2006-07-14 Thread [EMAIL PROTECTED]


Haven't done any work on this, but I made some notes that might be of
help.

patrickk wrote:
> I´m using the built-in authentication and now I´m trying to do a
> registration page (for the website-user, not the admin-user).
> I´m using an AddManipulator (manipulator = User.AddManipulator()),
> but I do have some problems:
>
> 1. how do I save the password (seems that I have to change new_data
> which doesn´t look clean to me ...) - note: I know how to generate
> the password from a raw string though.

Are you overriding the save method in the manipulator? You can convert
the password in that method as an option.

> 2. there´s no validation (how do I get that?)

http://www.djangoproject.com/documentation/forms/#validators

> 3. date_joined and last_login seems to be required, as well as
> first_name and last_name (although they don´t show up as required in
> the admin-interface)

This has to do with the whole "null" and "blank" thing. See
http://www.b-list.org/weblog/2006/06/28/django-tips-difference-between-blank-and-null
for more details. Those fields in the user model are set as "blank" but
not as "null", which is causing this problem. If you don't want to use
those fields just pass an empty string to the constructor, that should
work.

> 
> has anybody done that already? any pointers?
> 
> thanks,
> patrick


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



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Ian Maurer

On 7/14/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Jul 14, 2006, at 1:18 PM, Adrian Holovaty wrote:
> > Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
> > the fastest.
>
> By over 30% -- hell yeah!
>

That's awesome... congrats Django developers!

-ian

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



Re: Perspective on building a community blog in a short timeframe

2006-07-14 Thread Julio Nobrega

  This might sound a little harsh, but if you need to ask if you can
do it in Django, then you shouldn't do it.

  Not because it is not entirely possible... but because you're not
confortable with the framework and its quirks and your productivity on
it, yet. Since this is your Real Job, that will (probably) have your
boss angry at you if it's not delivered on time...

  Also, the requirements that you gave us are too much broad: No
multi-user weblog app with media files is only that. There will
probably be comments (threaded?, how to deal spam?), image galleries,
you will need HTML formatting while editing the posts, tags (?),
categories, social-networking features (?), user registration,
RSS/Atom, technoratti ping, templates per-user, plugins (?), send
article via email, stuff like that.

  A full-wordpress clone in three weeks... I don't think it's a
realistic goal. Unless you want something simpler. Talk to your boss
and get *every* requirement for the project. If you don't need the
fancy stuff (which I doubt, but I don't work there :p), try Django,
otherwise, hack WP.

On 7/14/06, Joe Murphy <[EMAIL PROTECTED]> wrote:
>
> Hi y'all,
>
> This week my boss sprang a new project on me: Build a community blog
> app (multiple blogs and multiple users, also with photo- and video-type
> content integrated and indexed). In three weeks.
>
> The original idea was to hack the Multi-User Wordpress to make this
> work. I've done my time with PHP (5 years), so I figure I could hack
> it.
>
> However, I'd much rather do it in Django. I've been messing around with
> Django for about a month now, and it's real pretty. I'm no expert
> though.
>
> Thought I would ask you all what your thoughts were on this -- hacking
> an established application to get it to do what I want vs. building an
> app from scratch, on a restricted timeline.
>
> Thanks,
> Joe
>
>
> >
>


-- 
Julio Nobrega - http://www.inerciasensorial.com.br

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



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Jacob Kaplan-Moss

On Jul 14, 2006, at 1:18 PM, Adrian Holovaty wrote:
> Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
> the fastest.

By over 30% -- hell yeah!

Now, I've always known in my gut that Django's pretty damn fast, but  
seeing it verified by the RoR website...

Priceless :)

Jacob


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



Re: Syncdb generates non-unique foreign key constraints

2006-07-14 Thread DavidA

As soon as I hit "Post" I realized this should be in django-developers.
I'll do that now...


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



Syncdb generates non-unique foreign key constraints

2006-07-14 Thread DavidA

I've been having a problem rebuilding my database from scratch via
syncdb. I've tracked it down to duplicate constraint name. Here is the
output from manage.py sql for my app:

ALTER TABLE `data_rawinst` ADD CONSTRAINT
`inst_id_referencing_data_inst_id` FOREIGN KEY (`inst_id`) REFERENCES
`data_inst` (`id`);
ALTER TABLE `data_instmap` ADD CONSTRAINT
`inst_id_referencing_data_inst_id` FOREIGN KEY (`inst_id`) REFERENCES
`data_inst` (`id`);

Note that I have two tables, both with FK's to data_inst and its
generating the same constraint name
(`inst_id_referencing_data_inst_id`). It seems the source table should
be part of that name, such as
`data_rawinst_inst_id_referencing_data_inst_id`.

I'm on the trunk at Rev 3350.

This used to work, I'm pretty sure, but I haven't rebuilt the whole DB
from scratch for a long time so I don't know if its been lingering for
a while.

Thanks,
-Dave


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



Re: debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread Scott Chapman

Simon Willison wrote:
> 
> On 14 Jul 2006, at 18:34, Scott Chapman wrote:
> 
>> It's in an xmlhttprequest call so I never get to see the blow up,  
>> and it's a
>> form POST so I can't simply call it with some command line parms in  
>> the
>> browser to see it - so I'm flying blind a bit.
> 
> Get yourself Firefox and the LiveHTTPHeaders extension - it's perfect  
> for debugging this kind of thing:
> 
> http://livehttpheaders.mozdev.org/

I have it and it's helpful but it doesn't address any of the issues in my 
post.  I need to be able to see the error on the server side when things break.

Scott


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



Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Adrian Holovaty

Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
the fastest.

Check it out here:

http://wiki.rubyonrails.com/rails/pages/Framework+Performance

And don't forget to Digg and del.icio.us!

http://digg.com/programming/Django_vs._Rails_vs._Symfony_Django_is_fastest
http://del.icio.us/url/c44bdc6ac0cd2adfa4eb38af27b9f644

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Perspective on building a community blog in a short timeframe

2006-07-14 Thread Joe Murphy

Yup, I caught that earlier today, it's a good start. I think the
details that matter here are the timeline, ease-of-use by a
non-technical audience, and hacking a pre-packaged solution vs.
building from scratch.


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



Re: recursive transaction support

2006-07-14 Thread Jacob Kaplan-Moss

On Jul 14, 2006, at 10:47 AM, Panard wrote:
> So, is it only the sqlite backend wich doesn't support recursive  
> transactions,
> or is django missing that point ?
> If it's only a sqlite problem, is there a workaround?

No databases that I'm aware of support nested transactions, thus  
Django doesn't either.

Jacob

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



Re: Perspective on building a community blog in a short timeframe

2006-07-14 Thread Guillermo Fernandez Castellanos

Don't know if this answers your question:
http://www.b-list.org/weblog/2006/07/03/django-tips-scaling-application

Good luck!

G

On 7/14/06, Joe Murphy <[EMAIL PROTECTED]> wrote:
>
> Hi y'all,
>
> This week my boss sprang a new project on me: Build a community blog
> app (multiple blogs and multiple users, also with photo- and video-type
> content integrated and indexed). In three weeks.
>
> The original idea was to hack the Multi-User Wordpress to make this
> work. I've done my time with PHP (5 years), so I figure I could hack
> it.
>
> However, I'd much rather do it in Django. I've been messing around with
> Django for about a month now, and it's real pretty. I'm no expert
> though.
>
> Thought I would ask you all what your thoughts were on this -- hacking
> an established application to get it to do what I want vs. building an
> app from scratch, on a restricted timeline.
>
> Thanks,
> Joe
>
>
> >
>

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



Re: debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread Simon Willison


On 14 Jul 2006, at 18:34, Scott Chapman wrote:

> It's in an xmlhttprequest call so I never get to see the blow up,  
> and it's a
> form POST so I can't simply call it with some command line parms in  
> the
> browser to see it - so I'm flying blind a bit.

Get yourself Firefox and the LiveHTTPHeaders extension - it's perfect  
for debugging this kind of thing:

http://livehttpheaders.mozdev.org/

Cheers,

Simon

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



debugging xmlhttprequest POST's is a PAIN! Need help.

2006-07-14 Thread Scott Chapman

I am building a new site and my view has some code in it that blows up.

It's in an xmlhttprequest call so I never get to see the blow up, and it's a 
form POST so I can't simply call it with some command line parms in the 
browser to see it - so I'm flying blind a bit.

When I set DEBUG=True, the tracebacks get output in the browser but I never 
see that.  I want them in my log file on the console.

When I set DEBUG=False, it yells at me that there's no 500.html around, which 
I again don't need because I'll never see it and don't want to worry about 
that right now as I'm a ways from going production here.

1) Is there a way to call my views in the django shell and emulate a POST?

2) Is there a way to get the tracebacks into my console log when DEBUG=True?

3) If neither of the above is possible, give me some suggestions how to debug 
these "blind" POST's

4) If none of the 3 above - where's the docs on setting up a 500.html that 
I'll not need to see.

Thanks!
Scott

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



Re: Extending pluralize?

2006-07-14 Thread Ivan Sagalaev

Russell Keith-Magee wrote:
> I'm a beliver that any tool should make the simple trivial and the 
> difficult possible. To that end, I don't think there is a universal 
> solution to pluralization. If a few small changes can get the existing 
> solution to cover a few more languages (including Slovenian) with 
> 'simple' pluralization strategies, then I think we should take the 
> opportunity.

Sure. This whole pluralization problem can be divided into two:

1. Enhance pluralization filter to accept language specific set of 
terminations and peek the right one by language-dependent algorithm. 
There a human is responsible for providing the exact values for 
pluralization forms and this task, in my opinion, is perfectly doable 
and should be done within Django.

2. Automatic pluralization of any (or most) words. This one is requiring 
a vocabulary and is a big task in itself.

> Then, if Ivan wants to contribute a 'declention' template tag that 
> supports Russian  pluralization (and is flexible enough to handle other 
> languages with 'complex' pluralization, e.g., Latin), I'd be happy to 
> add it. It would fit well in the django.templatetags.i18n package, 
> especially if it took into account the current language page code when 
> applying its strategy.

Well... A tag (or rather a filter) choosing one of three forms would be 
very simple. In fact I've heard gettext already has such functionality 
but I'm not very familliar with it. What is required in Django itself is 
some mechanism choosing the right pluralization plugin based on page 
language. But this looks more like a separate topic for 
django-developers already :-)

> but with English, you end up with constant 
> battles over the 'correct' plural (is it viruses or virii? octopuses, 
> octopus or octopodes?)

Funny :-) For this case Russian has a single authoritative source in the 
form of official vocabularies.

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



CGI Setup

2006-07-14 Thread Martin Glück

Hi,

I have been looking at Django for a few weeks now and I must say I'm
really impressed.
Since I love python I was looking around for a framework based on python
and finally found Django.

I#M planing an changing a site currently running on some home grown code
to use Django. Unfortunately, the provider currently hosting the site
does not support mode_python or FCGI or anything like it.

They only way to go would be the "normal" CGI interface. I know that
this will be a performance problem (because the the models have to be
re-read with every request) but I would like to give it a try to see how
"bad" the performance really is.

I looked around a bit in the source but I got a little bit lost (it is
always hard to walk your way trough existing sources if you don't know
where to start. I'm kind of newbie to all the WSGI, FCGI stuff, so I my
miss something here but I could not find the "entry" into the Django system.

Can anybody give me tip where I should start looking? My assumption is
that I need to create a kind of "Request" object and then call the
current Django "entry" function to get the response back.

Or do you think I it's not worth the effort because the performance is
too and my time is better used finding a different solution (sorry,
changing the provider is currently not a option...)

Thanks for your insight and keep up the great work,

Martin

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



Re: Samples for displaying a tree of data

2006-07-14 Thread Chris Moffitt

>
> I like to use elementtree here... The result tree can be cached and in
> the end you have a more usefull representation...
>
Interesting.  Do you have any reference code I could look at to try to
wrap my brain around it?

I haven't had a chance to look at Malcolm's samples yet but I do intend to
look at it later tonight.

Thanks,
Chris

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



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

2006-07-14 Thread Waylan Limberg

On 7/13/06, Wei Litao <[EMAIL PROTECTED]> wrote:
>
> I already have lots of static files in my lighttpd web server, so I'd
> like it to only talk to the django server if it can't find what it's
> looking for. So I'd like use error-handler-404 directive to do that
> thing.
> In django official document, it use url-write method to talk to django
> server. Is is possible to
> hack that script to use error-handler-404?
>

I'm not familiar with using lighttpd, but I know that if that was done
is Apache (and it is fairly easy to do), it is frowned upon as it
causes each request to add to the error logs. Imagine trying to
find/debug a real problem in a high traffic site in that situation.

The Apache solution is to use conditional statments to only use the
rewrite rules if the requested file/directory/etc does not already
exist in the file system. You may want to check with lighttpd for a
similar feature. When you find a solution, feel free to post back here
for others benefit.


-- 

Waylan Limberg
[EMAIL PROTECTED]

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



recursive transaction support

2006-07-14 Thread Panard
Hi,

I would like to ask a question concerning recursive transactions.

By recursive transaction I mean :

@django.db.transaction.commit_on_success
def a() :
# do some stuff

@django.db.transaction.commit_on_success
def b() :
# do some stuff
a()
# do some stuff
a()
# do some stuff


I would like when calling b(), the real commit will only be done when b 
returns (and not each time a() returns + when b() returns

I'm testing on a sqlite backend and there is a real commit after each call to 
a() : after raising an exception in the middle of b(), the stuff done by 
previous calls to a() is in the database.

So, is it only the sqlite backend wich doesn't support recursive transactions, 
or is django missing that point ?
If it's only a sqlite problem, is there a workaround?

Thanks.

Panard
-- 
HomePage: http://dev.inzenet.org/~panard/
Yzis : http://www.yzis.org
Qomics : http://dev.inzenet.org/~panard/qomics
Smileys : http://smileys.inzenet.org

-- 
HomePage: http://dev.inzenet.org/~panard/
Yzis : http://www.yzis.org
Qomics : http://dev.inzenet.org/~panard/qomics
Smileys : http://smileys.inzenet.org


pgpu8yB3yHaqe.pgp
Description: PGP signature


Re: Django and MySQLdb on Bluehost

2006-07-14 Thread Waylan Limberg

On 7/12/06, Steve <[EMAIL PROTECTED]> wrote:
>
> Nevermind, I figured it out.  Gosh I get smarter just by writing to
> this group :)
>
> All I had to do was add the local path of MySQLdb to my .fcgi file
> under my web root directory.  So:
> sys.path += ['/homedir/pythondir']
>
>
This is a common mistake I've seen a number of times in this list.
Remember that the .bash_profile is for a specific user (you) and
Apache/mod_python/fcgi is (usually) running under a different user so
those processes will never see settings in your .bash_profile. The
solution (as you discovered) is to add the appropriate settings to
your fcgi/mod_python settings.


-- 

Waylan Limberg
[EMAIL PROTECTED]

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



Re: Samples for displaying a tree of data

2006-07-14 Thread mamcxyz

I like to use elementtree here... The result tree can be cached and in
the end you have a more usefull representation...

Plus, traslate it to any html tree control become more easy...


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



Re: Extending pluralize?

2006-07-14 Thread Adrian Holovaty
On 7/14/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> Honestly I never saw a proper implementation of a pluralize function,
> that was universal enough... can we get a shot at this, at all?

Although I understand the problem (I speak Ukrainian, and it has some
fancy pluralization as well), I don't think handling all forms of
pluralization is within the scope of our Web framework. The only
reason the "pluralize" filter exists is for an 80% case -- the 80% of
words in the English language that can be pluralized by adding "s"
(or, thanks to the recent improvements to the filter, a configurable
suffix).

I'd encourage you to create and distribute your own language-specific
pluralization template tags/filters, but they're out of the scope of
the framework.

äÑËÕÀ,
Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Extending pluralize?

2006-07-14 Thread Carlos Yoder

Russel, I wrote my last comment before seeing yours. Just so that you know :-)

On 7/14/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
> > > The problem is that it's not 1, 2, 3, 4 and others :-). For Russian it's:
> > >
> > > 1 form, if it ends with 1 but excluding 11
> > > 2 form, if it ends with 2, 3, 4 but excluding 12, 13, 14
> > > 3 form, for everything else and all previous exclusions.
> > >
> > > So this is not compatible with English at all because 21 and 1 should
> > > work the same in Russian but different in English. May be other slavic
> > > languages have their forms and exceptions also.
> >
> > Thank you Ivan for clarifying that... I was just going to ask you for
> > the cases in Russian. Honestly I can't see a universal way of doing
> > this -- languages are the very definition of diversity! :-P
> >
> > What do you think, Russell?
>
> How about using array slices? (I mean the [:] syntax). Maybe in that
> way you could specify something along the lines of:
>
> plural[1:3] = "i"  # if items are 1, 2 or 3, use 'i' as ending
>
> As I type this I realize this would be not enough. This new pluralize
> method should accomodate for all possibilities (for only 1 item, items
> 2-5, default plurarizer and so on), so... does this mean we're stuck
> with a dictionary?
>
> Honestly I never saw a proper implementation of a pluralize function,
> that was universal enough... can we get a shot at this, at all?
>
> OTOH, the dictionary approach Ivan mentioned would still have to be in
> place, since nouns of different genders have different plural
> families.
>
>
> ps to all of you native English speakers: lucky you! =)
> --
> Carlos Yoder
> http://carlitosyoder.blogspot.com
>


-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: Extending pluralize?

2006-07-14 Thread Carlos Yoder

> > The problem is that it's not 1, 2, 3, 4 and others :-). For Russian it's:
> >
> > 1 form, if it ends with 1 but excluding 11
> > 2 form, if it ends with 2, 3, 4 but excluding 12, 13, 14
> > 3 form, for everything else and all previous exclusions.
> >
> > So this is not compatible with English at all because 21 and 1 should
> > work the same in Russian but different in English. May be other slavic
> > languages have their forms and exceptions also.
>
> Thank you Ivan for clarifying that... I was just going to ask you for
> the cases in Russian. Honestly I can't see a universal way of doing
> this -- languages are the very definition of diversity! :-P
>
> What do you think, Russell?

How about using array slices? (I mean the [:] syntax). Maybe in that
way you could specify something along the lines of:

plural[1:3] = "i"  # if items are 1, 2 or 3, use 'i' as ending

As I type this I realize this would be not enough. This new pluralize
method should accomodate for all possibilities (for only 1 item, items
2-5, default plurarizer and so on), so... does this mean we're stuck
with a dictionary?

Honestly I never saw a proper implementation of a pluralize function,
that was universal enough... can we get a shot at this, at all?

OTOH, the dictionary approach Ivan mentioned would still have to be in
place, since nouns of different genders have different plural
families.


ps to all of you native English speakers: lucky you! =)
-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: MySQLdb problems

2006-07-14 Thread DvD

Thank you very much Geert, it worked well.

Cheers, David



On Thu, 13 Jul 2006 19:27:56 +0200, Geert Vanderkelen <[EMAIL PROTECTED]>  
wrote:

>
> Hi David,
>
> birrafondaio wrote:
> ..
>> raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
>> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
>> module: cannot import name ImmutableSet
>> ---
>>
>> I already searched for people with similar problems as mine but can`t
>> find any solution.
>> I`ve already installed mysql and mysql-python but nothing seems to
>> work, can someone help me please? I`m getting desperate, any help will
>> be much appreciated.
> ..
>
> This has been discussed here before. You probably upgraded MySQLdb over  
> an
> older version. You need to remove set.py from the MySQLdb 1.2.1  
> installation.
>
> I reported it here:
> http://sourceforge.net/tracker/index.php?func=detail=1445105_id=22307=374932
>
> Hope this works.
>
> Cheers,
>
> Geert
>



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



Re: Extending pluralize?

2006-07-14 Thread Russell Keith-Magee
On 7/14/06, Carlos Yoder <[EMAIL PROTECTED]> 
What do you think, Russell?I'm a beliver that any tool should make the simple trivial and the difficult possible. To that end, I don't think there is a universal solution to pluralization. If a few small changes can get the existing solution to cover a few more languages (including Slovenian) with 'simple' pluralization strategies, then I think we should take the opportunity. 
Then, if Ivan wants to contribute a 'declention' template tag that supports Russian  pluralization (and is flexible enough to handle other languages with 'complex' pluralization, e.g., Latin), I'd be happy to add it. It would fit well in the 
django.templatetags.i18n package, especially if it took into account the current language page code when applying its strategy.I believe the 'dictionary of all plurals' approach is what Rails does. From what I've seen, it's not a good approach. I don't know if this a problem with other languages, but with English, you end up with constant battles over the 'correct' plural (is it viruses or virii? octopuses, octopus or octopodes?) as a result of the multiple base-languages that have contributed to English over the years, persistent errors in usage, and disagreements over descriptive versus prescriptive generation of vocabulary. Then, to make things worse, the whole thing falls apart when you find a word that isn't in the plural dictionary. I, for one, would oppose the introduction of this approach.
Russ Magee %-)

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


Re: Django hosting

2006-07-14 Thread julián

Send me a private (to avoid being off-topic) e-mail with the type of
project (mainly how many users will test it, if you required disk for
file uploads and this kind of things)

If the client buy I cant host the final version for a bargain price ;)

--
Julián Romero


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



Re: Extending pluralize?

2006-07-14 Thread Carlos Yoder

> The problem is that it's not 1, 2, 3, 4 and others :-). For Russian it's:
>
> 1 form, if it ends with 1 but excluding 11
> 2 form, if it ends with 2, 3, 4 but excluding 12, 13, 14
> 3 form, for everything else and all previous exclusions.
>
> So this is not compatible with English at all because 21 and 1 should
> work the same in Russian but different in English. May be other slavic
> languages have their forms and exceptions also.

Thank you Ivan for clarifying that... I was just going to ask you for
the cases in Russian. Honestly I can't see a universal way of doing
this -- languages are the very definition of diversity! :-P

What do you think, Russell?

-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: Extending pluralize?

2006-07-14 Thread Ivan Sagalaev

Russell Keith-Magee wrote:
> This should be fairly easy to extend to a 1,2,3,4,... case; in your 
> dolphin case, something like delfin{{ num_delfinov|pluralize:",a,i,ov"}}
> 
> (excuse my Slovenian if I've messed up your example :-)

The problem is that it's not 1, 2, 3, 4 and others :-). For Russian it's:

1 form, if it ends with 1 but excluding 11
2 form, if it ends with 2, 3, 4 but excluding 12, 13, 14
3 form, for everything else and all previous exclusions.

So this is not compatible with English at all because 21 and 1 should 
work the same in Russian but different in English. May be other slavic 
languages have their forms and exceptions also.

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



Custom Manipulator problem

2006-07-14 Thread Robert

Hello,

When using custom Manipulator (which in fact does nothing.. I've cut
some additional custom validation here) I'm getting error as follows:

Traceback (most recent call last):
File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py"
in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/www/data/django/projects/pbook/../pbook/book/views.py"
in create_entry
  23. new_entry = manipulator.save(new_data)
File
"/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/forms/__init__.py"
in save
  92. raise NotImplementedError

  NotImplementedError at /
-

Python 2.4.2, DB: SQLite, svn from trunk as of July 13th

Error occurs on POST when submitting, I am able to see & fill in the
form.

This is my code:

---> book/models.py
from django.db import models

class Entry(models.Model):
name = models.CharField(blank=False, maxlength=30)
last = models.CharField(blank=False, maxlength=50)
nr = models.IntegerField(unique=True, blank=True, maxlength=10)
nr_mobile = models.IntegerField(unique=True, blank=True,
maxlength=9)

def __str__(self):
return self.name

class Admin:
pass

--> book/views.py
from django.shortcuts import render_to_response
from django.core import validators
from django import forms
from pbook.book.models import Entry
from django.http import Http404, HttpResponse, HttpResponseRedirect

def create_entry(request):
manipulator = EntryManipulator()

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

errors = manipulator.get_validation_errors(new_data)

if not errors:
manipulator.do_html2python(new_data)
new_entry = manipulator.save(new_data)
return HttpResponse("Entry created: %s" % new_entry)
else:
errors = new_data = {}

form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('book/entry_form.html', {'form': form })

class EntryManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
forms.TextField(field_name='name',
is_required=True, maxlength=30),
forms.TextField(field_name='last',
is_required=True, maxlength=50),
forms.IntegerField(field_name='nr',
maxlength=10),
forms.IntegerField(field_name='nr_mobile',
maxlength=9),
  )

---> urls.py
from django.conf.urls.defaults import *
from pbook.book.models import Entry

urlpatterns = patterns('',
 (r'^$', 'pbook.book.views.create_entry'),
 (r'^admin/', include('django.contrib.admin.urls')),
)

---> templates/book/entry_form.html
{% if form.has_errors %}
Please correct the following error{{ form.error_dict|pluralize
}}:
{% endif %}



Name: {{ form.name }}
{% if form.name.errors %}*** {{ form.name.errors|join:", " }}{%
endif %}


Last: {{ form.last }}
{% if form.last.errors %}*** {{ form.last.errors|join:", " }}{%
endif %}


Phone nr: {{ form.nr }}
{% if form.nr.errors %}*** {{ form.nr.errors|join:", " }}{% endif
%}


Mobile nr: {{ form.nr_mobile }}
{% if form.nr_mobile.errors %}*** {{ form.nr_mobile.errors|join:",
" }}{% endif %}




Thanks,
Robert


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



Re: Can I use HAVING clause on a query?

2006-07-14 Thread Russell Keith-Magee
On 7/14/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
Hello there,In plain SQL I'd do something with a HAVING clause, effectivelyfiltering the COUNT(*) on the cars.Has anybody done sth like this before? Any clues?Django doesn't currently have any specific support for aggregate clauses; However, it can be done - in a slightly hackish way.
If you add your 'HAVING' clause to a 'where' block in a call to extra(), the SQL that is generated will have the HAVING at the end of your query. If you want to see a preview of the SQL that will be executed, you can run _get_sql_clause() on any QuerySet. If
Articles.objects.filter(...).extra(where=[' HAVING ...'])is your query, Articles.objects.filter(...).extra(where=[' HAVING ...'])._get_sql_clause()will give you an almost-sql look at what will be passed to the databse (without actually executing it)

This is undocumented, and more than a little hackish, but it should work. Long term, I hope to get around to getting aggregates into the query system properly, but that is for another day.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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---


Re: Extending pluralize?

2006-07-14 Thread Russell Keith-Magee
On 7/14/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
I'm currently developing my first app on Django, and it happens to bein Slovenia, land in which the beautiful Slovenian language is spoken.In this language, the rules of pluralization go very crazy, as the
following example (for the word for 'dolphin') shows:0 delfinov1 delfin2 delfina3 delfini3 delfini5 delfinovSo, as you can see, the template tag pluralize falls a little short,when it faces ancient, little crazy Slavic languages such as this :-)
How would a newbie to both Python and Django such as me be able toextend pluralize? Has anyone already faced this?I recently added a bunch of changes to pluralize (changeset 3272) that allow for different extensions for singular and plural (
e.g., 1 cherry, n cherries, from cherr{{ num_cherries|pluralize:"y,ies" }}).This should be fairly easy to extend to a 1,2,3,4,... case; in your dolphin case, something like delfin{{ num_delfinov|pluralize:",a,i,ov"}}
(excuse my Slovenian if I've messed up your example :-)I would have little hesitation adding this change if you were to make a patch for it; it's simple to explain, doesn't hurt the existing English use cases, and covers a little more pluralization ground. Make sure the patch has test cases and some documentation and it should get committed fairly quickly. 
As for process; open an enhancement ticket asking for Slovenian pluralization support, and add a patch. Details here: http://www.djangoproject.com/documentation/contributing/
Russ Magee %-)

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


Can I use HAVING clause on a query?

2006-07-14 Thread Carlos Yoder

Hello there,

Now I'm trying to do a simple thing, and I can't get around to it. I
have a list of car objects that can be filtered by Model and FuelType
(usign standard  controls).

Since the list of models is huge, I want to make it smart in two ways:

1. Display the number of existing cars between brackets, next to the
Model name (did it already)
2. Limit the Model choices to those which have 1+ cars, so that the
filters are tighter (and the code for the s smaller!)

In plain SQL I'd do something with a HAVING clause, effectively
filtering the COUNT(*) on the cars.

Has anybody done sth like this before? Any clues?

Best regards,




-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: Extending pluralize?

2006-07-14 Thread Carlos Yoder

>> How would a newbie to both Python and Django such as me be able to
>> extend pluralize? Has anyone already faced this?
>
> Being Russian, a lot! Russian has 3 basic forms of pluralizing nouns
> with many variants of these forms for different declinations. So to
> solve this problem universally you have to have a not-so-small language
> dictionary for every different case. I don't know if such things exist
> and it's actually my dream project to make one (for Russian).

That makes two of us!

> As for now I tend to have a template tag working like this
[snip] [snip] [snip]
> And then adding new words that I need to form as necessary.

Interesting... it was kind as I though it'd be. With all my newbie
questions being answered as I thought they would, Django is becoming a
much warmer place :-)

Spasiva! =)

-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: Extending pluralize?

2006-07-14 Thread Ivan Sagalaev

Carlos Yoder wrote:
> How would a newbie to both Python and Django such as me be able to
> extend pluralize? Has anyone already faced this?

Being Russian, a lot! Russian has 3 basic forms of pluralizing nouns 
with many variants of these forms for different declinations. So to 
solve this problem universally you have to have a not-so-small language 
dictionary for every different case. I don't know if such things exist 
and it's actually my dream project to make one (for Russian).

As for now I tend to have a template tag working like this

   {% quantity object.all.count ÏÂßÅËÔ %}

where 3rd parameter is a noun in nominative singular form (most basic). 
Then the tag does this:

 if value.endswith(u'ÉÑ'):
   if quantity in [11, 12, 13, 14]:
 value = value[:-2] + u'ÉÊ'
   elif quantity % 10 == 1:
 value = value[:-2] + u'ÉÑ'
   elif quantity % 10 in [2, 3, 4]:
 value = value[:-2] + u'ÉÉ'
   else:
 value = value[:-2] + u'ÉÊ'
 elif value.endswith(u'...'):
   ...

And then adding new words that I need to form as necessary.

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



Extending pluralize?

2006-07-14 Thread Carlos Yoder

Hello there,

I'm currently developing my first app on Django, and it happens to be
in Slovenia, land in which the beautiful Slovenian language is spoken.

In this language, the rules of pluralization go very crazy, as the
following example (for the word for 'dolphin') shows:

0 delfinov
1 delfin
2 delfina
3 delfini
3 delfini
5 delfinov

So, as you can see, the template tag pluralize falls a little short,
when it faces ancient, little crazy Slavic languages such as this :-)

How would a newbie to both Python and Django such as me be able to
extend pluralize? Has anyone already faced this?

Best regards and thanks in advance,

-- 
Carlos Yoder
http://carlitosyoder.blogspot.com

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



Re: Please fix my ugly code

2006-07-14 Thread Carlos Yoder

Jorge, muchas gracias!

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

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

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

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