Re: ValidationErrors

2006-06-30 Thread Max Battcher

Todd O'Bryan wrote:
> How do people handle validation errors in a standard way? Surely, the
> 
> {% if form.name.errors %}*** {{ form.name.errors|join:", " }}{% endif %}
> 
> repeated over and over again (with field changes) in the documentation
> example cries out for some better way.
> 
> I was thinking of creating a custom tag, but thought I'd ask to make
> sure I wasn't missing something.

{{ form.name.html_error_list }}, wraps it in a 

-- 
--Max Battcher--
http://www.worldmaker.net/
"I'm gonna win, trust in me / I have come to save this world / and in 
the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track)

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

2006-06-30 Thread Jeremy Dunck

On 6/30/06, mamcxyz <[EMAIL PROTECTED]> wrote:
> In where I need to look to see exactly what is evaluated?


django.core.urlresolvers.RegexURLPattern.resolve

...and from the look of that test, no, you don't understand the encoding issue.

it'd be more like:

re.match(r'[a-zA-Z0-9\%\\\xED-\xEF]', 'Medill\xEDn')
...In other words, your character class should include every character
you'll accept.

Here's an excellent tutorial:
http://www.regular-expressions.info/unicode.html

Unfortunately, googling for "unicode regex url" turned up nothing
useful.  I think a django-provided character class for "any char other
than URL-specials like ?#&/" would be good.

On that tack, perhaps [^?#&=/] (or similar) is what you want.  ;-)

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



ValidationErrors

2006-06-30 Thread Todd O'Bryan

How do people handle validation errors in a standard way? Surely, the

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

repeated over and over again (with field changes) in the documentation
example cries out for some better way.

I was thinking of creating a custom tag, but thought I'd ask to make
sure I wasn't missing something.

Todd

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

2006-06-30 Thread Paul Sargent
On 7/1/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
If you could make that change (change "User" to "user", for example) andsee if the problem reoccurs, that would be great.I think that did it. I'd changed it a while back, but I'd also commented out the field that was giving me problems so I hadn't noticed I'd fixed it.
Thanks. I think at 2:20am it's time to go to sleep, and stop making stupid errors.Paul

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

2006-06-30 Thread Jeremy Dunck
On 6/30/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
So, unless I'm a moron (in the Pilgrim sense[1]), in general, you can expect to get UTF-8 URLs.
Sorry, let me clarify:In general, you should expect to get -unicode- URLs from the server, and this explanation will hopefully serve to reduce confusion over URL-escaping and how to match non-ASCII URL dispatch.   
... And goddamn this unicode stuff makes my brain hurt.It's been like a perfect storm for me lately.  I've gone years without caring about unicode, but reading about it just cuz I like to know stuff.In the past week, I've dealt with emails getting cut off, files getting munged, form submissions failing, and regexs not matching, all due to encoding issues (and almost all in conjunction w/ django).  So yeah, I'm +1 on unicodification, because yow, it's already an issue and the least we could do is be explicit about it.  :)


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


Re: Help with regex for URL with spanish characters

2006-06-30 Thread Jeremy Dunck
On 6/30/06, mamcxyz <[EMAIL PROTECTED]> wrote:> > I'm building a site for restaurants, like a yellow pages.> > I wanna provide listing based in state / city /zones. Some citys in
> Colombia are "Medellín", "Santa Marta" and so on...> > So, the url are transformed to Medell%C3%ADn and Santa%20Marta.> > Easy, I think... in the urls:> 
> (r'^(?P[a-zA-Z0-9%\-]+)/(?P[a-zA-Z0-9%\-]+)/$',> 'restaurant.views.byCity' ),> > to match depto and city.> > I test this in the interactive mode:> 
> re.match(r'^(?P[a-zA-Z0-9%\-]+)/(?P[a-zA-Z0-9%\-]+)/$',r'a/Bogot%C3%A1/').groups()> >>('a', 'Bogot%C3%A1')> > However, the django site not can found this...> 
> Page not found (404)> > I don't find another regular _expression_ that work fineThe %C3%AD is just escaping for the URL, and isn't actually a character you'll see from the web server.
The unicode character í is U+00ED.  A matching regex would be:Medell\xEDnHow did I get from C3AD to 00ED?I guessed that the URL is escaped UTF-8.Medellín
Medell\xEDn
unicode1110 1101 
ED url (escaped utf-8)
range pattern:
110x  10xx  The unicode bits:
   11   10  1101

left zero-pad the bits:
1100 0011 1010  1101C3A D

Yep, it's escaped UTF-8 since the escaped chars match the bit pattern for UTF-8-encoded U+00ED.

So, unless I'm a moron (in the Pilgrim sense[1]), in general, you can expect to get UTF-8 URLs.

See UTF-8 on Wikipedia if you're totally confused.  :)

[1]http://diveintomark.org/archives/2004/08/16/specs

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


Help with regex for URL with spanish characters

2006-06-30 Thread mamcxyz

I'm building a site for restaurants, like a yellow pages.

I wanna provide listing based in state / city /zones. Some citys in
Colombia are "Medellín", "Santa Marta" and so on...

So, the url are transformed to Medell%C3%ADn and Santa%20Marta.

Easy, I think... in the urls:

(r'^(?P[a-zA-Z0-9%\-]+)/(?P[a-zA-Z0-9%\-]+)/$',
'restaurant.views.byCity' ),

to match depto and city.

I test this in the interactive mode:

re.match(r'^(?P[a-zA-Z0-9%\-]+)/(?P[a-zA-Z0-9%\-]+)/$',r'a/Bogot%C3%A1/').groups()
>>('a', 'Bogot%C3%A1')

However, the django site not can found this...

Page not found (404)

I don't find another regular expression that work fine

Any idea?


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

2006-06-30 Thread Jeremy Dunck

On 6/30/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> On 6/30/06, Paul <[EMAIL PROTECTED]> wrote:
> > The string I'm assigning to the field is a unicode string. Django is
> > trying to do a .encode('ascii') on it and failing. Understandable
> > really
>
> Are you sure it's the unicode type, and not just a byte string?

Sorry, just looked at the traceback.  :-/

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

2006-06-30 Thread Jeremy Dunck

On 6/30/06, Paul <[EMAIL PROTECTED]> wrote:
> The string I'm assigning to the field is a unicode string. Django is
> trying to do a .encode('ascii') on it and failing. Understandable
> really

Are you sure it's the unicode type, and not just a byte string?

> I assume I have to do a .encode('utf-8') on it before I store it. Does
> that tend to be the standard?

It depends how you've set up your DB storage, I think. But whatever
you do, keep your storage encoding consistent.  (You may have some
pain if you already have non-ASCII stuff in the DB.)

I've seen some situations where multiple encodings were stuck into the
same column, and you don't want to go there.

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



hi guys

2006-06-30 Thread spamlicious

whats going on in this topic?


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

2006-06-30 Thread Paul

Ok, I've dug a little more and I realised I'd got the wrong end of the
stick.

The string I'm assigning to the field is a unicode string. Django is
trying to do a .encode('ascii') on it and failing. Understandable
really

I assume I have to do a .encode('utf-8') on it before I store it. Does
that tend to be the standard?


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

2006-06-30 Thread Jay Parlar

On 6/30/06, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 6/30/06, Jay Parlar <[EMAIL PROTECTED]> wrote:
> > That should be:
> >
> > context_instance=RequestContext(request))
>
> Heh. Not sure how I got that wrong, considering I had it right in the
> blog entry I wrote about it...
>

We can just pretend it never happened. Don't worry, your rep on
django-users is safe :)

Jay P.

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

2006-06-30 Thread James Bennett

On 6/30/06, Jay Parlar <[EMAIL PROTECTED]> wrote:
> That should be:
>
> context_instance=RequestContext(request))

Heh. Not sure how I got that wrong, considering I had it right in the
blog entry I wrote about it...

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

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



Re: django.shortcuts.render_with_request_context() ?

2006-06-30 Thread Todd O'Bryan

On Fri, 2006-06-30 at 16:23 -0400, Jay Parlar wrote:

> > render_to_response already takes a 'context_instance' keyword argument
> > which can be used to specify the Context class to use, so you can just
> > do
> >
> > from django.template import RequestContext
> > return render_to_response('foo.html', {'form': form},
> > context_instance=RequestContext)
> >
> 
> That should be:
> 
> context_instance=RequestContext(request))

Thanks to both of you. I actually saw the context_instance argument and
didn't put two and two together.

Todd

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

2006-06-30 Thread Jay Parlar

On 6/30/06, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 6/30/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > I find that just about all of my HttpResponse objects have a
> > RequestContext inside. How would people feel about adding another
> > function to django.shortcuts parallel to render_to_response?
>
> render_to_response already takes a 'context_instance' keyword argument
> which can be used to specify the Context class to use, so you can just
> do
>
> from django.template import RequestContext
> return render_to_response('foo.html', {'form': form},
> context_instance=RequestContext)
>

That should be:

context_instance=RequestContext(request))

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

2006-06-30 Thread Filipe


Jeremy Dunck wrote:
> Trunk comes with an ado_mssql backend, which works only on Windows.
> pymssql is cross-platform, but not in trunk (yet).
>
> If all you're doing is custom SQL and your server is Windows, then
> yeah, you should be able to use ado_mssql.  But test first, and
> understand that ms sql support (in the sense of community and actual
> functionality) is (sadly) weak for now.

Alright, no problem, I've done a few tests and it seems to be working
good enough for my current needs :) Meanwhile, I'm eagerly waiting for
pymssql support, so that I can run it on a linux box

Cheers,
Filipe


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



Unicode strings through Database API

2006-06-30 Thread Paul

Hi,

I'm in need of a little education. This may be a python issue rather
than a Django one, but is anybody can help I'd appreciate it.

I've written an a little script which gets external data and inserts it
into the database using the Django models. Unfortunately (or
fortunately, depending on your point of view) somebody has put the word
'Résumé' into the data source that I'm using and those accented
charactered are causing an exception when I call the save method on my
object.

The field is declared as a CharField, and the data assigned is a

Traceback (most recent call last):
  File "", line 1, in ?
  File "/Users/pauls/Documents/Web Development/myapp/myscript.py", line
37, in main
e.save()
  File ".../django/db/models/base.py", line 199, in save
','.join(placeholders)), db_values)
  File ".../django/db/backends/util.py", line 19, in execute
self.db.queries.append({
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
991: ordinal not in range(128)

I understand that it's having problems because the string is identified
as an ASCII string and that character is beyond that, but how would I
identify this string as (probably) ISO8859-1?

Paul


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

2006-06-30 Thread James Bennett

On 6/30/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> I find that just about all of my HttpResponse objects have a
> RequestContext inside. How would people feel about adding another
> function to django.shortcuts parallel to render_to_response?

render_to_response already takes a 'context_instance' keyword argument
which can be used to specify the Context class to use, so you can just
do

from django.template import RequestContext
return render_to_response('foo.html', {'form': form},
context_instance=RequestContext)


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

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



django.shortcuts.render_with_request_context() ?

2006-06-30 Thread Todd O'Bryan

I find that just about all of my HttpResponse objects have a
RequestContext inside. How would people feel about adding another
function to django.shortcuts parallel to render_to_response?

Instead of 

t = loader.get_template('foo.html')
return HttpResponse(t.render(RequestContext(request, {'form': form})))

You'd have

return render_with_request_context('foo.html', request, {'form': form})

It ends up not saving that many keystrokes, but the constructors in
constructors in constructors idiom seems more cumbersome.

Thoughts?
Todd

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

2006-06-30 Thread Rob Hudson

I have a time tracking tool I wrote in PHP a long time ago.  It's not
perfect but it works.  Now that I have a couple Django sites under my
belt I've considered using it for rewriting it.  So if you're
interested in pushing this along I'd be willing to contribute.

My system is basically this one with my own added features on top and
an invoice creator:
http://www.zend.com/zend/tut/tutorial-delin.php

For PDF generation I cheat and use Firefox to print to a file to get a
.ps file, the use the ps2pdf tool on Linux and archive those off
manually.

But maybe that article will give you a few ideas but it sounds like
your ideas are already beyond the article.  The system presented is
pretty basic.


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

2006-06-30 Thread Jeremy Dunck

On 6/30/06, Filipe <[EMAIL PROTECTED]> wrote:
> I've seen references to both pymssql and ado_mssql being bundled with
> Django. Is this already implemented in the current trunk? If so, is it
> enough to change the "DATABASE_ENGINE" setting to something like
> "pymssql"? :)

Trunk comes with an ado_mssql backend, which works only on Windows.
pymssql is cross-platform, but not in trunk (yet).

If all you're doing is custom SQL and your server is Windows, then
yeah, you should be able to use ado_mssql.  But test first, and
understand that ms sql support (in the sense of community and actual
functionality) is (sadly) weak for 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
-~--~~~~--~~--~--~---



Re: MS SqlServer in Django

2006-06-30 Thread Filipe

>From the posts I've seen it seems MSSqlServer isn't yet fully supported
by Django's ORM, but that wouldn't be a problem in this case because I
just need to issue some custom sql queries to a SqlServer DB.

I've seen references to both pymssql and ado_mssql being bundled with
Django. Is this already implemented in the current trunk? If so, is it
enough to change the "DATABASE_ENGINE" setting to something like
"pymssql"? :)

cheers,
Filipe


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



ManyToMany field on User object

2006-06-30 Thread Paul

Hi all,

I'm trying to write a model to extend the standard Django user model,
which will add (among other things) the ability to have a list of users
recorded as your friends (like Flickr, or Digg).

The model looks like this (stripped down to just the relevant fields)

--
from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
"""Extra fields to add to the User Model"""

User   = models.OneToOneField(User)
Friends= models.ManyToManyField(User)

--

When I add the second line I get this trace-back...

--
Dr-Stupid: pauls$ ./manage.py sql myapp
Traceback (most recent call last):
  File "./manage.py", line 11, in ?
execute_manager(settings)
  File ".../django/core/management.py", line 1297, in execute_manager
execute_from_command_line(action_mapping, argv)
  File ".../django/core/management.py", line 1255, in
execute_from_command_line
mod_list = [models.get_app(app_label) for app_label in args[1:]]
  File ".../django/db/models/loading.py", line 40, in get_app
mod = load_app(app_name)
  File ".../django/db/models/loading.py", line 51, in load_app
mod = __import__(app_name, '', '', ['models'])
  File "/Users/pauls/mysite/myapp/models.py", line 119, in ?
class UserProfile(models.Model):
  File ".../django/db/models/base.py", line 49, in __new__
new_class.add_to_class(obj_name, obj)
  File ".../django/db/models/base.py", line 131, in add_to_class
value.contribute_to_class(cls, name)
  File ".../django/db/models/fields/related.py", line 662, in
contribute_to_class
super(ManyToManyField, self).contribute_to_class(cls, name)
  File ".../django/db/models/fields/related.py", line 69, in
contribute_to_class
self.do_related_class(other, cls)
  File ".../django/db/models/fields/related.py", line 79, in
do_related_class
self.contribute_to_related_class(other, related)
  File ".../django/db/models/fields/related.py", line 672, in
contribute_to_related_class
if related.model != related.parent_model or not
self.rel.symmetrical:
  File ".../django/db/models/fields/__init__.py", line 97, in __cmp__
return cmp(self.creation_counter, other.creation_counter)
AttributeError: type object 'UserProfile' has no attribute
'creation_counter'
--

(Sorry if that wraps at the wrong place, Google Groups posting window
wraps things)

Any ideas why this is causing a problem? Has anybody else tried this
type of structure?

Thanks

Paul


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Almost there: A little help in how template dirs under Linux

2006-06-30 Thread mamcxyz

I know... but currently I'm looking how secure the things...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Limiting 'displayed' choices on a field (esp. in admin)

2006-06-30 Thread [EMAIL PROTECTED]

I needed the same thing and adapted the code so that it changes the
text as well as the id field when you pick the related objects, it
helps the user see what actually happens. The text used is the str() of
the related object.

I posted the change to the developers list
(http://groups.google.com/group/django-developers/browse_frm/thread/a1288dc637813847)
but I haven't gotten any replies yet. I think this is a very simple
improvement to the interface.

I also experimented with Ajax, using the solution described here:
http://code.djangoproject.com/wiki/AJAXWidgetComboBox and it worked
quite well. It's easy to customize it so that it uses a like search
instead of the startswith search.

But in the end I kinda prefer the non-ajax approach.

But this is really something they should fix out of the box.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Limiting 'displayed' choices on a field (esp. in admin)

2006-06-30 Thread [EMAIL PROTECTED]

This seems to be closest to what we need; thanks.

Yup, I figured selecting 11k rows was not going to be 'optimisable',
which is why I was looking for a way to reduce what was actually
selected.

Now to see if i can customise the presentation of raw_id_admin.

Thanks.


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



Re: One-One relationship

2006-06-30 Thread ama55

Thanks Bryan:
i will try to do that.
and i will be glad if i u can post ur app


thanks.


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



Re: Problem upgrading from 0.95 build 3085 to 3233

2006-06-30 Thread Frankie Robertson

Svn tries do patch your project with loads of diffs at once, this
usually work, but can sometimes fail horribly. Try deleting the
django_src directory then checking it out from scratch.

Frankie

On 29/06/06, olive <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> there is no problem using the database in place.
> The problem occures when I try to create the database from scratch:
>
> mysql -uroot -p%passwd% -e"drop database %database%"
> mysql -uroot -p%passwd% -e"create database %database%"
>
> python manage.py syncdb
>
> Creating table auth_message
> Creating table auth_group
> Creating table auth_user
> Creating table auth_permission
> Creating many-to-many tables for Group model
> Creating many-to-many tables for User model
> Creating table django_content_type
> Creating table django_session
> Creating table django_site
> Creating table django_admin_log
> Creating table application_docchunk
> Creating table application_screenshot
> Creating table application_proglanguage
> Creating table application_application
> Traceback (most recent call last):
>  File "manage.py", line 11, in ?
>execute_manager(settings)
>  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
> line 1297, in execute_manager
>execute_from_command_line(action_mapping, argv)
>  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
> line 1221, in execute_from_command_line
>action_mapping[action]()
>  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
> line 473, in syncdb
>cursor.execute(statement)
>  File
> "C:\Applications\wiposoft\dev\python\django\db\backends\util.py", line
> 12, in execute
>return self.cursor.execute(sql, params)
>  File
> "C:\Applications\wiposoft\dev\python\django\db\backends\mysql\base.py",
> line 35, in execute
>return self.cursor.execute(sql, params)
>  File "C:\soft\python24\Lib\site-packages\MySQLdb\cursors.py", line
> 137, in execute
>self.errorhandler(self, exc, value)
>  File "C:\soft\python24\Lib\site-packages\MySQLdb\connections.py",
> line 33, in defaulterrorhandler
>raise errorclass, errorvalue
> _mysql_exceptions.OperationalError: (1005, "Can't create table
> '.\\wiposoftdev\\#sql-84_3e9.frm' (errno: 121)")
>
>
> Here is my mode:
>
> from django.db import models
> from django.contrib.auth.models import User
> from datetime import datetime
>
> class Contact(models.Model):
>user= models.ForeignKey(User)
>name= models.CharField(_('name'),maxlength=200,unique=True)
>
>def __str__(self):
>return self.name
>
>class Meta:
>verbose_name = _('author')
>verbose_name_plural = _('authors')
>ordering = ['name']
>
>class Admin:
>list_display = ('name',)
>search_fields = ['name']
>
> class ProgLanguage(models.Model):
>name= models.CharField(_('name'),maxlength=200,unique=True)
>
>def __str__(self):
>return self.name
>
>class Meta:
>verbose_name = _('programming language')
>verbose_name_plural = _('programming languages')
>ordering = ['name']
>
>class Admin:
>list_display = ('name',)
>
> class OperatingSystem(models.Model):
>name= models.CharField(_('name'),maxlength=200,unique=True)
>
>def __str__(self):
>return self.name
>
>class Meta:
>ordering = ['name']
>
>class Admin:
>list_display = ('name',)
>search_fields = ['name']
>
> class Software(models.Model):
>name= models.CharField(_('name'),maxlength=200,unique=True)
>xp_compat   = models.BooleanField(_('MS Windows XP
> compatible'),default=False)
>modified_on = models.DateTimeField(editable=False)
>short_desc  = models.TextField(_('short
> description'),blank=True,null=True)
>comments= models.TextField(_('comment'),blank=True,null=True)
>os  =
> models.ManyToManyField(OperatingSystem,verbose_name=_('operating
> system'),filter_interface=models.HORIZONTAL,blank=True,null=True)
>prgm_lang   =
> models.ManyToManyField(ProgLanguage,verbose_name=_('programming
> language'),filter_interface=models.HORIZONTAL,blank=True,null=True)
>
>def __str__(self):
>return self.name
>
>def save(self):
>self.modified_on = datetime.now()
>super(Software, self).save() # Call the "real" save() method
>
>def short_description(self):
> return self.short_desc
>short_description.allow_tags = True
>
>class Meta:
>verbose_name = _('third party software')
>verbose_name_plural = _('third party software')
>ordering = ['name']
>
>class Admin:
>list_display = ('name','short_description','modified_on')
>search_fields = ['name','short_desc']
>list_filter = ['modified_on','xp_compat','os','prgm_lang']
>fields = (
>  (None, {'fields': ('name','xp_compat')}),
>  (_('Short description and comments'), {
>   #'classes': 

Re: Limiting 'displayed' choices on a field (esp. in admin)

2006-06-30 Thread Jacob Kaplan-Moss

What you're looking for is the ``raw_id_admin`` option; fetching 11k  
rows from the database is going to be slow no matter how you cut it.

``raw_id_admin`` is documented at http://www.djangoproject.com/ 
documentation/model_api/#many-to-one-relationships.

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: Django Boot Camp

2006-06-30 Thread Jeremy Dunck

On 6/29/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> Zeldman very politely suggests I'm nuts.  :)

...but I'm too dumb to let it go.  One more round:



-- Forwarded message --
From: Jeffrey Zeldman <[EMAIL PROTECTED]>
Date: Jun 30, 2006 8:14 AM
Subject: Re: Contact from aneventapart.com
To: Jeremy Dunck <[EMAIL PROTECTED]>


At 2:30 PM -0500 6/29/06, Jeremy Dunck wrote:
>On 6/29/06, Jeffrey Zeldman <[EMAIL PROTECTED]> wrote:
>> There are at least 12 other problems with the idea, but my
>>main feeling is, we are very flattered by your question, but there
>>doesn't seem to be any realistic way to do what you're suggesting.
>>(But thanks for thinking of us, and continued good luck with Django!)
>
>That has to be the nicest brush-off I've ever received.
>
>Obviously AEA is a top-notch conference and the audiences are not
>identical, but I think the walls we build between coding and designing
>are harmful to our work.

I agree! ALA has always encouraged its readers to peer out
over the cubicle and talk to their colleagues in different web
disciplines. And AEA is somewhat unique in emphasizing design, code,
and content as parts of a holistic "design" approach.

And designer/coders certainly need to work with content
management sytems, so I retract my "not sure it's the same audience"
comment.

You are right.

But the problem of not being able to make space available
(because we don't own the space) remains. Then, too, if we were to
expand AEA to deliberately include CMS systems at future events, we'd
probably also need to include a couple of additional open-source
systems (lest the event be perceived as a commercial or an
endorsement). Make sense?



>Machines of loving grace should be lovingly made to serve.
>
>In any case, I'm flattered to receive a response given your busy
>schedule.  Sorry the idea does not seem workable.

As mentioned, perhaps at a future event (with more than one
open-source CMS), it could be a very good idea!

We will keep it in mind.

Thanks!

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



Limiting 'displayed' choices on a field (esp. in admin)

2006-06-30 Thread [EMAIL PROTECTED]

I've been poking people on freenode#django about this, but nobody seems
to have a good feel for the stuff i'm looking for.

For the record, I am working off of trunk (post-mr), keeping it
regularly up to date.

The crux of the problem is that we're using the Admin interface to
administer a large number of companies and people.

At the center of this is a many-to-many table containing addresses.
Both Person and Company have Many-to-Many against this, in some cases
as People and Companies (employer/employee) share an address.  Some
people or companies have multiple addresses as well.

The address table contains 11000 rows, person is 12000, and  company is
6000.  There were two major issues that our users complained about when
we first pushed the Admin at them:

1) When they see the Many-to-Many field on the person/company screens
for Addresses; there are 12000 addresses on there: This doesn't work
for them, adn is hard to see what addresses belong to people/manage
existing.  They weren't thrilled with the HORIZONTAL filter (which I
thought was the 'right' solution), so we wrote a custom template tag
that only displays the selected/linked addresses.  We're working on a
custom save method that finds duplicate 'new' entries and quietly
replaces with an existing if there's a dup.

2) It's SLOW.  I've tried this on a number of machines, including my
new 2ghz dual core/2gig RAM Macbook, and loading the company or person
screen takes 6-10 seconds.  I sprinkled the Django codebase with
debug/timing code and this is all when addresses is selected against,
and the custom filter is run.  Even if we are only displaying the
selected addresses, it's sitll finding ALL the addresses and this is
crawling.

My ideal solution (I'm considering dropping admin and whipping
something a bit more usable together, but I hate the idea) would be,
for now, to do a select that ONLY selects the addresses currently
associated with the person or company.  I can deal with the 'dup'
addresses issue later, as for now the 6-10 second load per screen has
made the page unusable.

I haven't been able to figure out however, without changing the core
Django code (Which I'm trying to avoid doing) how to implement this.
My understanding of the filter syntax is admittedly still rudimentary,
but it doesn't look like limit_choices_to can do what I need.  I have
written a custom manager method that does it, and very quickly, but I
don't know how to tell the admin to use it.

I do see stubs in models.fields.related for 'lookup_overrides',
however, nothing seems to hook into this attribute as of yet.

Any thoughts, if you've survived my long rambling inquiry, into how to
solve my problem?  Is the admin simply not capable of handling this
task?


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

2006-06-30 Thread Jeroen Ruigrok van der Werven

On 6/30/06, Craig Marshall <[EMAIL PROTECTED]> wrote:
> I can
> import django at the python prompt, but running syncdb gives me the
> ImportError.

What does python -v manage.py yield? 't Will be a long output.
Probably best to put it up on a URL if you can.

-- 
Jeroen Ruigrok van der Werven

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

2006-06-30 Thread spako

when i do:

> manage.py syncdb

no indexes are created, i've printed out all the sql statements and the
SQL for the indexes were infact missing. to check if django at least
knows about them i did:

> manage.py sqlall 

and the SQL for the indexes were printed.

i've found the ticket http://code.djangoproject.com/ticket/1828 that
seems to be about this

was wondering if i missed a step somewhere though, when i do syncdb i
don't do anything else (with manage.py) before that. also if i am doing
syndb correctly what is the procedure? should i update the comment on
the ticket.

this is probably not critical because the SQL for indexes can be run
manually. BUT it is probably very important to actully do that step
escpecially for production as this can slow down large site.


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

2006-06-30 Thread Bryan Chow

You can import User from django.contrib.auth.models

The save method of the Person class needs to create a User object
programatically, e.g. User.objects.create_user(username, email,
password)

Then you can call super(Person, self).save()

This should give you enough to figure out the rest, but if not I have a
working app that's very similar to what you're trying to do. I'll see
if I can clean it up and post it as an 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Secret Password + validating two passwords

2006-06-30 Thread Frankie Robertson

Making passwords masked is as simple as changing this in the html:

to this:


What do you mean about validatating two passwords? Try and be more specific.

On 30/06/06, MissLibra <[EMAIL PROTECTED]> wrote:
>
> Hello, I am trying to make the password appearing as stars, in other
> words a secret password but didn't know how. Also I want to validate
> two passwords. Can anyone help 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
-~--~~~~--~~--~--~---



Re: Almost there: A little help in how template dirs under Linux

2006-06-30 Thread David Reynolds


On 29 Jun 2006, at 5:03 am, mamcxyz wrote:

>
> I forgot to add this details:
>
> django is installed in /root/django_src
>
> The project is in
>
> /root/vulcano/jhonWeb/

This is a bit off-topic, but you shouldn't really run things as root,  
if at all possible.

Cheers,

David

-- 
David Reynolds
[EMAIL PROTECTED]




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



unique=True, one to one relationship

2006-06-30 Thread bernadet

1- if I combine related objects in the same page (by using the
edit_inline attribute), and add to one of the fields the unique
atrribute (unique=True), when trying to save the page, i got the
following exception:

Exception Type: TypeError
Exception Value: Cannot resolve keyword 'username' into field.

please note that the username is the name of the field that has the
unique attribute.

2- if I use the OneToOneField relationship between 2 classes and i
combined the 2 models in the same page i got an exception when doing
the following process:

Go to the page, fill the fields, save.
then return to the page in order to change some info fields, and try to
save, an exeption appears:

Exeption Type: Key Error
Exeption value:'person'

please note that am using person and user classes and user has the
field  OneToOneField.

3- if i separate user and person from the same page, but user always
has the OneToOneField. if i try to save a user without selecting a
person, an exeption appears:
OutOfRangevalue adjusted for column  person_id.
note that if i use ForeignKey relation, and i repeat the same process,
an error on the page appears not an exception.

hope that i was clear with my issues.


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



Secret Password + validating two passwords

2006-06-30 Thread MissLibra

Hello, I am trying to make the password appearing as stars, in other
words a secret password but didn't know how. Also I want to validate
two passwords. Can anyone help 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
-~--~~~~--~~--~--~---



Re: ImportError: No module named django

2006-06-30 Thread Craig Marshall

> I'd advise you to drop the symlink and use the PYTHONPATH variable,
> but that's just my hunch based on no empirical data.

Okay, I just deleted /usr/lib/python2.4/site-packages/django (which
was the symlink), and added to the PYTHONPATH environment variable the
actual django directory, and if failed to import django at the python
prompt, so I changed the env-var to point to the parent of the django
directory, and I now have the same problem I had to start with. I can
import django at the python prompt, but running syncdb gives me the
ImportError.

Craig

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

2006-06-30 Thread Craig Marshall

> This is very strangely worded. You installed Ubuntu completely on top
> of Debian and then installed Django from SVN again? You're not being
> explicit enough.

Sorry for being unclear. I had debian sarge installed, and I installed
django from svn at that point. Then I wiped my machine entirely,
installed ubuntu, and installed the exact same svn version of django I
previously downloaded (I'm working in a team, and we're trying to use
the same version of django.).

> In your site-packages directory (typically something like
> /usr/local/lib/python24/site-packages), do you have anything
> resembling Django (egg or directory)?

Only the symlink I made called "django" which points to the actual
django dir in my $HOME

I also symlinked /usr/bin/django-admin.py into the
.../site-packages/django/bin/django-admin.py file.

> Jeroen Ruigrok van der Werven

Thanks for your help.

Craig

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

2006-06-30 Thread Jeroen Ruigrok van der Werven

On 6/28/06, Craig Marshall <[EMAIL PROTECTED]> wrote:
> I downloaded the svn version of django a couple of weeks ago, and had
> it working fine within Debian. I installed Ubuntu 6.06 today, and my
> django install has stopped working.

This is very strangely worded. You installed Ubuntu completely on top
of Debian and then installed Django from SVN again? You're not being
explicit enough.

> I can run python interactively and type "import django" and get no
> errors, but when I go into our project directory and run "./manage.py
> syncdb",  I get this error:
>
> ImportError: No module named django

In your site-packages directory (typically something like
/usr/local/lib/python24/site-packages), do you have anything
resembling Django (egg or directory)?

-- 
Jeroen Ruigrok van der Werven

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

2006-06-30 Thread Craig Marshall

> I downloaded the svn version of django a couple of weeks ago, and had
> it working fine within Debian. I installed Ubuntu 6.06 today, and my
> django install has stopped working.
>
> I can run python interactively and type "import django" and get no
> errors, but when I go into our project directory and run "./manage.py
> syncdb",  I get this error:
>
> ImportError: No module named django

Is this the best place to ask this kind of question, or would I be
better off trying irc or something else?

Thanks,
Craig

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

2006-06-30 Thread oggie rob

> First i'd like to know if anyone has already done this kind of thing?

I have a pretty basic time tracking and invoicing feature in my
database. As people have pointed out, the biggest issue is printing
consistently. However, you can avoid this headache (yes, it is going to
be a headache!) if you yourself are doing all the printing, or have
control over the machine(s) that are printing invoices. I use Firefox
and make sure all my employees use Firefox, for the time being.
Eventually the PDF output is a must but I am delaying that as much as
possible.

As for the time tracking, probably the most useful thing I found was
the inline feature of the admin interface. This is a very basic way to
associate something of variable length (i.e. time) with a single fixed
entity (i.e. project).

You are basically on the right track. Just keep trying and make
improvements when you see the need. Its so simple with Django!

 -rob


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