Re: How to View Raw Generated SQL

2008-09-24 Thread John Allen

The FAQ recipe (when run from a manage.py shell) didn't produce
anything in my application.

I found this which might help:
http://blog.michaeltrier.com/2007/8/11/display-the-sql-django-orm-is-generating

On Sep 25, 5:45 am, Chris <[EMAIL PROTECTED]> wrote:
> I'm trying to debug a usage of callproc, which doesn't return any rows
> when used inside Django. Is there anyway to view the SQL and escaped
> values sent from db cursor? I 
> foundhttp://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra...
> by this doesn't show anything. When they say "just do this", are they
> implying we should run that from a manage.py shell?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Restrict users to their own data

2008-09-24 Thread solomon71

On Sep 11, 11:51 am, Simon Willison <[EMAIL PROTECTED]> wrote:
> On Sep 11, 5:23 pm, Glimps <[EMAIL PROTECTED]> wrote:
>
> >     I would like torestrictusersto thedatathey can see/modify/
> > delete on a table. I have a Reservation table that holds reservations
> > for multiple banners of Restaurant chain. I don't want the user from
> > franchiseX to be able to see/confirm reservations from franchiseY.
>
> > Since all the add/edit/delete is made with the admin interface (Django
> > 1.0) I went and search for something I could override in the
> > ModelAdmin class. No success.
>
> Take another look at ModelAdmin - the methods you want to over-ride
> are queryset(request) which returns the QuerySet used to create the
> "change list" view and has_add_permission(request),
> has_change_permission(request, obj) and has_delete_permission(request,
> obj).
>
> You can over-ride those methods on your ModelAdmin subclass to
> implement your permissions logic. Your code will end up looking
> something like this:
>
> class ReservationAdmin(admin.ModelAdmin):
>     def queryset(self, request):
>         return super(ReservationAdmin, self).filter(user =
> request.user)
>
>     def has_change_permission(self, request, obj=None):
>         if not obj:
>             return False
>         return obj.user == request.user
>
>     def has_delete_permission(self, ...)
>         # similar
>
> Cheers,
>
> Simon

Thank you for pointing this out, very handy.

Can this be taken 1 step further in a add_view or change_view? Say I
have a PhotoAlbum model that a User is associated to via a ForeignKey.
I also have a Photo model that has a ForeignKey to the PhotoAlbum. In
the add_view or change_view, is there a way to only show in the drop
down the PhotoAlbums that belong to the request.user and not show the
full list?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: new user needs some advice setting up a model...

2008-09-24 Thread paul

ah - even easier than i thought it might me.  many thanks for taking
your time to point me in the right direction.  very very much
appreciated!

-p


On Sep 24, 9:40 pm, "Alexander Pugachev"
<[EMAIL PROTECTED]> wrote:
> You can force database to watch after columns to be unique by one or in
> combinations.
> Django admin interface also can watch after this restrictions.
> How to make a model to have few attributes unique together is described
> here:
>  http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together
> So you make job and id to be unique together in shot model.
>
> 2008/9/24 paul <[EMAIL PROTECTED]>
>
>
>
> > hi all,
>
> > i've thrown myself into developing an animation pipeline using
> > django.  i'm new to both python and django - but have in the (distant)
> > past written thousands of lines of c,c++ & perl.  so, please be gentle
> > - but maybe not too gentle with me.
>
> > this first question is quite simple.  i have a job and shot classes
> > (should i call them tables?).  each job has a unique name, and can
> > have many shots attached to it.  a shot must have a unique name within
> > each job.  ie,
>
> > job=bmw, shot=1,2,3,looktest
> > job=goldfrapp, shot=1,2,3,4,5,6,looktest,animtest
>
> > currently, i'm using the admin UI to input job and shot information.
> > my question is what is the best way to make sure that i never have a
> > two shots of the same name per job?  should this logic be inserted
> > into the save method of the shot, or could/should it be inserted
> > elsewhere (ie, within the model itself)?
>
> > sorry for the simplicity of the question - i'm still trying to get to
> > grips with django/pythonific best practice...
>
> > regards to all,
>
> > 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?hl=en
-~--~~~~--~~--~--~---



How to View Raw Generated SQL

2008-09-24 Thread Chris

I'm trying to debug a usage of callproc, which doesn't return any rows
when used inside Django. Is there anyway to view the SQL and escaped
values sent from db cursor? I found
http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running
by this doesn't show anything. When they say "just do this", are they
implying we should run that from a manage.py shell?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A question about spaces and passing variables...

2008-09-24 Thread Brian Neal

On Sep 24, 7:23 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Sep 24, 2008 at 6:37 PM, djandrow <[EMAIL PROTECTED]> wrote:
>
> > So after messing around a for a couple of minutes I discovered the
> > urlencode changes About Me to About%20Me, (if you are using firefox 3
> > or above it will still display "About Me" in the address bar, that
> > confused me for a while).
>
> > But now if i put in:
>
> > url.net/blog/About%20Me/,
>
> > it doesn't match this url pattern:
>
> > ^blog/(?P\w+)/$
>
> > So how can i get this to match the patter?
>
> I think rather you need to make the pattern match all possible values of
> category.  Since you want to take the value from the url and look it up in
> the database, and since you allow spaces in category, your pattern has to
> allow spaces.  (Note that the percent-encoding in the url is automatically
> undone before url mathicng is attempted.  Similarly your view code will get
> the variable passed in with spaces, not '%20' in place of spaces.)  So, if
> your category field can contain any character, then your urlpattern to match
> it should be something like:
>
> ^blog/(?P.+)/$
>
> instead of the \w which disallows spaces (among other characters).
>
> Karen

djandrow, you may also consider using a "slug field" instead of the
category name for your urls if you don't like the url encoding. Many
people do not like spaces in URL's. A slug is a unique key for each
category that is made up of letters, digits, and the dash (-)
character.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin redirecting to wrong URL?

2008-09-24 Thread Graham Dumpleton



On Sep 24, 11:37 pm, Allan <[EMAIL PROTECTED]> wrote:
> Hi Graham,
>
> Thanks for responding.  I'm using Django 1.0, hosted at Webfaction on
> Apache usingmod_python.  What special configuration or hacks would
> you suggest to get admin properly working at a sub URL of this
> configuration?

For mod_python, are you following what documentation at:

  http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

says for Django 1.0 and setting:

  PythonOption django.root /django

This is required for mod_python else Django doesn't know it is mounted
at a sub URL.

Graham

> Allan -- Atlanta
>
> On Sep 23, 8:04 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > On Sep 24, 5:43 am, Allan <[EMAIL PROTECTED]> wrote:
>
> > > My application is working well at mysite.com/django/, and I get
> > > an admin login at mysite.com/django/admin/ -- but when I
> > > enter my credentials, I seem to be redirected to mysite.com/
> > > admin/ (which is a 404 error).  Did I miss an admin config setting
> > > somewhere?
>
> > > A relevant excerpt from urls.py appears below.
>
> > > Allan
>
> > > import os
> > > from django.conf.urls.defaults import *
> > > from django.conf import settings
> > > from django.contrib import admin
>
> > > admin.autodiscover()
>
> > > urlpatterns = patterns('',
>
> > >     (r'^contact/$', 'careers_contact.views.contact'),
> > >     (r'^careers/$', 'careers_contact.views.careers'),
>
> > >     (r'^admin/(.*)', admin.site.root),
> > > )
>
> > How are you hosting Django and what version of Django are you using?
>
> > Depending on how you are hosting Django and what version, you may have
> > to set special configuration or use hacks to allow it to properly host
> > at a sub URL of an Apache installation.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Set booleanfield to True on shell?

2008-09-24 Thread Jorge Romo

Woah it was so obvious!

Thanks a lot Daniel!

On Sep 24, 2:23 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 24, 8:00 pm, Jorge Romo <[EMAIL PROTECTED]> wrote:
>
> > Hello guys, maybe this is a kinda dumb question but i just can't
> > figure it out!
>
> > I have set to False as default for a is_finished field. If something
> > is finished it should turn to True, but i just can't make it happen.
> > Any idea?
>
> > I tried with .objects.update but it updated all my model objects
> > hahaha. I hope you can help me out
>
> > Thanks in advance
>
> myinstance = MyModel.objects.get(pk=1) # or whatever
> myinstance.is_finished = True
> myinstance.save()
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-24 Thread shacker


On Sep 24, 4:34 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:

> If however you have used in Apache configuration the ErrorDocument
> directive for 404 at some point, possibly by enabling multi language
> custom error documents, then when the 404 occurs, rather than
> returning an internally generated generic 404 error response, Apache,
> based on the value of the ErrorDocument directive may trigger a sub
> request to a handler to generate the custom error document.

We had a very similar problem with a wsgi setup on a cPanel machine.
cPanel defines the location of a bunch of Apache error documents
globally for all vhosts - error docs that don't exist in a Django
setup. The solution was to override those settings in the vhost
configuration for the site in question, like this:

ErrorDocument 401 "Authentication Error"
ErrorDocument 403 "Forbidden"

That way 401 and 403 return strings, rather than paths to non-existent
files, and the problem goes away.

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



Re: Multiple instances using mod_python

2008-09-24 Thread Graham Dumpleton

The problem is more fundamental than that and virtual environments
would not help. This is because it relates to which Python sub
interpreter instance is selected and not where modules may be imported
from for a specific sub interpreter instance.

Graham

On Sep 25, 5:12 am, "Álvaro J. Iradier" <[EMAIL PROTECTED]> wrote:
> Take a look at this, it worked for me:
>
> https://devel.airadier.com/default/blog/modpythonvirtualenvironments
>
> Greets.
>
>
>
> On Wed, Sep 24, 2008 at 4:52 PM, Scott Moonen <[EMAIL PROTECTED]> wrote:
> > I'm running a single instance of Apache to serve two IP addresses.  One IP
> > address has specific hostnames assigned in several VirtualHosts, and a
> > Location statement for certain hostnames to be handled by a mod_python
> > instance running a Django application.  The other IP address has a
> > wildcarded ServerAlias, and DNS is setup so that any hostname not
> > specifically assigned to the first IP address is directed to this second IP
> > address.  For this second IP address I have a VirtualHost that also uses a
> > mod_python instance running a different Django application.
>
> > I see on this thread
> > 
> > from last year that there is suspicion that Apache can at times misdirect
> > mod_python requests to the wrong mod_python instance.  And this is what I'm
> > experiencing from time to time.  It's a bit strange, though: 1) normal file
> > content on these same virtual hosts outside of my mod_python 
> > statement seems to load fine, so Apache seems to be confused only when
> > directing requests to mod_python; 2) this is intermittent, as several
> > requests in a row may go to the wrong handler while a subsequent request may
> > go to the proper handler; 3) I have taken care to force a specific ordering
> > in my virtual host definitions, but this has not helped, although I kind of
> > expected that given that the problem is intermittent; and 4) the wildcarded
> > virtual host is in fact the only virtual host on my second IP address, and I
> > have no other VirtualHosts for that IP address, so the fact that Apache
> > seems to be misdirecting the mod_python handler to virtual hosts for an
> > entirely different IP address is pretty disconcerting.
>
> > I'm running Apache 2.2.3, mod_python 3.3.1, and the latest Django SVN.
> > Because filesystem content loads fine, and because this problem is polluting
> > VirtualHosts that don't even share the same IP address, it seems intuitive
> > that the problem must be some weakness in Apache's internal scoping of
> > Location statements to the VirtualHosts that they appear in.
>
> > Is anyone else experiencing this problem?  Is anyone aware of any fixes?
> > Based on my guess that the problem is Apache's internal scoping of Location
> > directives, I'm tempted to switch from mod_python to mod_fastcgi.  But I'd
> > rather stick with the recommended mod_python deployment method if there's a
> > known way of getting things working,
>
> >   -- Scott
>
> > --
> >http://scott.andstuff.org/|http://truthadorned.org/
>
> --
> (:===:)
>  Alvaro J. Iradier Muro - [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A question about spaces and passing variables...

2008-09-24 Thread Karen Tracey
On Wed, Sep 24, 2008 at 6:37 PM, djandrow <[EMAIL PROTECTED]> wrote:

>
> So after messing around a for a couple of minutes I discovered the
> urlencode changes About Me to About%20Me, (if you are using firefox 3
> or above it will still display "About Me" in the address bar, that
> confused me for a while).
>
> But now if i put in:
>
> url.net/blog/About%20Me/,
>
> it doesn't match this url pattern:
>
> ^blog/(?P\w+)/$
>
> So how can i get this to match the patter?
>

I think rather you need to make the pattern match all possible values of
category.  Since you want to take the value from the url and look it up in
the database, and since you allow spaces in category, your pattern has to
allow spaces.  (Note that the percent-encoding in the url is automatically
undone before url mathicng is attempted.  Similarly your view code will get
the variable passed in with spaces, not '%20' in place of spaces.)  So, if
your category field can contain any character, then your urlpattern to match
it should be something like:

^blog/(?P.+)/$

instead of the \w which disallows spaces (among other characters).

Karen

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



Re: python-ldap + Apache causing errors

2008-09-24 Thread Graham Dumpleton



On Sep 25, 12:30 am, Jashugan <[EMAIL PROTECTED]> wrote:
> > The problem is most like because some other Apache module, eg. PHP or
> > mod_auth_ldap, is loading an incompatible version/variant of LDAP
> > client libraries before the Python ldap module does.
>
> > Thus, check what versions of LDAP client libraries Python ldap module
> > is compiled against and then also look at what PHP or other Apache
> > modules are using.
>
> > To really get to the problem, you may need to start up Apache in
> > single process mode and run it in a debugger. For details see:
>
> >http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_C...
>
> This seems a bit daunting, especially if there may be an alternative
> solution. For example if I switched to FCGI, this issue should be
> resolved, since there wouldn't be any conflicts between other Apache
> modules. Am I right in this assumption?

Yes, that assumption is correct. Given that mod_python and mod_fastcgi
can equally be as painful as the other, then no harm in changing. If
using mod_wsgi I would have perhaps suggested persisting with finding
the problem. ;-)

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



Re: Whither Validators?

2008-09-24 Thread Russell Keith-Magee

On Thu, Sep 25, 2008 at 12:30 AM, Rodrigo Culagovski
<[EMAIL PROTECTED]> wrote:
>
> Validators (django.core.validators) seem to have been removed from
> 1.0. What replaces them?

Well... validators weren't ever really there to begin with. There was
some initial stub code, but it wasn't fully integrated into models.

Model validation (Ticket #6845) was on the list of possible v1.0
features, but got bumped from the feature list because the
implementation wasn't quite ready. It's certainly on the list of
features intended for v1.1.

In the meantime, there is form-level validation; you can also override
the save() method to ensure that invalid models aren't saved. It's not
particularly pretty, but a better solution is on the way. If you're
feeling adventurous, you can try out the patch on #6845 and let us
know about any problems you have.

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



Re: Multiple instances using mod_python

2008-09-24 Thread Graham Dumpleton



On Sep 25, 12:52 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> I'm running a single instance of Apache to serve two IP addresses.  One IP
> address has specific hostnames assigned in several VirtualHosts, and a
> Location statement for certain hostnames to be handled by a mod_python
> instance running a Django application.  The other IP address has a
> wildcarded ServerAlias, and DNS is setup so that any hostname not
> specifically assigned to the first IP address is directed to this second IP
> address.  For this second IP address I have a VirtualHost that also uses a
> mod_python instance running a different Django application.
>
> I see on this thread 
> 
> from last year that there is suspicion that Apache can at times misdirect
> mod_python requests to the wrong mod_python instance.  And this is what I'm
> experiencing from time to time.  It's a bit strange, though: 1) normal file
> content on these same virtual hosts outside of my mod_python 
> statement seems to load fine, so Apache seems to be confused only when
> directing requests to mod_python; 2) this is intermittent, as several
> requests in a row may go to the wrong handler while a subsequent request may
> go to the proper handler; 3) I have taken care to force a specific ordering
> in my virtual host definitions, but this has not helped, although I kind of
> expected that given that the problem is intermittent; and 4) the wildcarded
> virtual host is in fact the only virtual host on my second IP address, and I
> have no other VirtualHosts for that IP address, so the fact that Apache
> seems to be misdirecting the mod_python handler to virtual hosts for an
> entirely different IP address is pretty disconcerting.
>
> I'm running Apache 2.2.3, mod_python 3.3.1, and the latest Django SVN.
> Because filesystem content loads fine, and because this problem is polluting
> VirtualHosts that don't even share the same IP address, it seems intuitive
> that the problem must be some weakness in Apache's internal scoping of
> Location statements to the VirtualHosts that they appear in.
>
> Is anyone else experiencing this problem?  Is anyone aware of any fixes?
> Based on my guess that the problem is Apache's internal scoping of Location
> directives, I'm tempted to switch from mod_python to mod_fastcgi.  But I'd
> rather stick with the recommended mod_python deployment method if there's a
> known way of getting things working,

The one time where a concrete reason was found for this occurring for
a specific person, it was found to be the lack of the NameVirtualHost
directive in Apache configuration. Other than that, yes there is some
suspicion of wildcarding in ServerAlias causing a problem for
mod_python in some instances.

The same problem hasn't been seen with mod_wsgi at this point. So, if
stuck try it as someone else suggested.

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



Re: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-24 Thread Graham Dumpleton

On Sep 25, 7:38 am, Ross Dakin <[EMAIL PROTECTED]> wrote:
> Graham,
>
> I am using Apache andmod_wsgi, and I have experienced that issue
> before (500 errors for 404, et al.).
>
> I fixed it with some tinkering, but don't remember how.  Would you
> mind explaining this problem a little?

Consider that you have Django mounted at root and static media at a
sub URL.

If someone tries to access a file in static media directory and it
doesn't exist, then Apache generates a 404 error. In Apache default
configuration, this would result in an internally generated generic
404 error response page being returned to client.

If however you have used in Apache configuration the ErrorDocument
directive for 404 at some point, possibly by enabling multi language
custom error documents, then when the 404 occurs, rather than
returning an internally generated generic 404 error response, Apache,
based on the value of the ErrorDocument directive may trigger a sub
request to a handler to generate the custom error document.

For example, if you had:

  ErrorDocument 404 /404.html

it will trigger a sub request against URL /404.html.

Problem is that you have Django mounted at root and see such a request
gets routed into Django where they most like is now no handler for
that URL. What happens is that Django itself returns a 404 error
response. Apache, seeing the 404 for the sub request thinks something
nasty must have gone wrong as it would expect it to work, and so
returns a generic 500 error response for the original request instead
since it now can't generate a valid error response page for the
original 404.

A quite nasty variation of this is where the ErrorDocument was for a
401 error response in relation to failed Basic authentication. This is
because the client would then never see the 401 response and always
get a 500 error response instead.

This may not explain your situation, but is a problem that can occur
and it isn't really obvious what is happening.

Graham

> Thanks,
> Ross
>
> On Sep 23, 5:08 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > How are you hosting Django? It would help to know if you are using
> > builtin development server or whether you are hosting under Apache
> > using mod_python ormod_wsgi. If under Apache then use of certain
> > Apache configuration settings can cause 500 errors to be returned
> > instead of 404 errors. No point explaining though if not using Apache.
>
> > Graham
>
> > On Sep 24, 2:14 am, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > There are no tracebacks in this instance.  I can see the non-descript
> > > 500 errors appearing in my terminal window.
>
> > > On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > > > On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > > > I'm preparing to deploy my Django app and I noticed that when I change
> > > > > the "DEBUG" setting to False, all references to static files (i.e.,
> > > > > JavaScript, CSS, etc..) result in HTTP 500 errors.
>
> > > > > Any idea what's causing that issue (and how to fix it)?
>
> > > > No. An idea for getting enough information to figure it out, though, is 
> > > > to
> > > > configure things in settings.py (ADMINS, the various EMAIL_HOST,
> > > > EMAIL_HOST_USER, etc. settings) so that you get the tracebacks for these
> > > > errors mailed to you.
>
> > > > Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Test fixture persistent across applications

2008-09-24 Thread Russell Keith-Magee

On Thu, Sep 25, 2008 at 2:13 AM, davenaff <[EMAIL PROTECTED]> wrote:
>
> As it turns out, TestCase only flushes the database before a test.  It
> doesn't flush it after it has finished its tests.

Correct. This is because your test suite can contain standard doctests
and unittests, and these tests don't clean up after themselves
automatically. As a result, the only guaranteed safe approach (in
terms of predictable test behaviour) is to have tests that need a
clean room to do that cleaning at the start of the test.

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



Re: Template tag to split list evenly

2008-09-24 Thread Annie

Hi Mike -

Replying to an older post, under the theory that any answer helps,
even if it comes months later. ;)

In July I posted a template tag that allows you to break a list up
into n number of sublists. The snippet is here: 
http://www.djangosnippets.org/snippets/889/
with more detailed info and examples here:
http://herself.movielady.net/2008/07/16/split-list-to-columns-django-template-tag/

Hope that helps. :)
Annie

On Jun 3, 7:59 am, mike171562 <[EMAIL PROTECTED]> wrote:
> Thanks for your help tim, I had a look at your filter, but I ended up
> using thetemplatetag here:
>
> http://www.djangosnippets.org/snippets/660/
>
> The only problem is it requires you to know the length of your list,
> and the length of mine varies.
>
> {% load splitlist %}
> {% split_listtagsas new_list 30 %}
> {% for x in new_list.0 %}
> {{x.call}}
> {{x.date}}
> {%endfor%}
>
> {% for x in new_list.1 %}
> {{x.call}}
> {{x.date}}
> {%endfor%}
>
> etc. but im trying to iterate through the length of the list something
> like:
>
> length = range(len(tags))
>
> {% load splitlist %}
> {% split_listtagsas new_list 30 %}
> {% for y in length %}
> {% for x in new_list.{{y}} %}
> {{x.calldate}}
> {%endfor%}
> {%endfor%}

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



Re: A question about spaces and passing variables...

2008-09-24 Thread djandrow

So after messing around a for a couple of minutes I discovered the
urlencode changes About Me to About%20Me, (if you are using firefox 3
or above it will still display "About Me" in the address bar, that
confused me for a while).

But now if i put in:

url.net/blog/About%20Me/,

it doesn't match this url pattern:

^blog/(?P\w+)/$

So how can i get this to match the patter?
This is going to be one of those really obvious things, sorry i'm new
to all this stuff.
If someone could help that would be great.

Regards

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



Re: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-24 Thread Ross Dakin

Graham,

I am using Apache and mod_wsgi, and I have experienced that issue
before (500 errors for 404, et al.).

I fixed it with some tinkering, but don't remember how.  Would you
mind explaining this problem a little?

Thanks,
Ross


On Sep 23, 5:08 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> How are you hosting Django? It would help to know if you are using
> builtin development server or whether you are hosting under Apache
> using mod_python or mod_wsgi. If under Apache then use of certain
> Apache configuration settings can cause 500 errors to be returned
> instead of 404 errors. No point explaining though if not using Apache.
>
> Graham
>
> On Sep 24, 2:14 am, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > There are no tracebacks in this instance.  I can see the non-descript
> > 500 errors appearing in my terminal window.
>
> > On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > > On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > > I'm preparing to deploy my Django app and I noticed that when I change
> > > > the "DEBUG" setting to False, all references to static files (i.e.,
> > > > JavaScript, CSS, etc..) result in HTTP 500 errors.
>
> > > > Any idea what's causing that issue (and how to fix it)?
>
> > > No. An idea for getting enough information to figure it out, though, is to
> > > configure things in settings.py (ADMINS, the various EMAIL_HOST,
> > > EMAIL_HOST_USER, etc. settings) so that you get the tracebacks for these
> > > errors mailed to you.
>
> > > Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQL ENUM and SET fields - can Django handle them?

2008-09-24 Thread Karen Tracey
On Wed, Sep 24, 2008 at 3:25 PM, J Cook <[EMAIL PROTECTED]> wrote:

> Karen Tracey wrote:
> > SET as I recall required a little more work.  It's also a CharField, but
> > required some translation from the comma-delimited string value passed
> > to/from the database layer to the Python set type I wanted to use for
> > manipulating the data in my Python code.  If I were writing the code
> > today I'd probably look into creating a custom field
> > (http://docs.djangoproject.com/en/dev/howto/custom-model-fields/) for a
> > set, but back when I had to do this it was not so easy to write custom
> > fields, so I did not go that route (and I have not had to revisit the
> > code, so it stays as originally written despite there now maybe being a
> > better way to do it...if it's not broken I'm not inclined to 'fix' it).
>
> Is there any way you could post an example of what works for you
> with a
> SET field? Pretty please:)
>

I have a model representing a crossword puzzle, one field tracks letters not
used in the puzzle.  On the MySQL side the field is defined as a
"set('A','B', ... ,'Z')".  On the Django side it's a CharField.  To my
Django app code it looks like this:

>>> from crossword.models import Puzzles
>>> puz = Puzzles.objects.get(pk=222)
>>> puz.UnusedLetters
u'J,K,Q,X,Z'

To transform that value to a set I do:

>>> set_of_unused_letters = set(x for x in puz.UnusedLetters.split(','))
>>> set_of_unused_letters
set([u'Q', u'X', u'K', u'J', u'Z'])

To transform the set to a string value acceptable for saving in the
database, I do:

>>> val_to_save = ','.join(x for x in set_of_unused_letters)
>>> val_to_save
u'Q,X,K,J,Z'
>>> puz.UnusedLetters = val_to_save
>>> puz.save()

Karen

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



Re: unexpected keyword argument 'force_insert'

2008-09-24 Thread [EMAIL PROTECTED]

Found it... actually on the user_profile models save()

changing it to
def save(self, *args, **kwargs):
...
   super(SiteUser, self).save(*args, **kwargs)

fixed it.

On Sep 24, 3:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Using django 1.0 and django-registration I'm getting this error:
>
> save() got an unexpected keyword argument 'force_insert'
>
> I've read some docs about adding force_insert as a keyword, but I
> guess I'm not seeing where/how to do that.
>
> Also, I don't really think there's any problem with django-
> registration. I suspect the problem may be related to my
> profile_callback:
>
> def create_site_user(new_user):
>         new_user_profile = SiteUser.objects.create(
>                 user=new_user,
>                 site = Site.objects.get_current()
>         )
>         new_user_profile.save()
>
> I've also tried it with
> new_user_profile.save(force_insert=True) but get the same error.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-recommender 0.2, with content based recs

2008-09-24 Thread bcurtu

meppum,

I will use a K-Means clustering. It's easy to use, and it can be
executed in background and add new users online.

coulix,

Yes, the main problem for these algorithms is the preformance and the
memory consumption. A cloud architecture may be interesting, but I've
never used it.

On 24 sep, 22:27, coulix <[EMAIL PROTECTED]> wrote:
> Very nice, i was expecting something like this to be released soon,
> its such a nice book.
> All the calculation are done on the fly i guess, but it should not bet
> too hard to move this on a cron job or why not send it for calculation
> on EC2 for large data set.
>
> Good work !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I test my api between two servers running django

2008-09-24 Thread Alexander Pugachev
crazy russian

2008/9/23 Vitaliy <[EMAIL PROTECTED]>

>
> >so they both created test db for each other
> I meen for them selfs :)
>
> >
>

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



Re: new user needs some advice setting up a model...

2008-09-24 Thread Alexander Pugachev
You can force database to watch after columns to be unique by one or in
combinations.
Django admin interface also can watch after this restrictions.
How to make a model to have few attributes unique together is described
here:
 http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together
So you make job and id to be unique together in shot model.

2008/9/24 paul <[EMAIL PROTECTED]>

>
> hi all,
>
> i've thrown myself into developing an animation pipeline using
> django.  i'm new to both python and django - but have in the (distant)
> past written thousands of lines of c,c++ & perl.  so, please be gentle
> - but maybe not too gentle with me.
>
> this first question is quite simple.  i have a job and shot classes
> (should i call them tables?).  each job has a unique name, and can
> have many shots attached to it.  a shot must have a unique name within
> each job.  ie,
>
> job=bmw, shot=1,2,3,looktest
> job=goldfrapp, shot=1,2,3,4,5,6,looktest,animtest
>
> currently, i'm using the admin UI to input job and shot information.
> my question is what is the best way to make sure that i never have a
> two shots of the same name per job?  should this logic be inserted
> into the save method of the shot, or could/should it be inserted
> elsewhere (ie, within the model itself)?
>
> sorry for the simplicity of the question - i'm still trying to get to
> grips with django/pythonific best practice...
>
> regards to all,
>
> 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?hl=en
-~--~~~~--~~--~--~---



Re: django-recommender 0.2, with content based recs

2008-09-24 Thread coulix

Very nice, i was expecting something like this to be released soon,
its such a nice book.
All the calculation are done on the fly i guess, but it should not bet
too hard to move this on a cron job or why not send it for calculation
on EC2 for large data set.

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



Re: Dictionary Issue in Django Template (Beginner)

2008-09-24 Thread rskm1

> {% for machine in web %}
>   {% for status_message in  status.machine %}
> ...
> So, i want to be able to do something like status.machine..

If there's a BETTER way, I'd love to hear it too, but this is usually
accomplished with a custom filter.
It's commonly named "getattr", and your template would change like so:

{% load myfilters %}
{% for machine in web %}
  {% for status_message in  status|getattr:machine %}
...

You don't need to name it "myfilters.py", but the custom "getattr"
filter code MUST be in a directory named "templatetags/".  Mine is a
little different (I didn't bother with the "default value"
capability), but I used the same basic concepts as:
http://www.djangosnippets.org/snippets/38/ (Read RichardBronosky's
comment too!)
http://www.djangosnippets.org/snippets/411/ (if you want to get a
little fancier)

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



unexpected keyword argument 'force_insert'

2008-09-24 Thread [EMAIL PROTECTED]

Using django 1.0 and django-registration I'm getting this error:

save() got an unexpected keyword argument 'force_insert'

I've read some docs about adding force_insert as a keyword, but I
guess I'm not seeing where/how to do that.

Also, I don't really think there's any problem with django-
registration. I suspect the problem may be related to my
profile_callback:

def create_site_user(new_user):
new_user_profile = SiteUser.objects.create(
user=new_user,
site = Site.objects.get_current()
)
new_user_profile.save()

I've also tried it with
new_user_profile.save(force_insert=True) but get the same error.


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



new user needs some advice setting up a model...

2008-09-24 Thread paul

hi all,

i've thrown myself into developing an animation pipeline using
django.  i'm new to both python and django - but have in the (distant)
past written thousands of lines of c,c++ & perl.  so, please be gentle
- but maybe not too gentle with me.

this first question is quite simple.  i have a job and shot classes
(should i call them tables?).  each job has a unique name, and can
have many shots attached to it.  a shot must have a unique name within
each job.  ie,

job=bmw, shot=1,2,3,looktest
job=goldfrapp, shot=1,2,3,4,5,6,looktest,animtest

currently, i'm using the admin UI to input job and shot information.
my question is what is the best way to make sure that i never have a
two shots of the same name per job?  should this logic be inserted
into the save method of the shot, or could/should it be inserted
elsewhere (ie, within the model itself)?

sorry for the simplicity of the question - i'm still trying to get to
grips with django/pythonific best practice...

regards to all,

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



Re: UserProfile problem

2008-09-24 Thread Denis Morozov

Look at this post, it seems to be what you need:
http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/

And you have to read comments to that page, where is some fix to the
code in the comments.

On Sep 24, 7:03 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote:
> Running django-1.0 out of svn trunk, just updated today (9084).
>
> I've defined my UserProfile according to the latest documentation:
>
> class UserProfile(models.Model):
>      user  = models.ForeignKey(User, unique=True)
>      dep   = models.CharField("Department", max_length=20, blank=True)
>      phone = models.CharField(max_length=20, blank=True)
>      notes = models.TextField(blank=True)
>
> I've added the following to my settings.py:
>
> AUTH_PROFILE_MODULE = 'app.userprofile'
>
> But I still don't get any extra fields in the admin.
>
> What am I missing?
>
> Any input appreciated
> /Lars
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Whither Validators?

2008-09-24 Thread Rodrigo Culagovski

So, do you have to override the model's save method and do your
validation there?

On Sep 24, 3:20 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 24 sep, 18:30, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
>
> > Validators (django.core.validators) seem to have been removed from
> > 1.0. What replaces them?
>
> Nothing yet AFAICT.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Set booleanfield to True on shell?

2008-09-24 Thread Daniel Roseman

On Sep 24, 8:00 pm, Jorge Romo <[EMAIL PROTECTED]> wrote:
> Hello guys, maybe this is a kinda dumb question but i just can't
> figure it out!
>
> I have set to False as default for a is_finished field. If something
> is finished it should turn to True, but i just can't make it happen.
> Any idea?
>
> I tried with .objects.update but it updated all my model objects
> hahaha. I hope you can help me out
>
> Thanks in advance

myinstance = MyModel.objects.get(pk=1) # or whatever
myinstance.is_finished = True
myinstance.save()
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQL ENUM and SET fields - can Django handle them?

2008-09-24 Thread J Cook



Karen Tracey wrote:

> 
> SET as I recall required a little more work.  It's also a CharField, but 
> required some translation from the comma-delimited string value passed 
> to/from the database layer to the Python set type I wanted to use for 
> manipulating the data in my Python code.  If I were writing the code 
> today I'd probably look into creating a custom field 
> (http://docs.djangoproject.com/en/dev/howto/custom-model-fields/) for a 
> set, but back when I had to do this it was not so easy to write custom 
> fields, so I did not go that route (and I have not had to revisit the 
> code, so it stays as originally written despite there now maybe being a 
> better way to do it...if it's not broken I'm not inclined to 'fix' it).

Is there any way you could post an example of what works for you with a 
SET field? Pretty please:)

Justin

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



Re: Whither Validators?

2008-09-24 Thread bruno desthuilliers

On 24 sep, 18:30, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> Validators (django.core.validators) seem to have been removed from
> 1.0. What replaces them?

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



Re: Multiple instances using mod_python

2008-09-24 Thread Álvaro J. Iradier

Take a look at this, it worked for me:

https://devel.airadier.com/default/blog/modpythonvirtualenvironments

Greets.

On Wed, Sep 24, 2008 at 4:52 PM, Scott Moonen <[EMAIL PROTECTED]> wrote:
> I'm running a single instance of Apache to serve two IP addresses.  One IP
> address has specific hostnames assigned in several VirtualHosts, and a
> Location statement for certain hostnames to be handled by a mod_python
> instance running a Django application.  The other IP address has a
> wildcarded ServerAlias, and DNS is setup so that any hostname not
> specifically assigned to the first IP address is directed to this second IP
> address.  For this second IP address I have a VirtualHost that also uses a
> mod_python instance running a different Django application.
>
> I see on this thread
> 
> from last year that there is suspicion that Apache can at times misdirect
> mod_python requests to the wrong mod_python instance.  And this is what I'm
> experiencing from time to time.  It's a bit strange, though: 1) normal file
> content on these same virtual hosts outside of my mod_python 
> statement seems to load fine, so Apache seems to be confused only when
> directing requests to mod_python; 2) this is intermittent, as several
> requests in a row may go to the wrong handler while a subsequent request may
> go to the proper handler; 3) I have taken care to force a specific ordering
> in my virtual host definitions, but this has not helped, although I kind of
> expected that given that the problem is intermittent; and 4) the wildcarded
> virtual host is in fact the only virtual host on my second IP address, and I
> have no other VirtualHosts for that IP address, so the fact that Apache
> seems to be misdirecting the mod_python handler to virtual hosts for an
> entirely different IP address is pretty disconcerting.
>
> I'm running Apache 2.2.3, mod_python 3.3.1, and the latest Django SVN.
> Because filesystem content loads fine, and because this problem is polluting
> VirtualHosts that don't even share the same IP address, it seems intuitive
> that the problem must be some weakness in Apache's internal scoping of
> Location statements to the VirtualHosts that they appear in.
>
> Is anyone else experiencing this problem?  Is anyone aware of any fixes?
> Based on my guess that the problem is Apache's internal scoping of Location
> directives, I'm tempted to switch from mod_python to mod_fastcgi.  But I'd
> rather stick with the recommended mod_python deployment method if there's a
> known way of getting things working,
>
>   -- Scott
>
> --
> http://scott.andstuff.org/ | http://truthadorned.org/
>
> >
>



-- 
(:===:)
 Alvaro J. Iradier Muro - [EMAIL PROTECTED]

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



Manager to add entries where there is a ManyToMany relationship

2008-09-24 Thread SnappyDjangoUser

Hi Everyone,

I need some guidance with adding table entries where I have a M2M
table relationship.  I am adding entires via a Quote ModelForm.  The
problem is that I am getting the following error when submitting the
form:  "Cannot set values on a ManyToManyField which specifies an
intermediary model.  Use QuoteHasProduct's Manager instead."

I have 2 questions:

1. How do I create a Manager to add entries to the QuoteHasProduct
model? (see above error message)
2. My Quote ModelForm creates a nice multiselect box for the products
selected in the M2M relationship.  My problem is that I also have
several additional fields in the QuoteHasProduct table (e.g. quantity
and product_quote) and I need a way to enter values for them.  Does
anyone have a suggestion on a front end mechanism to select multiple
products for an order and also enter the quantity and product_quote at
the same time.  I am hoping there is an easy way to do this within the
ModelForms class.

For reference, the Models of my tables are below:

class Product(models.Model):
idProduct = models.AutoField(primary_key=True)
Vendor_idVendor = models.ForeignKey(Vendor,
db_column='Vendor_idVendor', verbose_name = 'Vendor Name')
Device_Family = models.CharField(max_length=90)
Product_Number = models.CharField(max_length=30)
Device_Description = models.TextField(blank=True)
class Meta:
db_table = u'Product'
def __unicode__(self):
return self.Device_Family

class Quote(models.Model):
idQuote = models.AutoField(primary_key=True, verbose_name='Quote
Number')
quote_date = models.DateField()
quote_number = models.CharField(max_length=45, blank=True)
quote_file = models.FileField(blank=True, upload_to='files/
orders/')
products = models.ManyToManyField(Product,
through='QuoteHasProduct') # filter_interface=models.HORIZONTAL
class Meta:
db_table = u'Quote'
def __unicode__(self):
return self.quote_number

class QuoteHasProduct(models.Model):
Quote_idQuote = models.ForeignKey(Quote)
Product_idProduct = models.ForeignKey(Product)
quantity = models.IntegerField()
product_quote = models.DecimalField(max_digits=10,
decimal_places=2)
class Meta:
db_table = u'Quote_has_Product'


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



Set booleanfield to True on shell?

2008-09-24 Thread Jorge Romo

Hello guys, maybe this is a kinda dumb question but i just can't
figure it out!

I have set to False as default for a is_finished field. If something
is finished it should turn to True, but i just can't make it happen.
Any idea?

I tried with .objects.update but it updated all my model objects
hahaha. I hope you can help me out

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



Re: Recursively rendering in template

2008-09-24 Thread Scott Moonen
Haven't tried it, but off the top of my head it seems like you could
accomplish this by combining 'with' (to temporarily rename the child) and
'include':

*app/node.html:*
{{ node.name }} . . .

  {% for child in node.children %}
{% with child as node %}{% include 'app/node.html' %}{% endwith %}
  {% endfor %}


   -- Scott

On Wed, Sep 24, 2008 at 2:17 PM, David Koblas <[EMAIL PROTECTED]> wrote:

>
> I'm not sure if this is possible to do without writing a templatetag
> (ok, that's my theory).
>
> Basic idea is that I have a tree structure that I want to render into a
> template, the one example that I found pre-rendered a template into a
> template variable and then rendered it into the page.
>
> What I would really like to be able to do is something akin to:
>...html...
>{% render node %}
>
>{% render children %}
>
>html...
>
> Any quick answers, before I spend the afternoon figuring out if a
> template tag is going to work?
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: Recursively rendering in template

2008-09-24 Thread akonsu

hello,

i do not see a way to do it without a custom tag. i myself do a
similar thing using my own tag.

konstantin

On Sep 24, 2:17 pm, David Koblas <[EMAIL PROTECTED]> wrote:
> I'm not sure if this is possible to do without writing a templatetag
> (ok, that's my theory).
>
> Basic idea is that I have a tree structure that I want to render into a
> template, the one example that I found pre-rendered a template into a
> template variable and then rendered it into the page.
>
> What I would really like to be able to do is something akin to:
>     ...html...
>     {% render node %}
>     
>     {% render children %}
>     
>     html...
>
> Any quick answers, before I spend the afternoon figuring out if a
> template tag is going to work?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple instances using mod_python

2008-09-24 Thread Scott Moonen
FYI because there was some wildcarding going on, I think my ServerNames were
actually duplicate in the two VirtualHost definitions (unqualified main
domain name) and I was accomplishing any differentiation using ServerAlias.
According to the mod_python docs <
http://www.modpython.org/live/current/doc-html/pyapi-interps.html>, this
must have caused my instances to share an interpreter, probably resulting in
some unfortunate collisions on key modules (like the settings file, which
had the same path in both handlers).  So I added the PythonInterpreter
directive as suggested by mod_python and as indicated in the Django docs <
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/>.  Haven't
had much opportunity to test, but I expect this will do the trick.

Just wanted to close the loop here on the list in case someone stumbles
across this in the future,

  -- Scott

On Wed, Sep 24, 2008 at 12:11 PM, David Durham, Jr. <
[EMAIL PROTECTED]> wrote:

>
> > I see on this thread
> > <
> http://groups.google.com/group/django-users/browse_thread/thread/4f0cb183eb5b43cd/7be0fa3681b73220?lnk=raot
> >
> > from last year that there is suspicion that Apache can at times misdirect
> > mod_python requests to the wrong mod_python instance.
>
> You could try mod_wsgi.
>
> -Dave
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Recursively rendering in template

2008-09-24 Thread David Koblas

I'm not sure if this is possible to do without writing a templatetag 
(ok, that's my theory).

Basic idea is that I have a tree structure that I want to render into a 
template, the one example that I found pre-rendered a template into a 
template variable and then rendered it into the page.

What I would really like to be able to do is something akin to:
...html...
{% render node %}

{% render children %}

html...

Any quick answers, before I spend the afternoon figuring out if a 
template tag is going to work?

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



Re: FormPreview, context, and the state dictionary

2008-09-24 Thread Rajesh Dhawan

On Sep 24, 2:01 pm, Beals <[EMAIL PROTECTED]> wrote:
> Thanks, Rajesh, that makes sense.

You're welcome.

Please consider bottom/in-line posting in future. It makes it easier
for others to follow along what you are replying to.

> I'm still having an issue, though.
> One value I'm trying to put into the context comes from the URL
> parameters, so the context processor doesn't see it (I can't find it
> in the WSGI request, which is all the context processor sees).  How
> can I get the context processor to see the URL parameters?

I don't know if that's the right way of thinking about this since
there isn't a clean way of doing that. You do get those URL parameters
in the "state" variable in your template when you override
parse_params and populate self.state. So is there any reason you would
not access them as state.xyz in the template?

Is this problem specific to your FormPreview related views/templates
or is it that you want to grab a certain URL parameter for use by site-
wide templates? It would help to understand the purpose of this URL
parameter because there may be other better design patterns this would
fit under such as: process_view middleware, custom templatetag, query
string parameter, etc.

-RD


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



Re: Test fixture persistent across applications

2008-09-24 Thread davenaff

As it turns out, TestCase only flushes the database before a test.  It
doesn't flush it after it has finished its tests.

On Sep 24, 10:18 am, davenaff <[EMAIL PROTECTED]> wrote:
> I'm running into a bizarre bug? in the test utilities.  Basically, a
> fixture imported as part of a django testcase is persistent and the
> data in the fixture is appearing in doctests for a separate
> application.
>
> I have two apps:
> app1
>  - uses the fixture in test case
> app2
>  - doctest
>
> If I run "test app1 app2"  the data from app1 is picked up in app2
> If I run "test app2 app1" everything works fine.
>
> I'm still trying to isolate the problem, but I wanted to see if anyone
> else has run into similar problems and what the resolution was...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FormPreview, context, and the state dictionary

2008-09-24 Thread Beals

Thanks, Rajesh, that makes sense.  I'm still having an issue, though.
One value I'm trying to put into the context comes from the URL
parameters, so the context processor doesn't see it (I can't find it
in the WSGI request, which is all the context processor sees).  How
can I get the context processor to see the URL parameters?

-Aaron

On Sep 24, 12:47 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> On Sep 24, 11:41 am, Beals <[EMAIL PROTECTED]> wrote:
>
>
>
> > I've started to use the FormPreview app in contrib, which has mostly
> > worked out well (though it's a little strange to me to move all my
> > logic into the form, rather than the view).  My only issue now is with
> > the context.
>
> > Some background:
> > 1) Most of my URLs are backed by views, and I have context processors
> > set up that put all kinds of useful variables in the context so the
> > templates have direct access to them.
> > 2) I'm heavily using template inheritance and inclusion (very DRY,
> > eh?), and some of the base templates occur on all pages and expect
> > certain variables to live in the context.
>
> > The issue is that FormPreview works differently.  It isn't a
> > traditional view, per se, but rather generates functions that act like
> > views, complete with context.  FormPreview provides an overriddable
> > method -- parse_params(self, *args, **kwargs) -- that allows you to
> > take URL parameters and store them in the local 'state' dictionary,
> > which is then passed on in the context.
>
> > So now, if I want to access a context variable 'foo' in my base
> > templates, I need to look for both 'foo' and 'state.foo'; the latter
> > in case I'm in a FormPreview page.
>
> You shouldn't have to. The view methods used internally by FormPreview
> call RequestContext which call all your
> settings.TEMPLATE_CONTEXT_PROCESSORS and add their results to the
> context dictionary. So you should just be able to access 'foo' as you
> would with any other template.
>
> What problem are you seeing if you just try to access 'foo' in such a
> template?
>
> -RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQL ENUM and SET fields - can Django handle them?

2008-09-24 Thread Karen Tracey
On Wed, Sep 24, 2008 at 12:52 PM, J Cook <[EMAIL PROTECTED]> wrote:

>
> I have a legacy database with a table that has many ENUM and SET fields
> - it seems that Django's models cannot handle these field types - or can
> they? I would rather not modify the table if I can get it to work as is.
>  Is this what CommaSeparatedIntegerField is for?
>
> Google has not been my friend since I cannot really find anything with
> Django MySQL ENUM and SET fields that explains one way or the other.
> Maybe this should be addressed on
> http://docs.djangoproject.com/en/dev/ref/databases/ so it could help
> others with this problem.
>

I too started with a legacy MySQL database that uses ENUM and SET fields.

ENUM is easy, in the Django model just use a CharField with choices (
http://docs.djangoproject.com/en/dev/topics/db/models/#field-options) set to
match your possible values.  (Though there is no help here provided by the
introspection of inspectdb, so you have to set this up manually.)

SET as I recall required a little more work.  It's also a CharField, but
required some translation from the comma-delimited string value passed
to/from the database layer to the Python set type I wanted to use for
manipulating the data in my Python code.  If I were writing the code today
I'd probably look into creating a custom field (
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/) for a set,
but back when I had to do this it was not so easy to write custom fields, so
I did not go that route (and I have not had to revisit the code, so it stays
as originally written despite there now maybe being a better way to do
it...if it's not broken I'm not inclined to 'fix' it).

You definitely should not have to modify the table (if Django had required
that I do that, I would not have used Django).

Karen

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



Test fixture persistent across applications

2008-09-24 Thread davenaff

I'm running into a bizarre bug? in the test utilities.  Basically, a
fixture imported as part of a django testcase is persistent and the
data in the fixture is appearing in doctests for a separate
application.

I have two apps:
app1
 - uses the fixture in test case
app2
 - doctest

If I run "test app1 app2"  the data from app1 is picked up in app2
If I run "test app2 app1" everything works fine.

I'm still trying to isolate the problem, but I wanted to see if anyone
else has run into similar problems and what the resolution was...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pyRTF and unicode

2008-09-24 Thread Juanjo Conti

I added unicode support to pyrtf-ng. Google it.
JJ from cellphone

2008/9/24, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> I'm creating some RTF pages using pyRTF. Unfortunately, it doesn't
> appear to support unicode, and I keep throwing UnicodeEncodeError. Is
> there a way to de-unicode the data I'm passing to it or something?
> >
>


-- 
Juanjo Conti

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



MySQL ENUM and SET fields - can Django handle them?

2008-09-24 Thread J Cook

I have a legacy database with a table that has many ENUM and SET fields 
- it seems that Django's models cannot handle these field types - or can 
they? I would rather not modify the table if I can get it to work as is. 
  Is this what CommaSeparatedIntegerField is for?

Google has not been my friend since I cannot really find anything with 
Django MySQL ENUM and SET fields that explains one way or the other. 
Maybe this should be addressed on 
http://docs.djangoproject.com/en/dev/ref/databases/ so it could help 
others with this problem.

TIA,

Justin

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



Re: FormPreview, context, and the state dictionary

2008-09-24 Thread Rajesh Dhawan



On Sep 24, 11:41 am, Beals <[EMAIL PROTECTED]> wrote:
> I've started to use the FormPreview app in contrib, which has mostly
> worked out well (though it's a little strange to me to move all my
> logic into the form, rather than the view).  My only issue now is with
> the context.
>
> Some background:
> 1) Most of my URLs are backed by views, and I have context processors
> set up that put all kinds of useful variables in the context so the
> templates have direct access to them.
> 2) I'm heavily using template inheritance and inclusion (very DRY,
> eh?), and some of the base templates occur on all pages and expect
> certain variables to live in the context.
>
> The issue is that FormPreview works differently.  It isn't a
> traditional view, per se, but rather generates functions that act like
> views, complete with context.  FormPreview provides an overriddable
> method -- parse_params(self, *args, **kwargs) -- that allows you to
> take URL parameters and store them in the local 'state' dictionary,
> which is then passed on in the context.
>
> So now, if I want to access a context variable 'foo' in my base
> templates, I need to look for both 'foo' and 'state.foo'; the latter
> in case I'm in a FormPreview page.

You shouldn't have to. The view methods used internally by FormPreview
call RequestContext which call all your
settings.TEMPLATE_CONTEXT_PROCESSORS and add their results to the
context dictionary. So you should just be able to access 'foo' as you
would with any other template.

What problem are you seeing if you just try to access 'foo' in such a
template?

-RD

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



Adding permalinks from get_absolute_url to serialized output

2008-09-24 Thread macgregor

I have a view that uses django.core.serializers to output the latest 3
entries in my app in json. This works great but I would like to add
permalinks for each item in the queryset rather than regex the date
and slug fields together with javascript to build my url.

I have get_absolute_url set up and working on this model.Is there a
way to do this in my view code rather than doing with javascript when
I process the json?

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



Whither Validators?

2008-09-24 Thread Rodrigo Culagovski

Validators (django.core.validators) seem to have been removed from
1.0. What replaces them?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Anti-spam suggestions (strange case)

2008-09-24 Thread Brian Neal

On Sep 24, 9:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> We have a simple form that allows site visitors to request a free
> issue of the magazines we publish. The form simply writes to the
> database, and the info is later pulled by the circulation people so
> they can send the issues out. The info does not appear anywhere on the
> site, and is only used to fulfill the request.
>
> My problem is that for some reason spammers have latched onto this
> form, creating a lot of grief when our circulation people are trying
> to send out the requests.
>
> Nearly all of the spammers follow a pattern, giving random strings for
> their address, city and email, like this:
> City: bbaOWiatlF  and email: [EMAIL PROTECTED]
>
> Does anyone have any suggestions on how to weed these goons out?

Maybe use a honeypot field in the form like the comments app does. You
can even label it with a label that says "do not fill in this form or
we will think you are spamming us". Hide this field on the form with
CSS (display: none) so most users with modern browsers won't even see
it. Spammers using automated tools typically fill in random garbage
into all fields on a form. Reject any form submission that has that
field filled 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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple instances using mod_python

2008-09-24 Thread David Durham, Jr.

> I see on this thread
> 
> from last year that there is suspicion that Apache can at times misdirect
> mod_python requests to the wrong mod_python instance.

You could try mod_wsgi.

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



Re: amd64 vs x86 hosting

2008-09-24 Thread David Durham, Jr.

On Wed, Sep 24, 2008 at 11:07 AM, David Durham, Jr.
<[EMAIL PROTECTED]> wrote:
> On Wed, Sep 24, 2008 at 6:14 AM, mcosta <[EMAIL PROTECTED]> wrote:
>> One question: ¿amd64 or x86? we've got some bechmark claiming superior
>> performance for amd64, both with python and mysql, but then we can not
>> tune with psyco. We've taken a look at pyrex but we do not know even
>> if we are shooting in our foot with any of these. ¿are these
>> technologies useful for actual web app tuning?
>
> I think the primary difference is the amount of RAM that is supported
> and whether or not you have compatible software.  With that said, all
> modern processors are x64 so you probably want to default with an x64
> OS unless you need x86 for software compatibility reasons.

Actually I don't know that all modern processors are x64, but it seems
to me that the server ones are.

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



Re: amd64 vs x86 hosting

2008-09-24 Thread David Durham, Jr.

On Wed, Sep 24, 2008 at 6:14 AM, mcosta <[EMAIL PROTECTED]> wrote:
> One question: ¿amd64 or x86? we've got some bechmark claiming superior
> performance for amd64, both with python and mysql, but then we can not
> tune with psyco. We've taken a look at pyrex but we do not know even
> if we are shooting in our foot with any of these. ¿are these
> technologies useful for actual web app tuning?

I think the primary difference is the amount of RAM that is supported
and whether or not you have compatible software.  With that said, all
modern processors are x64 so you probably want to default with an x64
OS unless you need x86 for software compatibility reasons.

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



Re: django-recommender 0.2, with content based recs

2008-09-24 Thread bcurtu

Mostly, algorithms from chapter 2. However, some of them have
modifications, or even a rewrite of it.


On 24 sep, 17:59, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> Looks nice. Which of the algorithms in Programming Collective
> Intelligence are you using, specifically?
>
> Thanks,
>
> Rodrigo
>
> On Sep 24, 11:36 am, bcurtu <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have just updated my django-recommender to 0.2, including Content
> > Based Recommendations using django tagging.
>
> > Have a look athttp://code.google.com/p/django-recommender/
>
> > Cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-recommender 0.2, with content based recs

2008-09-24 Thread Rodrigo Culagovski

Looks nice. Which of the algorithms in Programming Collective
Intelligence are you using, specifically?

Thanks,

Rodrigo

On Sep 24, 11:36 am, bcurtu <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have just updated my django-recommender to 0.2, including Content
> Based Recommendations using django tagging.
>
> Have a look athttp://code.google.com/p/django-recommender/
>
> Cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unsaved object when passing a callable to "upload_path"

2008-09-24 Thread Rodrigo Culagovski

D'oh. This was trivial.

>Is there a way to
> save the rest of the object before calling "file_path"?

Yes, putting it after the other fields in the model definition.

This works:

class File(models.Model):
article= models.ForeignKey(Article)
type= models.IntegerField(choices=choices((0,"Text"),(1,"Figure"),
(2,"Table")))
number= models.IntegerField()
file= models.FileField(upload_to=file_path)

On Sep 24, 11:51 am, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> I'm trying to use the new ability to pass a callable to "upload_to" in
> fieldfields. I'm having problems with the object not being saved
> before the callable is called.
>
> Model:
>
> def file_path(instance, filename):
>     return "uploads/files/%s/%s/%s_%s%s" % (
>         slugify(instance.article.author.lastname
> +"_"+instance.article.author.firstname),
>         slugify(instance.article.title),
>         instance.get_type_display(),
>         instance.number,
>         os.path.splitext(filename)[1])
>
> class File(models.Model):
>     article= models.ForeignKey(Article)
>     file= models.FileField(upload_to=file_path)
>     type= models.IntegerField(choices=choices((0,"Text"),(1,"Figure"),
> (2,"Table")))
>     number= models.IntegerField()
>
> File is being edited inline in "Article". This should create a path
> like
>
> "uploads/files/peter_parker/webs_i_have_known/Figure_1.jpg",
>
> however, what I actually get is:
>
>  "uploads/files/parker_peter/webs_i_have_known/None_None.jpg".
>
> So "instance.get_type_display()" and "instance.number" are returning
> "None".
> If I change the file and save it again the name is assigned
> correctly.
> This is clearly because the object has not been saved the first time
> when the filepath is calculated. How to fix this? Is there a way to
> save the rest of the object before calling "file_path"?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: An academic journal's site

2008-09-24 Thread Rodrigo Culagovski

 > However, you might also wish to consider whether storing the text
in the
> database is really necessary or useful. Maybe just storing the files on
> disk and storing the filenames in the database is a simpler approach.
> That way people can download/upload as they have always done and you
> don't end with megabyte-sized rows in the database. Django's FileField
> field is going to make this relatively straightforwards.
>
>
Good point.

Thanks,

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



Unsaved object when passing a callable to "upload_path"

2008-09-24 Thread Rodrigo Culagovski

I'm trying to use the new ability to pass a callable to "upload_to" in
fieldfields. I'm having problems with the object not being saved
before the callable is called.

Model:

def file_path(instance, filename):
return "uploads/files/%s/%s/%s_%s%s" % (
slugify(instance.article.author.lastname
+"_"+instance.article.author.firstname),
slugify(instance.article.title),
instance.get_type_display(),
instance.number,
os.path.splitext(filename)[1])

class File(models.Model):
article= models.ForeignKey(Article)
file= models.FileField(upload_to=file_path)
type= models.IntegerField(choices=choices((0,"Text"),(1,"Figure"),
(2,"Table")))
number= models.IntegerField()

File is being edited inline in "Article". This should create a path
like

"uploads/files/peter_parker/webs_i_have_known/Figure_1.jpg",

however, what I actually get is:

 "uploads/files/parker_peter/webs_i_have_known/None_None.jpg".

So "instance.get_type_display()" and "instance.number" are returning
"None".
If I change the file and save it again the name is assigned
correctly.
This is clearly because the object has not been saved the first time
when the filepath is calculated. How to fix this? Is there a way to
save the rest of the object before calling "file_path"?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FormPreview, context, and the state dictionary

2008-09-24 Thread Beals

I've started to use the FormPreview app in contrib, which has mostly
worked out well (though it's a little strange to me to move all my
logic into the form, rather than the view).  My only issue now is with
the context.

Some background:
1) Most of my URLs are backed by views, and I have context processors
set up that put all kinds of useful variables in the context so the
templates have direct access to them.
2) I'm heavily using template inheritance and inclusion (very DRY,
eh?), and some of the base templates occur on all pages and expect
certain variables to live in the context.

The issue is that FormPreview works differently.  It isn't a
traditional view, per se, but rather generates functions that act like
views, complete with context.  FormPreview provides an overriddable
method -- parse_params(self, *args, **kwargs) -- that allows you to
take URL parameters and store them in the local 'state' dictionary,
which is then passed on in the context.

So now, if I want to access a context variable 'foo' in my base
templates, I need to look for both 'foo' and 'state.foo'; the latter
in case I'm in a FormPreview page.

Anyone used the form preview code before and run into this issue?

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



django-recommender 0.2, with content based recs

2008-09-24 Thread bcurtu

Hi,

I have just updated my django-recommender to 0.2, including Content
Based Recommendations using django tagging.

Have a look at http://code.google.com/p/django-recommender/

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



Re: amd64 vs x86 hosting

2008-09-24 Thread Christian Joergensen

mcosta wrote:
> One question: ¿amd64 or x86? we've got some bechmark claiming superior
> performance for amd64, both with python and mysql, but then we can not
> tune with psyco. We've taken a look at pyrex but we do not know even
> if we are shooting in our foot with any of these. ¿are these
> technologies useful for actual web app tuning?

In my experience, when it comes to database backed web applications, the 
application logic is seldom the bottleneck (unless, of course, you do a 
lot of numbers crushing).

You should probably focus your optimization on your database instead, 
and not so much whether you should use psyco or pyrex to speed up your 
Python code.

Regards,

Christian

-- 
Christian Joergensen
http://www.technobabble.dk

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



Re: Anti-spam suggestions (strange case)

2008-09-24 Thread Dan M




> My problem is that for some reason spammers have latched onto this
> form, creating a lot of grief when our circulation people are trying
> to send out the requests.
>
> Nearly all of the spammers follow a pattern, giving random strings for
> their address, city and email, like this:
> City: bbaOWiatlF  and email: [EMAIL PROTECTED]
>
> Does anyone have any suggestions on how to weed these goons out?
>
>   
This is not Django-specific and would not be fast, but perhaps doing a 
"whois" lookup on the domain name?


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



Re: pyRTF and unicode

2008-09-24 Thread Karen Tracey
On Wed, Sep 24, 2008 at 10:14 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> I'm creating some RTF pages using pyRTF. Unfortunately, it doesn't
> appear to support unicode, and I keep throwing UnicodeEncodeError. Is
> there a way to de-unicode the data I'm passing to it or something?
>

The way to go from a unicode type to a bytestring is to call encode() on the
unicode type.  You have to choose an appropriate encoding for the resulting
bytestring.  'utf-8' may be appropriate but I know nothing of pyRTF so can't
say for sure.  The error you are seeing usually results from an attempt to
encode to 'ascii'  (the default when you say str(unicode_type)) when the
data you have in your unicode_type has no ascii representation.

Karen

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



Re: Percentages in templates

2008-09-24 Thread Rajesh Dhawan

> I have an app that tracks football stats, I'd like to use bar graphs
> similar to what's on Everyblock. This is their code:
>
> http://dpaste.com/80211/
>
> I was curious, how, if possible at all, in the template I could get
> the percentage for the height.
>
> So, for my first graph, so far I'd have these numbers:
>
> 390
> 314
> 402
> 429
>
> The 429 should be 100%, and then down from there 402 (94%), 390 (91%),
> 314 (73%), etc, etc.

You could create a simple template tag that calculates the percentages
for you. The usage would be something like:

{% graph_percentage 429 390 %}
{% graph_percentage 429 314 %}
{% graph_percentage 429 402 %}
{% graph_percentage 429 429 %}

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#shortcut-for-simple-tags

There are other ways of doing this if you tell us how you intend to
generate those raw numbers.

-Rajesh D

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



Re: saving custom form fields in admin panel

2008-09-24 Thread Dennis Schmidt

OK, I found the mistake myself.
The save() function has to return the new object. So this works:

def save(self, commit=True):
return super(CustomerForm, self).save(commit)


On 24 Sep., 13:58, Dennis Schmidt <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> I have a model (Customer) with a ManyToMany field referencing django's
> User class.
> Now in my admin panel I've created a custom Form (ModelForm subclass)
> for my Customer class. The only difference to the default form is that
> I added 3 new (ModelChoiceField) fields. The intention behind this is
> that I want to replace the default MultiSelectField for the model's
> ManyToMany field.
>
> Now my problem is that I don't know how to actually add / save these
> extra fields to my Customer model when it's saved.
> The form gets displayed correctly (and even validation works) but (of
> course?) django doesn't know how it should save my 3 custom fields. So
> everything else gets saved correctly (no errors) but my 3 User models
> won't get added to my Customer model.
>
> My first thought was I maybe have to override the ModelForm.save()
> method. So I tried this just to get started somewhere:
>
> def save(self, commit=True):
>     super(CustomerForm, self).save(commit)
>
> but then, when I click "save" I just get the error message "'NoneType'
> object has no attribute 'save'" which is raised somewhere in a django
> function called save_model().
>
> So what am I doing wrong and how can I realize what I'm trying to do
> (allways adding 3 User objects to one Customer object)?
>
> Thanks in advance,
>
> Dennis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



UserProfile problem

2008-09-24 Thread Lars Stavholm

Running django-1.0 out of svn trunk, just updated today (9084).

I've defined my UserProfile according to the latest documentation:

class UserProfile(models.Model):
 user  = models.ForeignKey(User, unique=True)
 dep   = models.CharField("Department", max_length=20, blank=True)
 phone = models.CharField(max_length=20, blank=True)
 notes = models.TextField(blank=True)

I've added the following to my settings.py:

AUTH_PROFILE_MODULE = 'app.userprofile'

But I still don't get any extra fields in the admin.

What am I missing?

Any input appreciated
/Lars


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



Multiple instances using mod_python

2008-09-24 Thread Scott Moonen
I'm running a single instance of Apache to serve two IP addresses.  One IP
address has specific hostnames assigned in several VirtualHosts, and a
Location statement for certain hostnames to be handled by a mod_python
instance running a Django application.  The other IP address has a
wildcarded ServerAlias, and DNS is setup so that any hostname not
specifically assigned to the first IP address is directed to this second IP
address.  For this second IP address I have a VirtualHost that also uses a
mod_python instance running a different Django application.

I see on this thread <
http://groups.google.com/group/django-users/browse_thread/thread/4f0cb183eb5b43cd/7be0fa3681b73220?lnk=raot>
from last year that there is suspicion that Apache can at times misdirect
mod_python requests to the wrong mod_python instance.  And this is what I'm
experiencing from time to time.  It's a bit strange, though: 1) normal file
content on these same virtual hosts outside of my mod_python 
statement seems to load fine, so Apache seems to be confused only when
directing requests to mod_python; 2) this is intermittent, as several
requests in a row may go to the wrong handler while a subsequent request may
go to the proper handler; 3) I have taken care to force a specific ordering
in my virtual host definitions, but this has not helped, although I kind of
expected that given that the problem is intermittent; and 4) the wildcarded
virtual host is in fact the only virtual host on my second IP address, and I
have no other VirtualHosts for that IP address, so the fact that Apache
seems to be misdirecting the mod_python handler to virtual hosts for an
entirely different IP address is pretty disconcerting.

I'm running Apache 2.2.3, mod_python 3.3.1, and the latest Django SVN.
Because filesystem content loads fine, and because this problem is polluting
VirtualHosts that don't even share the same IP address, it seems intuitive
that the problem must be some weakness in Apache's internal scoping of
Location statements to the VirtualHosts that they appear in.

Is anyone else experiencing this problem?  Is anyone aware of any fixes?
Based on my guess that the problem is Apache's internal scoping of Location
directives, I'm tempted to switch from mod_python to mod_fastcgi.  But I'd
rather stick with the recommended mod_python deployment method if there's a
known way of getting things working,

  -- Scott

-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: Anti-spam suggestions (strange case)

2008-09-24 Thread Grigory Fateyev

Hello [EMAIL PROTECTED]
On Wed, 24 Sep 2008 07:11:44 -0700 (PDT) you wrote:

> 
> We have a simple form that allows site visitors to request a free
> issue of the magazines we publish. The form simply writes to the
> database, and the info is later pulled by the circulation people so
> they can send the issues out. The info does not appear anywhere on the
> site, and is only used to fulfill the request.
> 
> My problem is that for some reason spammers have latched onto this
> form, creating a lot of grief when our circulation people are trying
> to send out the requests.
> 
> Nearly all of the spammers follow a pattern, giving random strings for
> their address, city and email, like this:
> City: bbaOWiatlF  and email: [EMAIL PROTECTED]
> 
> Does anyone have any suggestions on how to weed these goons out?

Maybe create new field w/ captcha validation?

-- 
Всего наилучшего! Григорий
greg [at] anastasia [dot] ru
Письмо отправлено: 2008/09/24 18:39

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



Re: python-ldap + Apache causing errors

2008-09-24 Thread Jashugan

> The problem is most like because some other Apache module, eg. PHP or
> mod_auth_ldap, is loading an incompatible version/variant of LDAP
> client libraries before the Python ldap module does.
>
> Thus, check what versions of LDAP client libraries Python ldap module
> is compiled against and then also look at what PHP or other Apache
> modules are using.
>
> To really get to the problem, you may need to start up Apache in
> single process mode and run it in a debugger. For details see:
>
> http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_C...

This seems a bit daunting, especially if there may be an alternative
solution. For example if I switched to FCGI, this issue should be
resolved, since there wouldn't be any conflicts between other Apache
modules. Am I right in this assumption?

> BTW, you don't say whether you are using mod_python or mod_wsgi.

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



Re: ModelChoiceField with Unique Results

2008-09-24 Thread BobZ

Wow, thank you so much Daniel.

I totally get this now, and it works!

Looks like I've sort of been skirting around this solution for a while
but, being clueless as I can be sometimes with Django, I never knew
what I could've been doing wrong.

Thanks a lot for the help again.

-Bob

On Sep 23, 4:37 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 23, 4:44 pm, BobZ <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks Daniel.  I've found solutions similar to yours in other threads
> > on the net, and everytime I test them, I literally get no form at all
> > in my rendered template.
> > My template appears to have all the correct code in it as you can see
> > in the link "search.html" at the bottom of this post.
> > Looking at the code you provided, it seems like the
> > "queryset=Vehicle.objects.order_by('-year').distinct()" pulls all
> > distinct fields from the Vehicle table and sorts them by year.  What
> > I'm actually after is a way to filter out only the years and list them
> > in descending order.
>
> > In my forms.py file, I've kept all variations of the code I've tested
> > for this app commented out for my own reference, but maybe it will
> > help you see what's happening and what I'm trying to do.
>
> > Here's all of my code in dpaste:
> > http://dpaste.com/80010/;>models.py -http://dpaste.com/80010/
> > http://dpaste.com/80009/;>forms.py -http://dpaste.com/80009/
> > http://dpaste.com/80011/;>views.py -http://dpaste.com/80011/
> > http://dpaste.com/80013/;>search.html -http://dpaste.com/80013/
>
> I think you're misunderstanding the point of ModelForms.
>
> A ModelForm (as opposed to a standard form) is specifically for
> creating or editing a model instance. So if you had a model with a
> foreignkey to Vehicle, you could use this model as the base for a
> modelform with the modelchoice field we have defined.
>
> However, you have defined a ModelForm based on the Vehicle model, with
> a modelchoice field also pointing at Vehicle. That doesn't make sense,
> as the year field on Vehicle isn't a ForeignKey, it's an IntegerField.
> This could be why you're not getting any output in the rendered
> template.
>
> Luckily, your use case doesn't warrant a ModelForm anyway. You're not
> editing a model, you are using the form to create a search box. So you
> just want a standard Form. In which case, something akin to dmorozov's
> solution may be best after all. How about this:
>
> class SearchForm(forms.Form):
>     year=forms.ChoiceField()
>
>     def __init__(self, *args, **kwargs):
>         super(SearchForm, self) .__init__(*args, **kwargs)
>         self.fields['year'].choices =
> Vehicle.objects.values_list('year', 'year').distinct().order_by('-
> year')
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pyRTF and unicode

2008-09-24 Thread [EMAIL PROTECTED]

I'm creating some RTF pages using pyRTF. Unfortunately, it doesn't
appear to support unicode, and I keep throwing UnicodeEncodeError. Is
there a way to de-unicode the data I'm passing to it or something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Anti-spam suggestions (strange case)

2008-09-24 Thread [EMAIL PROTECTED]

We have a simple form that allows site visitors to request a free
issue of the magazines we publish. The form simply writes to the
database, and the info is later pulled by the circulation people so
they can send the issues out. The info does not appear anywhere on the
site, and is only used to fulfill the request.

My problem is that for some reason spammers have latched onto this
form, creating a lot of grief when our circulation people are trying
to send out the requests.

Nearly all of the spammers follow a pattern, giving random strings for
their address, city and email, like this:
City: bbaOWiatlF  and email: [EMAIL PROTECTED]

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



Re: Extra space in the match string

2008-09-24 Thread Keith Eberle
the space indicates passing the URL off to an included urls.py.

keith


On Wed, Sep 24, 2008 at 8:28 AM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
>
>
> On 24 sep, 13:03, tsmets <[EMAIL PROTECTED]> wrote:
> > I am refactoring my URL matching configuration file and I get this :
> > [snip]
> > Page not found (404)
> > Request Method: GET
> > Request URL:http://localhost:8000/followDeploys/viewDeployed/xxx
> >
> > Using the URLconf defined in customer.urls, Django tried these URL
> > patterns, in this order:
> >
> >1. ^followDeploys/ ^viewDeployed/(?P[^a-z][a-z0-9][a-
> > z0-9])
>
> Are you sure the last part ( "everything *but* a character in range a-z".
>
> >2. ^admin/(.*)
> >
> > The current URL, followDeploys/viewDeployed/xxx, didn't match any of
> > these.
> > [/snip]
> >
> > Now there is an extra space in the first matching URL pattern.
>
>
> AFAICT, this 'extra space' is in the error page display only, not in
> the pattern effectively used for matching - I can see similar things
> here with patterns that I know are ok and working.
>
> You didn't specify the effective value of the appAcronym part you used
> for your tests, but it won't match anything starting with a lowercase
> letter.
>
> My 2 cents...
>
> >
>

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



Re: Admin redirecting to wrong URL?

2008-09-24 Thread Allan

Hi Graham,

Thanks for responding.  I'm using Django 1.0, hosted at Webfaction on
Apache using mod_python.  What special configuration or hacks would
you suggest to get admin properly working at a sub URL of this
configuration?

Allan -- Atlanta


On Sep 23, 8:04 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Sep 24, 5:43 am, Allan <[EMAIL PROTECTED]> wrote:
>
> > My application is working well at mysite.com/django/, and I get
> > an admin login at mysite.com/django/admin/ -- but when I
> > enter my credentials, I seem to be redirected to mysite.com/
> > admin/ (which is a 404 error).  Did I miss an admin config setting
> > somewhere?
>
> > A relevant excerpt from urls.py appears below.
>
> > Allan
>
> > import os
> > from django.conf.urls.defaults import *
> > from django.conf import settings
> > from django.contrib import admin
>
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
>
> >     (r'^contact/$', 'careers_contact.views.contact'),
> >     (r'^careers/$', 'careers_contact.views.careers'),
>
> >     (r'^admin/(.*)', admin.site.root),
> > )
>
> How are you hosting Django and what version of Django are you using?
>
> Depending on how you are hosting Django and what version, you may have
> to set special configuration or use hacks to allow it to properly host
> at a sub URL of an Apache installation.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Percentages in templates

2008-09-24 Thread mccomas . chris

I have an app that tracks football stats, I'd like to use bar graphs
similar to what's on Everyblock. This is their code:

http://dpaste.com/80211/

I was curious, how, if possible at all, in the template I could get
the percentage for the height.

So, for my first graph, so far I'd have these numbers:

390
314
402
429

The 429 should be 100%, and then down from there 402 (94%), 390 (91%),
314 (73%), etc, etc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



amd64 vs x86 hosting

2008-09-24 Thread mcosta

Hello people.

This is our first project with python and django. We've been playing
with this stuff but now with django 1.0 we are going to do Real Paid
Work(tm) with it. Until now we are a PHP/cakePHP shop.

One concern is speed. Right now we are not thinking about scale. Just
raw speed, and get the bucks back from the dedicated hosting we are
going to hire.

One question: ¿amd64 or x86? we've got some bechmark claiming superior
performance for amd64, both with python and mysql, but then we can not
tune with psyco. We've taken a look at pyrex but we do not know even
if we are shooting in our foot with any of these. ¿are these
technologies useful for actual web app tuning?

I would love to get some advice for CPU/web server combination. For
example amd64/lighttpd, amd64/cherokee, fastcgi etc...

Thanks

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



Re: Auto Discover on MediaTemple

2008-09-24 Thread mccomas . chris

Thanks for the tips. When you use the most recent release on MT,
they're still using 0.96 for some reason.

On Sep 23, 9:30 am, krylatij <[EMAIL PROTECTED]> wrote:
> make sure that you use Django 1.0
> this mechanizm was changed since 0.96
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: strategy for deploying to production server

2008-09-24 Thread birkin

On Sep 23, 1:36 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:

> ...So I usually have files called dbsettings.py and
> mediasettings.py, that hold all my database and media info, then I
> just have settings.py import them...

I also import into my settings.py file a 'settings_local.py' file,
which does not live in the repository. The one other thing I do is set
every custom setting in the main settings file explicitly, like:

AUTOMATIC_SSL_REDIRECTION = settings_local.AUTOMATIC_SSL_REDIRECTION #
True or False

Especially for non-standard settings, my thinking is that this will
help folk who want to examine my code more easily get it up and
running.

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



Re: Extra space in the match string

2008-09-24 Thread bruno desthuilliers



On 24 sep, 13:03, tsmets <[EMAIL PROTECTED]> wrote:
> I am refactoring my URL matching configuration file and I get this :
> [snip]
> Page not found (404)
> Request Method: GET
> Request URL:http://localhost:8000/followDeploys/viewDeployed/xxx
>
> Using the URLconf defined in customer.urls, Django tried these URL
> patterns, in this order:
>
>1. ^followDeploys/ ^viewDeployed/(?P[^a-z][a-z0-9][a-
> z0-9])

Are you sure the last part (2. ^admin/(.*)
>
> The current URL, followDeploys/viewDeployed/xxx, didn't match any of
> these.
> [/snip]
>
> Now there is an extra space in the first matching URL pattern.


AFAICT, this 'extra space' is in the error page display only, not in
the pattern effectively used for matching - I can see similar things
here with patterns that I know are ok and working.

You didn't specify the effective value of the appAcronym part you used
for your tests, but it won't match anything starting with a lowercase
letter.

My 2 cents...

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



saving custom form fields in admin panel

2008-09-24 Thread Dennis Schmidt

Hello everyone,

I have a model (Customer) with a ManyToMany field referencing django's
User class.
Now in my admin panel I've created a custom Form (ModelForm subclass)
for my Customer class. The only difference to the default form is that
I added 3 new (ModelChoiceField) fields. The intention behind this is
that I want to replace the default MultiSelectField for the model's
ManyToMany field.

Now my problem is that I don't know how to actually add / save these
extra fields to my Customer model when it's saved.
The form gets displayed correctly (and even validation works) but (of
course?) django doesn't know how it should save my 3 custom fields. So
everything else gets saved correctly (no errors) but my 3 User models
won't get added to my Customer model.

My first thought was I maybe have to override the ModelForm.save()
method. So I tried this just to get started somewhere:

def save(self, commit=True):
super(CustomerForm, self).save(commit)

but then, when I click "save" I just get the error message "'NoneType'
object has no attribute 'save'" which is raised somewhere in a django
function called save_model().

So what am I doing wrong and how can I realize what I'm trying to do
(allways adding 3 User objects to one Customer object)?

Thanks in advance,

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



Re: pretty urls lost in dns

2008-09-24 Thread Wim Feijen

OK, please ignore the above.

Turns out that I am not using DNS at all, but iframes. It will take
some time for the DNS to pick up, but let's see how it works after
that.

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



Extra space in the match string

2008-09-24 Thread tsmets

I am refactoring my URL matching configuration file and I get this :
[snip]
Page not found (404)
Request Method: GET
Request URL:http://localhost:8000/followDeploys/viewDeployed/xxx

Using the URLconf defined in customer.urls, Django tried these URL
patterns, in this order:

   1. ^followDeploys/ ^viewDeployed/(?P[^a-z][a-z0-9][a-
z0-9])
   2. ^admin/(.*)

The current URL, followDeploys/viewDeployed/xxx, didn't match any of
these.
[/snip]

Now there is an extra space in the first matching URL pattern.

My top level URL.py
###
from django.conf.urls.defaults import *


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns ('',
# Follow deploys :
(r'^followDeploys/',include('customer.follow_deploys.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

(r'^admin/(.*)', admin.site.root),
)
###


Then my url.py in follow_deploys is :
###
from django.conf.urls.defaults import *

urlpatterns = patterns('customer.follow_deploys.views',
# Allows to view the status of one acronym
(r'^viewDeployed/(?P[^a-z][a-z0-9][a-z0-9])',
'viewDeployed'),
)
###


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



Re: Django 1.0 and Stdimage does not work

2008-09-24 Thread mwebs

Hi lapain,

yes, this solved the TypeError, but now I am running into a "No such
file or directory".

I opened a new thread: 
http://groups.google.com/group/django-users/browse_thread/thread/b0d3e55398f2906d.

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



Django+ Apache Configuration in Fedora 9

2008-09-24 Thread Harish

hi folks,

   I am  trying to configure apache for a django project..
we are getting a following error

"ImproperlyConfigured: Error loading psycopg2 module: libpq.so.5:
failed to map segment from shared object: Permission denied" while
running the url,

any solution?

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



Templates, context-setting custom tag and nested blocks - doesn't work ? (and is it supposed to anyway ?)

2008-09-24 Thread bruno desthuilliers

Hi all

I don't know wether it's me doing something wrong, or if it's a normal
limitation of Django's templates, or else, but anyway, here's the
problem:

I have a custom tag that sets a variable in the context (the usual
way, ie 'context[self.varname] = something'). This is not my first
custom tag, nor the first context-updating one, so I don't think
there's anything wrong so far.

Now I have this template that extends a base template - I didn't wrote
personnaly FWIW - that has quite a lot of nested blocks definitions -
the idea being to let you override either a whole block or just part
of it. Might be a good idea or not, don't know (as far as I'm
concerned, I wouldn't have done such a thing, but that's another
question...). The doc doesn't mention nesting blocks, but well, it
seems to work fine... *as long* as you only access vars defined in the
view itself *or* have the call to the context-setting tag in the same
block where you access the var. That is : when calling a context-
setting tag anywhere else (top level, prior block at the same level
etc), the var is just not there.

I strongly suspect this have to do with nesting blocks (is that even
supposed to be done ???), but a quick glance at the template package's
code wasn't enough for me to spot anything related, so I thought I'd
better ask here before having a closer look. So, if there's any guru
around (spirit of James B., are you here ?-)...

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



Re: Pre-empting Fixture execution in Django with nosetests.

2008-09-24 Thread Russell Keith-Magee

On Wed, Sep 24, 2008 at 4:39 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Russ,
>
> Well, as you can tell from my initial post, this was my initial
> concept. However, you seem to be proposing to launch nosetests from
> the 'manage.py test' execution rather than directly from the command
> line. Am I reading you right? Hadn't considered that option. Not sure
> how much effort it would be so will have to dig into nosetests source
> to determine. Seems a bit complex at first glance, however.

Caveat: I am in no way an expert on nosetests, so I can't say for sure
that this is possible.

However, at the base level, the Django test runner (./manage.py test)
is just a way of calling a generic python function with an argument
specifying the test conditions (test names, verbosity etc). By
default, the test runner executes the default Python test framework,
but it should be possible to integrate any other test runner or
framework - as long as they expose some sort of 'run these tests'
function. It's just a matter of writing a test runner that can invoke
that function.

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



How to use Stdimage with Django 1.0

2008-09-24 Thread mwebs

Hello, I am using Stdimage in combination with Django 1.0.

Picture(models.Model)
  
  image = StdImageField(upload_to ='multimedia/pictures',
null=True, size=(573, 441), thumbnail_size=(100, 100, True))
...


in my view I do this:

picture = Picture(gallery = gallery, image =
request.FILES['image'].name)
picture.save()

But when I do this I get an "No such File or directory".
When I do something like this (which is the way you go using the
django-built-in image field):

picture = Picture(gallery = gallery, image =
request.FILES['image'].name)
 filename = '%s_%s.jpg' % (str(gallery.content_object), picture.id)
picture.image.save(filename, request.FILES['image'], save=True)

...then I run into a maximum recursion error.

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



How to use Stdimage with Django 1.0

2008-09-24 Thread mwebs

Hello, I am using Stdimage in combination with Django 1.0.

Picture(models.Model)
  
  image = StdImageField(upload_to ='multimedia/pictures',
null=True, size=(573, 441), thumbnail_size=(100, 100, True))
...


in my view I do this:

picture = Picture(gallery = gallery, image =
request.FILES['image'].name)
picture.save()

But when I do this I get an "No such File or directory".
When I do something like this (which is the way you go using the
django-built-in image field):

picture = Picture(gallery = gallery, image =
request.FILES['image'].name)
 filename = '%s_%s.jpg' % (str(gallery.content_object), picture.id)
picture.image.save(filename, request.FILES['image'], save=True)

...then I run into a maximum recursion error.

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



Re: json

2008-09-24 Thread Christian Joergensen

yozhik wrote:
> hi all,
> 
> does anyone have a very simple example of how to use json and jquery
> to communicate between django and javascript. i'm trying to use
> $.getJSON but getting confused what parameters to provide to it. docs
> say
> getJSON(url,data,func). well, func is my javascript function which
> handles data from django. but I am mainly confused  about url.

`url` is the URL where jQuery will request the JSON data from.

It could be `/json/somefeed/` or whatever you have configured the URL of 
your Django view to in urls.py.

Regards,
Christian

-- 
Christian Joergensen
http://www.technobabble.dk

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



pretty urls lost in dns

2008-09-24 Thread Wim Feijen

Hello,

I'm happily running a project on a Strato web server.

I've forwarded the domain name 'uwadresboek.nl' to my server, it's at
IP 85.214.104.194 . Everything works fine, except that:

1. Pretty URLs are lost.

I can type www.uwadresboek.nl/prices and everything is well. In
addition, I can click on a link, f.e. 'read more' and I get
redirected. But now the URL in my browser does not show a change,
which I find very confusing. What could be the cause of the browser
not showing the URL and what can I do about it?

Using www.go2people.net (without DNS forwarding), everything is OK.

2. The background flashes while switching screens.

Any help would be much appreciated!

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



Re: Pre-empting Fixture execution in Django with nosetests.

2008-09-24 Thread [EMAIL PROTECTED]

Russ,

Well, as you can tell from my initial post, this was my initial
concept. However, you seem to be proposing to launch nosetests from
the 'manage.py test' execution rather than directly from the command
line. Am I reading you right? Hadn't considered that option. Not sure
how much effort it would be so will have to dig into nosetests source
to determine. Seems a bit complex at first glance, however.

thanx,

  -- Ben

PS: Meanwhile for the specific model in question, I have moved the
fixtures under the test directory itself and have the unit test class
explicitly load those fixtures so my monkey-patch can happen prior to
the fixture load. Not a general solution but works for now.

On Sep 23, 7:55 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> The solution here is easy - write your own custom test runner. The
> default Django test runner monkeypatches the mail sending libraries
> and the template generation. You need to monkeypatch one of your
> internal capabilites, so you will need to write a custom test runner
> that does so. I haven't looked at the nosetests test runner, but I'd
> be surprised if it can't be substantially reused (or at the very
> least, copied) for your own custom test runner.
>
> 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?hl=en
-~--~~~~--~~--~--~---



Re: get children of children

2008-09-24 Thread Evgeny



On Sep 24, 11:49 am, "Matthias Kestenholz" <[EMAIL PROTECTED]> wrote:

> You probably mean this:
> C.objects.filter(id_b__id_a__exact=1)

> Maybe you meant A is referenced by B?

Yes, exactly this.

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



Re: get children of children

2008-09-24 Thread Matthias Kestenholz

On Wed, Sep 24, 2008 at 9:25 AM, Evgeny <[EMAIL PROTECTED]> wrote:
>
> Hi,
> There's an object hierarchy: A references B, B references C.
> "references" means foreign key.
> Is there a nice Django way to select all C objects which are
> grandchilds of given A with one query? Somethink like
>
> select C.* from C
> join B on B.id = C.id_b
> join A on A.id = B.id_a
> where A.id = 1
>
> i.e. in Django terms get all C objects which are children of
> A.objects.get(id=1).B_set.all()

You probably mean this:
C.objects.filter(id_b__id_a__exact=1)

Your code and your description do not match though. You write
'A references B', but you've got a foreign key from B to A (field id_a)
Maybe you meant A is referenced by B?


Matthias

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



get children of children

2008-09-24 Thread Evgeny

Hi,
There's an object hierarchy: A references B, B references C.
"references" means foreign key.
Is there a nice Django way to select all C objects which are
grandchilds of given A with one query? Somethink like

select C.* from C
join B on B.id = C.id_b
join A on A.id = B.id_a
where A.id = 1

i.e. in Django terms get all C objects which are children of
A.objects.get(id=1).B_set.all()

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



django & chat

2008-09-24 Thread Eric Simorre

Hi,

if you are looking for a chat component to embed in a django project,
take a look at the django-chat project (http://code.google.com/p/
django-chat/ , it has just started), your comments are welcome, in the
chat demo or here.

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



Re: json

2008-09-24 Thread Pigletto

> does anyone have a very simple example of how to use json and jquery
> to communicate between django and javascript. i'm trying to use
> $.getJSON but getting confused what parameters to provide to it. docs
> say
> getJSON(url,data,func). well, func is my javascript function which
> handles data from django. but I am mainly confused  about url.
In Python I use:
Class JsonResponse from djangosnippets.org:
---
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.utils import simplejson
from django.core.serializers.json import DjangoJSONEncoder


class JsonResponse(HttpResponse):
def __init__(self, obj):
self.original_obj = obj
HttpResponse.__init__(self, self.serialize(),
content_type='text/javascript')
#self["Content-Type"] = "text/javascript"

def serialize(self):
return(simplejson.dumps(self.original_obj,
cls=DjangoJSONEncoder))
-

View eg. in views.py is like:
-
def a_something(request):
return JsonResponse({'message': 'bla bla bla',
 'code':324})
-

Javascript:
-
$.ajax({url:COMMON_URLS.test_url,
type: 'GET',
dataType: 'json',
error:   function(data){ alert('Error: '+data); },
success: function(data){ alert('OK! '+data.message+',
'+data.code); }
   });
-

COMMON_URLS.test_url is something like below, defined in your
template:
-

COMMON_URLS = {
   test_url:'{% url a_something_id %}'
}

-

urls.py like:
-
url(r'^a_something/$', 'views.a_something',
name='a_something_id'),
-
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: locale aware number formats

2008-09-24 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-09-23, o godz. 17:51, przez pihentagy:

>>> How can I print a number using the locale's thousand separator and
>>> decimal?
>>
>>> Basically I hoped ther is a template filter, but floatformat doesn't
>>> have thousand separator, and seems to use decimal point always.
>>
>> Take a look at Babel package and Django helpers -http://babel.edgewall.org/
>
> Ok, but there is also the module locale.
> Should I really use other libraries for just displaying a number in a
> page? Django supports translations, doesn't it supports printing
> numbers and currency honoring the currently selected language?

Additionally to what's been said by others, Python's own locale module  
isn't that good in formatting dates and numbers. Babel uses CLDR  
database to provide most accurate l10n data for many locations and  
languages, event those not supported by standard NLS machinery. Plus  
on linux it does not require installing appropriate language support -  
you can do eg. Hungarian date, number and currency formatting without  
installing Hungarian language support package (language-pack-hu on  
Ubuntu).

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[EMAIL PROTECTED]


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



Re: get_query_set in admin/views/main trying to split a list

2008-09-24 Thread Daniel Roseman

On Sep 23, 11:06 pm, Jigsaw <[EMAIL PROTECTED]> wrote:
> Hello,
>
> After upgrading from svn 8322 to 9084, I received: 'list' object has
> no attribute 'split'
> /usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py in
> get_query_set, line 187
>
> I modified line 186 from:
>         if key.endswith('__in'):
> to:
>         if key.endswith('__in') and isinstance(value, str):
> I left line187 untouched:
>                 lookup_params[key] = value.split(',')
>
> Although this appears to have resolved the error, I wonder if I have
> done so correctly?
> If so, what should I do so that I don't lose this modification when I
> next update Django?
>
> Thanks,
> -Jason

It's possible this is a bug, in which case you should raise a ticket
at http://code.djangoproject.com, but you haven't given us enough
information to determine that. What's your code? What are you passing
into this function?

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



Re: denormalized data in single field

2008-09-24 Thread gearheart

yes, i think i'll do that
but the for every entity that has location i need to override form and
save method.

i think there should be more django-style solution


On 23 сент, 23:39, akonsu <[EMAIL PROTECTED]> wrote:
> hello,
>
> you can override the model's save() method.
>
> konstantin
>
> On Sep 23, 3:05 pm, "Владимир Сидоренко" <[EMAIL PROTECTED]> wrote:
>
> > hi
>
> > i need to process a set of denormalized data in single model field.
> > for example,
>
> > class Place(Model):
> >     location = LocationField()
>
> > it's rendered as one single text field, where we insert address, then by
> > this address we find out corresponding district and nearest subway station
>
> > and write to database something like:
>
> > class Location(Model):
> >     address = CharField()
> >     subway = ManyToManyField(Subway)
> >     district = ForeignKey(District)
>
> > class Place(Model):
> >     location = ForeignKey(Location)
>
> > how can i override field's save to db process to generate Location object
> > and save corresponding key to Place?
>
> > Thanks
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



json

2008-09-24 Thread yozhik

hi all,

does anyone have a very simple example of how to use json and jquery
to communicate between django and javascript. i'm trying to use
$.getJSON but getting confused what parameters to provide to it. docs
say
getJSON(url,data,func). well, func is my javascript function which
handles data from django. but I am mainly confused  about url.

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



  1   2   >