Re: mod_python/django problems

2007-08-03 Thread Kenneth Gonsalves


On 03-Aug-07, at 6:36 PM, David Reynolds wrote:

>> per server. i have a situation where i have many small sites.
>> anybody here using mod_python for larger number of sites per server?
>
> We have around 30 and have noticed the problems you've mentioned..

could you mention what exactly the problems you are facing - as i  
mentioned, on one site i have faced the problem of the initial screen  
in admin loading with the fields of the admin screen of the previous  
site accessed in another browser tab. As mentioned I felt that this  
is a browser cache problem as the two sites are practically identical  
and username and password are the same for the two sites. But the  
problem goes away after any action is performed.

-- 

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



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



Re: UnicodeEncodeError

2007-08-03 Thread Alexandre Forget

thanks the help

I am using a modified version of django-forum, replacing those __str__
with __unicode__ did the job

alex

On 8/1/07, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
> Am Mittwoch, 1. August 2007 04:23 schrieb Alexandre Forget:
> > Hi,
> >
> > I am stuck with this error, does someone know what it mean?
> > I am using django svn and sqlite.
> >
> > This error happen when I try to delete an object with the admin
> > interface but it delete fine with the shell.
> >
>
> Hi,
>
> I submitted a small patch to views/debug.py to show the characters
> before and after the wrong charachter. This helps you to find
> the place where the string comes from:
>
> http://code.djangoproject.com/attachment/ticket/5046/views_debug_unicodeerror_hint.diff
>
> Since my python code is in latin1 I get this message often.
> Be sure to use only unicode strings in your code:
>
> example:
>
> models.py
> ...
> foo=models.CharField(maxlength=6, choices=(
> ("umlaut", u"üöäßÜÖÄ"),
>
>  Thomas
>
> >
>

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

2007-08-03 Thread Sean Perry


On Aug 3, 2007, at 9:57 AM, Doug Van Horn wrote:

 def age(d, bday):
> ... return (d.year - bday.year) - \
> ... ((d.month, d.day) < (bday.month, bday.day) and 1 or 0)

Or to be a little more explicit about it:

def age(d, bday):
 return (d.year - bday.year) - \
 int((d.month, d.day) < (bday.month, bday.day))

int(True) => 1, int(False) => 0


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

2007-08-03 Thread Forest Bond
On Fri, Aug 03, 2007 at 08:57:10PM -, [EMAIL PROTECTED] wrote:
> For anyone trying this, I had to make it
> old_self = self.__class__.objects.get(id = self.id)
> instead of
> old_self = self.__class__.get(id = self.id)

Right, that's what I meant :)

-Forest
-- 
Forest Bond
http://www.alittletooquiet.net



signature.asc
Description: Digital signature


Re: mod_python/django problems

2007-08-03 Thread Graham Dumpleton

On Aug 3, 9:16 pm, Aljosa Mohorovic <[EMAIL PROTECTED]>
wrote:
> on few blogs/web sites it is stated that > 30 django sites on one
> server running apache/mod_pythonhave some issues, like untraceable
> errors and wrong site displaying for some domain.
> any comments on this?
>
> i have many small php sites that will eventually became django sites,
> how should i deploy?

For a related discussion on why running multiple sites, even if in
distinct sub interpreters, using mod_python or embedded mode of
mod_wsgi can cause problems, see:

  http://blog.dscpl.com.au/2007/07/web-hosting-landscape-and-modwsgi.html

In short however, the main problems are as follows:

1. A C extension module is loaded only once per process no matter how
many sub interpreters there are. Thus, if different applications try
and load different versions of a C extension module problems will
arise in the use of that module. This is because the first application
to load its version will win, and other applications using different
versions may find their Python wrapper code for that extension module
will not match, leading to fatal or subtle problems.

2. Some C extension modules are not written properly so as to cope
with being able to be used from multiple sub interpreters at the same
time. Problems can be caused by the C extension module caching data
from one sub interpreter then using it in a different sub interpreter.
This may result in mixing of data between sub interpreters, if for
example each applications is modifying the cached data. If the cached
data is a Python class type from which object instances are created,
then objects created from it which are passed to a different sub
interpreter will fail isinstance() checks and potentially use the
wrong code base. This latter problem has been found with psycopg2 and
will affect Django from subversion repository.

In other words, if all your applications use exactly the same code
base and thus versions of C extension modules you may be okay, but not
if the C extension modules haven't been written properly to work with
multiple sub interpreters.

The safest way is to use a mechanism whereby each application is run
in a different process. This is why fastcgi solutions work okay, as
they force this behaviour. The other alternative now also available
for Apache is to use daemon mode of mod_wsgi (www.modwsgi.org). This
also optionally allows applications to be delegated to a distinct
process, thereby ensuring they can't interfere with other
applications. For specific notes on using Django with mod_wsgi see:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

Also see:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac

which includes some more interesting examples of using mod_wsgi daemon
mode with lots of sites.

If using mod_python, would also in general suggest that you ensure you
are using mod_python 3.3.1 and not some older version.

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



Windows XP tips and tricks

2007-08-03 Thread Vladimir Rakita
Windows XP tips and tricks. Learn how to bypass very common windows
problems, to speed up your system and make it more reliable with useful tips
and tricks.

http://windowsxpsp2pro.blogspot.com

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



Re: Trouble with installing stockphoto

2007-08-03 Thread Danno

Thanks for gettin back to me!

I got that part figured out.  Thank you!

On Aug 2, 2:18 am, yml <[EMAIL PROTECTED]> wrote:
> Hello,
>
> It looks like your "base.html" is in a folder which is not defined in
> the "TEMPLATE_DIRS". In order to fix your problem you should add this
> directory to this tuple.
> I hope that help
>
> On Aug 2, 5:38 am, Danno <[EMAIL PROTECTED]> wrote:
>
> > So I was able to import everything it looks like ok, but when i go 
> > tohttp://localhost/stockphoto/
>
> > it is giving me the following error:
> > TemplateSyntaxError at /stockphoto/
> > Template u'base.html' cannot be extended, because it doesn't exist
>
> > So I navigate to my installedstockphotoat c:/python25/Lib/site-
> > packages/stockphoto/templates/stockphoto/base.html and sure enough the
> > only thing in it is {% extends "base.html" %}
> > It is trying to extend itself as far as I can tell.
>
> > Any help on this would be extremely appreciated, Thank you!
>
> > Rocksteady,
> > Danno~
>
> > On Aug 1, 2:17 am, Danno <[EMAIL PROTECTED]> wrote:> I am having a bit of 
> > trouble 
> > installingstockphoto(http://www.carcosa.net/jason/software/django/stockphoto/README.html)
>
> > > I am wanting to try out just the functionality of the app itself, not
> > > yet integrating it with a current project and am running into a few
> > > errors.  Here is my work flow as to how I've set up a new project to
> > > havestockphoto:
>
> > > I downloaded thestockphoto-0.2.tar.gz, uncompressed it and have the
> > > folderstockphoto-0.2 in c:/django/stockphoto-0.2
>
> > > command line>cd : c\django
>
> > > c\django> manage.py startproject testproject
>
> > > from here, I have tried multiple ways toinstallstockphoto as an app
> > > inside the c:/django/testproject/ directory and i just can't get it.
>
> > > Any and all help you can give this newbie will be extremely
> > > appreciative.  Thank you guys!
>
> > > Rocksteady,
> > > Danno~


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



Error was: 'module' object has no attribute 'process_register'

2007-08-03 Thread Fabien Schwob

Hello,

I'm currently rewriting a website to take advantage of the new new
features of the trunk. I'm using named urls and the {% url  %}
tag. But from time to time, I get the following errors :

ViewDoesNotExist at /
Tried process_register in module chibbi.club.views. Error was:
'module' object has no attribute 'process_register'

Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: ViewDoesNotExist
Exception Value:Tried process_register in module chibbi.club.views.
Error was: 'module' object has no attribute 'process_register'
Exception Location:
C:\Python25\Lib\site-packages\django\core\urlresolvers.py in
_get_callback, line 184
Python Executable:  C:\Python25\python.exe
Python Version: 2.5.0

The problem is raised when the template encounter the following tag :
{% url clubber-public-profil connected.user %}

I've the problem on :
* Django : trunk (I've make an svn up today) / Python : 2.5 / DB: Sqlite
* Django : trunk (from ~1 week) / Python : 2.4.4 / DB: Sqlite

Does someone know how to solve this issue ?

Thanks

-- 
Fabien SCHWOB

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

2007-08-03 Thread Tyson Tate

On Aug 3, 2007, at 2:29 PM, [EMAIL PROTECTED] wrote:

> I have a template directory having home.html in it.  home.html has
> , but the
> server always 404s the css _only_, whether it is written as home.css
> or ./home.css.
> Emphasizing here that home.html and home.css are in the same directory
> but the server is not finding the latter.
> Is this a problem wih direct_to_template? Should I be using a simple
> view? Or django.contrib.flatpages?

You're not telling Django where to find your CSS file. Read this:

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

And you should be on your way.

-Tyson

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Do I have to send shopping cart data to every template in my app?

2007-08-03 Thread oggie rob

If you really need to use a tag, look at
http://www.djangoproject.com/documentation/templates_python/#passing-template-variables-to-the-tag
But I think you probably would find it easier to add an extra context
processor & avoid the tag altogether.

 -rob

On Aug 3, 6:01 am, Greg <[EMAIL PROTECTED]> wrote:
> Thanks for your help...I'm now able to create a custom tag.  However,
> I now seem to have a another problem with custom tags.  How do I send
> session information to each template.   I can't use
> request.session['cart'] in my custom tag function because it doesn't
> have a request parameter.  I always get the error 'global name request
> is not defined'


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



css 404?

2007-08-03 Thread [EMAIL PROTECTED]

I've got a seemingly simple setup that I'm having problems with.  The
urlconf is:
==
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('',
# Example:
# (r'^home/', include('home.foo.urls')),

# Uncomment this for admin:
(r'^$', direct_to_template, {'template': 'home.html'}),
(r'^admin/', include('django.contrib.admin.urls')),
(r'^blog/$', include('home.blog.urls')),

==
I have a template directory having home.html in it.  home.html has
, but the
server always 404s the css _only_, whether it is written as home.css
or ./home.css.
Emphasizing here that home.html and home.css are in the same directory
but the server is not finding the latter.
Is this a problem wih direct_to_template? Should I be using a simple
view? Or django.contrib.flatpages?
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: Compare column entries in database query

2007-08-03 Thread [EMAIL PROTECTED]

Hi Russ!

Thanks for the info! Saves me from trying around more.

Yours,
Thomas

On Aug 2, 1:25 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 8/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > I want to find all entries in a database where two specific fields are
> > equal:
>
> > mytable.objects.filter(column_a='column_b')
>
> At present, the answer is unfortunately 'you can't do this' (unless
> you use a hack like the one you mentioned).
>
> I've had a few ideas on how to fix this; however, fixing this area of
> code would require changes to an area that is currently undergoing a
> major refactor. Once the query engine changes are complete, I have a
> number of issues to address - this is one of them.
>
> 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: Only save if changed?

2007-08-03 Thread [EMAIL PROTECTED]

On Aug 3, 3:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Thanks!
>
> On Aug 3, 3:04 pm, Forest Bond <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Aug 03, 2007 at 07:37:17PM -, [EMAIL PROTECTED] wrote:
>
> > > In my site_users model (which extends auth user), I've got:
>
> > >  def save(self):
> > > self.geocode = self.get_geocode()
> > > super(SiteUser, self).save() # Call the "real" save() method.
>
> > > get_geocode makes a call out to google's geocoding service, gives the
> > > city and state, and returns the geocode. Since there's a lot of
> > > activity on site_users, updating for board post counts and all sorts
> > > of other things, I don't want to call get_geocode unless city and
> > > state have actually changed.
>
> > def save(self):
> > if self.id is not None:
> > old_self = self.__class__.get(id = self.id)
> > if self.id is None or (old_self.city != self.city) or (
> >   old_self.state != self.state):
> > self.geocode = self.get_geocode()
> > super(SiteUser, self).save()
>
> > -Forest
> > --
> > Forest Bondhttp://www.alittletooquiet.net
>
> >  signature.asc
> > 1KDownload

For anyone trying this, I had to make it
old_self = self.__class__.objects.get(id = self.id)
instead of
old_self = self.__class__.get(id = self.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: Only save if changed?

2007-08-03 Thread [EMAIL PROTECTED]

Thanks!

On Aug 3, 3:04 pm, Forest Bond <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 03, 2007 at 07:37:17PM -, [EMAIL PROTECTED] wrote:
>
> > In my site_users model (which extends auth user), I've got:
>
> >  def save(self):
> > self.geocode = self.get_geocode()
> > super(SiteUser, self).save() # Call the "real" save() method.
>
> > get_geocode makes a call out to google's geocoding service, gives the
> > city and state, and returns the geocode. Since there's a lot of
> > activity on site_users, updating for board post counts and all sorts
> > of other things, I don't want to call get_geocode unless city and
> > state have actually changed.
>
> def save(self):
> if self.id is not None:
> old_self = self.__class__.get(id = self.id)
> if self.id is None or (old_self.city != self.city) or (
>   old_self.state != self.state):
> self.geocode = self.get_geocode()
> super(SiteUser, self).save()
>
> -Forest
> --
> Forest Bondhttp://www.alittletooquiet.net
>
>  signature.asc
> 1KDownload


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

2007-08-03 Thread Forest Bond
On Fri, Aug 03, 2007 at 07:37:17PM -, [EMAIL PROTECTED] wrote:
> 
> In my site_users model (which extends auth user), I've got:
> 
>  def save(self):
> self.geocode = self.get_geocode()
> super(SiteUser, self).save() # Call the "real" save() method.
> 
> get_geocode makes a call out to google's geocoding service, gives the
> city and state, and returns the geocode. Since there's a lot of
> activity on site_users, updating for board post counts and all sorts
> of other things, I don't want to call get_geocode unless city and
> state have actually changed.

def save(self):
if self.id is not None:
old_self = self.__class__.get(id = self.id)
if self.id is None or (old_self.city != self.city) or (
  old_self.state != self.state):
self.geocode = self.get_geocode()
super(SiteUser, self).save()

-Forest
-- 
Forest Bond
http://www.alittletooquiet.net


signature.asc
Description: Digital signature


Re: Job Fair F/OSS project

2007-08-03 Thread [EMAIL PROTECTED]

Well, all that stuff is still up in the air. This is the very-very
beginning of the project.

I think the first thing I'd like to do is to setup a site, like google
code or sourceforge. If anyone has a suggestion about which one is
better, that'd be great. I know they all use SVN (I use Git), so
that's not a factor. It's also possible for me to just setup a Trac
site (I'm most likely gonna setup one anyhow) like I've been using
with my previous internal projects and forego sourceforge and google
code.

On Aug 3, 5:12 am, "Chris Hoeppner" <[EMAIL PROTECTED]> wrote:
> What kind of volunteers do are you looking for? What kind of tasks are
> you looking to resolve?
>
> If I could have some more details (maybe have a look at the proposed
> timeline) I'd be in :)
>
> 2007/8/3, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
>
>
>
> > I'm looking for some volunteers for a new open source project. At the
> > Institute of Design (http://www.id.iit.edu), our next project is a
> > system for the management of our job fair (http://www.id.iit.edu/
> > recruitID/ )
>
> > The systems goal is to allow students and employers to enter their
> > availability for interviews and have the system designate times and
> > rooms for each to meet for interviews. The system includes much more
> > than just this of course, but that is the main goal. We decided that
> > this application is generic enough that it should be made into an F/
> > OSS project.
>
> > So far the system will be built on Django and uses (hopefully)
> > Prototype.js
>
> > I've only really been using Django for a month now so anyone with real
> > experience would be appreciated.
>
> > The project is on the ground floor and some basic wire frames and a
> > few other preliminary designs.
>
> > I'm personally located in Chicago and West Virginia (about half of my
> > time spent in each place), though you are welcome to help out from
> > anywhere around the world!
>
> > If you're interested, reply to this message, or contact me at cezar AT
> > id.iit.edu
>
> --
> Best Regards,
> Chris Hoeppner -www.pixware.org// My weblog


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



Only save if changed?

2007-08-03 Thread [EMAIL PROTECTED]

In my site_users model (which extends auth user), I've got:

 def save(self):
self.geocode = self.get_geocode()
super(SiteUser, self).save() # Call the "real" save() method.

get_geocode makes a call out to google's geocoding service, gives the
city and state, and returns the geocode. Since there's a lot of
activity on site_users, updating for board post counts and all sorts
of other things, I don't want to call get_geocode unless city and
state have actually changed.

Is there a way to check if they've changed. I know there's an
ifchanged filter for templates, but don't know about this.

Or should I move it to the update profile view, and only get geocode
when they actually update their profile?


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



Re: Queryset of instances bound to particular ForeignKey

2007-08-03 Thread Benjamin Goldenberg

Hi Colin,
The problem is that there are multiple ForeignKeys in A bound to
instances of B, but I only want the instances of B bound to a specific
foreignkey. Does that make sense?

-Benjamin

On Aug 3, 12:17 am, Collin Grady <[EMAIL PROTECTED]> wrote:
> I feel silly for not trying this earlier, but it appears to work :)
>
> >>> B.objects.filter(a__isnull=False)
>
> [, ]
>
> Models used for this test:http://dpaste.com/15931/


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

2007-08-03 Thread James Tauber

Great, I'll start something at Google Code Project Hosting and  
whatever you (or anyone else) can help with will be most welcome.

django-mailer will probably be the project name.

James


On 03/08/2007, at 5:12 PM, Jacob Kaplan-Moss wrote:

>
> On 8/3/07, James Tauber <[EMAIL PROTECTED]> wrote:
>> I was thinking of developing a django app for this with support for
>> queuing and throttling of sends, scheduled sends, and logging of mail
>> failures. I'm NOT interested at all in using it for unsolicited email
>> (although unfortunately there's nothing in the design I have in mind
>> that would prevent its use for that, I don't think)
>>
>> But I wanted to check first if anyone has developed something like  
>> this?
>
> We've got something internally (as part of Ellington) that handles
> these sorts of tasks, but it's somewhat half-assed. If you wanted to
> start a public project, I can probably kick in some of the more
> fully-assed parts of our code.
>
> I'd have to check with management, of course, but given our track
> record and our need for a robust email system I'm pretty sure the
> answer'll be yes.
>
> Jacob
>
> >


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



Re: django app for managing sending email to users...

2007-08-03 Thread James Tauber

On 03/08/2007, at 5:55 PM, Bram - Smartelectronix wrote:
> I'm exactly in the same situation, with the same needs for
> splicemusic.com. Right now I have a big loop which goes over all  
> users,
> and for each user checks if there are any new events that happened.
>
> This scales really badly, and would definitely need some kind of  
> fix, so
> I'm very interested in any solutions you guys might come up with.

With a mail out system like I've described, would you envisage being  
able to queue the email *at the time the event happens* rather than  
looping over the users?

If so, I assume you'd expect the mail out system to consolidate  
multiple events if they occurred within a set period of time.

So in other words, the system would allow queuing of not only entire  
emails, but components of an email (let's call them "sub-messages")  
and when some threshold is reached (either time passed or number of  
sub-messages queued up) an email is constructed and sent.

James

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

2007-08-03 Thread Doug Van Horn

On Aug 3, 11:50 am, Doug Van Horn <[EMAIL PROTECTED]> wrote:
> On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
> wrote:
[snip]

You see, you learn something new every day.  Based on Nis Jørgensen's
post above, here's a refined age function using the fancy tuple
comparison I didn't know about:

>>> def age(d, bday):
... return (d.year - bday.year) - \
... ((d.month, d.day) < (bday.month, bday.day) and 1 or 0)

This new function has the added bonus of having the argument names
correct.  :-)


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



Re: django app for managing sending email to users...

2007-08-03 Thread Bram - Smartelectronix

Jacob Kaplan-Moss wrote:
> On 8/3/07, James Tauber <[EMAIL PROTECTED]> wrote:
>> I was thinking of developing a django app for this with support for
>> queuing and throttling of sends, scheduled sends, and logging of mail
>> failures. I'm NOT interested at all in using it for unsolicited email
>> (although unfortunately there's nothing in the design I have in mind
>> that would prevent its use for that, I don't think)
>>
>> But I wanted to check first if anyone has developed something like this?
> 
> We've got something internally (as part of Ellington) that handles
> these sorts of tasks, but it's somewhat half-assed. If you wanted to
> start a public project, I can probably kick in some of the more
> fully-assed parts of our code.
> 
> I'd have to check with management, of course, but given our track
> record and our need for a robust email system I'm pretty sure the
> answer'll be yes.

I'm exactly in the same situation, with the same needs for 
splicemusic.com. Right now I have a big loop which goes over all users, 
and for each user checks if there are any new events that happened.

This scales really badly, and would definitely need some kind of fix, so 
I'm very interested in any solutions you guys might come up with.


  - bram

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

2007-08-03 Thread Doug Van Horn

On Aug 3, 6:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Hey Everyone,
>
> does anyone have a good age in years calculation function for usage with
> datetime.date that returns the age in nr of years of a person?
>
> We were using:
>
> def get_age(self):
> now = datetime.today()
> birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> return now.year - self.birthday.year - (birthday > now)
>
> But the trouble is that this fails for people whose birthday falls on a
> leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) )
>
> For now I swaped to:
>
> try:
>   birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> except ValueError:
>   birthday = datetime(now.year, self.birthday.month, self.birthday.day-1)
>
> But that seems such a hack :-))
>
>   - bram

Not sure how pretty it is, but this seems to work:

>>> def age(d, bday):
... return (now.year - bday.year) - \
... ((now.month < bday.month) or \
... (now.month == bday.month and now.day < bday.day) and 1 or
0)
...
>>> now = datetime.date(2007, 1, 1)
>>> bday = datetime.date(1980, 2, 29)
>>> age(now, bday)
26
>>> now = datetime.date(2007, 3, 1)
>>> age(now, bday)
27


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

2007-08-03 Thread Nis Jørgensen

Lucky B skrev:
> how about surrounding the statement with a try and work the leap year
> to regular year case with the exception?
That seems like overkill. There isn't really any leap-year handling
necessary:

import datetime.date as date

def age (d1, d2=None):
if not d2:
d2 = date.today()
years = d2.year - d1.year
if (d2.month,d2.day) < (d1.month,d1.day):
years -= 1
return years

Nis

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

2007-08-03 Thread Jacob Kaplan-Moss

On 8/3/07, James Tauber <[EMAIL PROTECTED]> wrote:
> I was thinking of developing a django app for this with support for
> queuing and throttling of sends, scheduled sends, and logging of mail
> failures. I'm NOT interested at all in using it for unsolicited email
> (although unfortunately there's nothing in the design I have in mind
> that would prevent its use for that, I don't think)
>
> But I wanted to check first if anyone has developed something like this?

We've got something internally (as part of Ellington) that handles
these sorts of tasks, but it's somewhat half-assed. If you wanted to
start a public project, I can probably kick in some of the more
fully-assed parts of our code.

I'd have to check with management, of course, but given our track
record and our need for a robust email system I'm pretty sure the
answer'll be yes.

Jacob

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



Re: mod_python/django problems

2007-08-03 Thread Jacob Kaplan-Moss

On 8/3/07, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote:
> on few blogs/web sites it is stated that > 30 django sites on one
> server running apache/mod_python have some issues, like untraceable
> errors and wrong site displaying for some domain.
> any comments on this?

When something like this happens, it's usually because of a missing
PythonInterpreter and/or DJANGO_SETTINGS_MODULE directive.

We've had far more than 30 sites on a single Apache, no problems. I
use the past-tense since we've started running multiple instances of
Apache (instead of one monolithic one with many vhosts) so that we
have greater granular control over each individual site.

Jacob

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



Amazon S3 and S3FileField

2007-08-03 Thread John-Scott

Is anyone out there using S3FileField (http://code.djangoproject.com/
wiki/AmazonSimpleStorageService) in their models to interface with
Amazon's S3 service?

I've saved the code from the above url into a file 'amazon_s3.py' in
my project directory (e.g. /amazon_s3.py) and I've saved
the Amazon code from 
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=134=47
into /amazon/. I've set the DEFAULT_BUCKET value in my
settings file but I'm trying to figure out how to set the key for the
S3FileField. There is a method called 'set_key' which apparently does
this, but I don't know how to set this value in my model.
My model currently looks something like this (and validates, so all
the import statements seem to be in working order):

from django.db import models
from my_project.amazon_s3 import S3FileField
class Photo(models.Model):
photo_file = S3FileField()

I would like to be able to set the key so that each file would be
accessible from a url like 
http://s3.amazonaws.com//media/img/photo.jpg,
that is, I want to set the key to "/media/img/" + file_name

I have another question about the code from the wiki page. There is a
keyword argument 'upload_to="s3"':

class S3FileField(models.FileField):
def __init__(self, verbose_name=None, name=None, bucket='',
is_image=False, **kwargs):
models.FileField.__init__(self, verbose_name, name,
upload_to="s3", **kwargs)

What does the value assigned to upload_to mean in the context of S3
storage?

Any tips appreciated.

Cheers,
John-Scott


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



Re: mod_python/django problems

2007-08-03 Thread Aljosa Mohorovic

On Aug 3, 3:06 pm, David Reynolds <[EMAIL PROTECTED]> wrote:
> We have around 30 and have noticed the problems you've mentioned..

anybody on list knows if there is any progress on this issue, will it
be resolved?
i know lighttpd is good but i still want to know if this issue with
apache will be resolved.

Aljosa


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

2007-08-03 Thread Lucky B

how about surrounding the statement with a try and work the leap year
to regular year case with the exception?

On Aug 3, 10:16 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Jonathan Buchanan wrote:
>
>  >
>
> >http://toys.jacobian.org/presentations/2007/oscon/tutorial/
>
> > Slide 14, unit tests too! :)
>
>  >>> dob = date(1980,2,29)
>  >>> dob.replace(year=2007)
> Traceback (most recent call last):
>File "", line 1, in 
> ValueError: day is out of range for month
>
> it ain't a particularly useful unit test in my case ;-)))
>
>   - bram


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

2007-08-03 Thread James Tauber

A number of sites I'm working on will optionally notify users of  
certain events via email. Think of the email you get from a social  
networking site when someone wants to add you as a friend. Or forum  
software that emails subscribers to a thread when there's been a new  
post. I also have the occasional need to send administrative email to  
all users on a site or announcements to those that have opted-in to  
receive them (although my own preference in that case is for there to  
be an Atom feed).

I was thinking of developing a django app for this with support for  
queuing and throttling of sends, scheduled sends, and logging of mail  
failures. I'm NOT interested at all in using it for unsolicited email  
(although unfortunately there's nothing in the design I have in mind  
that would prevent its use for that, I don't think)

But I wanted to check first if anyone has developed something like this?

James

(cross-posted to django-hotclub as it's a potentially useful addition  
to the nascent Hot Club of France suite of apps)

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

2007-08-03 Thread Todd O'Bryan

I've been using fixtures to create test data, but how do I set user
permissions that aren't brittle? If I use

./manage.py dumpdata

it dumps the user_permissions as a list of ids of permissions the user
has. The problem is, as I add more apps/permissions to my project, those
ids are likely to change and my test data will end up invalid.

Is there some way to specify a permission by name in a fixture or some
easier way to do this that I'm missing?

Todd


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



ANN: New alpha backend for MS Sql Server

2007-08-03 Thread mamcxyz

If want/need support for mssql, I hope this help.

I submit a ticket with patchs for enable a new backend for sql server,
so we can have
a clean direction from the ado_mssql confusion of tickets, and have a
single point for development.

Is at http://code.djangoproject.com/ticket/5062.

I'm working in emulate the non-standar limit/offset thing based on the
oracle backend implementation.

Please take a look, test and inform me if works ;)


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



Re: Question about upload / FileField

2007-08-03 Thread !张沈鹏(电子科大 08年毕业)
In there , my filefield is required . Yes , you must upload a file .
How can I reach this aim ?

2007/8/3, Thomas Guettler <[EMAIL PROTECTED]>:
>
> Am Freitag, 3. August 2007 15:34 schrieb ZhangshenPeng:
> > Question 1:
> >
> > When I removed "blank=True" from FileField ,then use below method
> > to upload file , but no matter whether your choosed file , the from
> > valid will report error "This field is required."
>
> All newforms Fields habe a keyword argument called "required".
> Use required=False
>
> >
>


-- 
欢迎访问我的博客:
http://zsp.javaeye.com/

--张沈鹏

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



Re: get object qs with certain generic relation

2007-08-03 Thread Bram - Smartelectronix

Jonathan Buchanan wrote:

> class Flag(models.Model):
> objects = FlagManager()
> 
> Usage::
> 
> songs = Flag.objects.get_by_model_and_flag_type(Song, 'illegal')

Thanks a lot Jonathan...

I guess I should adding custom managers to all my classes containing 
generic relations!

  - bram

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

2007-08-03 Thread Landlord Bulfleet
Hi,

I have to organize a single sign-on between a django and a tomcat (with
Acegi Security)

Any suggestions are appreciated :)

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: age in years calculation

2007-08-03 Thread Bram - Smartelectronix

Jonathan Buchanan wrote:
 >
> http://toys.jacobian.org/presentations/2007/oscon/tutorial/
> 
> Slide 14, unit tests too! :)

 >>> dob = date(1980,2,29)
 >>> dob.replace(year=2007)
Traceback (most recent call last):
   File "", line 1, in 
ValueError: day is out of range for month


it ain't a particularly useful unit test in my case ;-)))


  - bram

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

2007-08-03 Thread Thejaswi Puthraya

> Is there a way I can add some attributes to the User model in
> django.contrib.auth.models and also have those new attributes render
> in admin?

Probably you should have a look at Django-Registrationbetter to
hack on this than directly on django.contrib.auth.models.
See http://code.google.com/p/django-registration for more details.

Cheers
Thejaswi Puthraya


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

2007-08-03 Thread Thomas Guettler

Am Freitag, 3. August 2007 15:34 schrieb ZhangshenPeng:
> Question 1:
>
> When I removed "blank=True" from FileField ,then use below method
> to upload file , but no matter whether your choosed file , the from
> valid will report error "This field is required."

All newforms Fields habe a keyword argument called "required".
Use required=False

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



(another) admin and edit_inline

2007-08-03 Thread Lic. José M. Rodriguez Bacallao
Why when I have a model edited inline other (for example, Model B is edited
inline model A, admin is for model A) and model B have a DateTimeField field
with auto_now_add = True (creation_date = DateTimeField(auto_now_add = True)
), when I save the model the second time, it raise this error:
app_name_model_B.creation_date may not be NULL.
Is this normal? What can I do?

-- 
Lic. José M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic por
profesionales
-

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



Question about upload / FileField

2007-08-03 Thread ZhangshenPeng

Question 1:

When I removed "blank=True" from FileField ,then use below method
to upload file , but no matter whether your choosed file , the from
valid will report error "This field is required."

How can FileField work with newform without blank=True ?

def file_fix_callback(field, **kwargs):
if isinstance(field, models.FileField):
return field.formfield(widget=forms.FileInput(),**kwargs)
else:
return field.formfield(**kwargs)

Form=form_for_model(model,formfield_callback=file_fix_callback)
.

Question 2:
How to limit the size of upload files.


At last , thanks to the django authors . It's really a great
framework :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Do I have to send shopping cart data to every template in my app?

2007-08-03 Thread Greg

Thanks for your help...I'm now able to create a custom tag.  However,
I now seem to have a another problem with custom tags.  How do I send
session information to each template.   I can't use
request.session['cart'] in my custom tag function because it doesn't
have a request parameter.  I always get the error 'global name request
is not defined'

Thanks for you help

On Aug 2, 1:37 am, oggie rob <[EMAIL PROTECTED]> wrote:
> On Aug 1, 11:22 pm, oggie rob <[EMAIL PROTECTED]> wrote:
>
> > This is what middleware is made 
> > for.http://www.djangoproject.com/documentation/middleware/
>
> >  -rob
>
> Sorry, I have recently been working withshoppingcarts and had
> redirection onmybrain. Fabien's suggestion is probably what you are
> after.
>
>  Thob


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

2007-08-03 Thread David Reynolds


On 3 Aug 2007, at 1:58 pm, Aljosa Mohorovic wrote:



On Aug 3, 1:47 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:

On 03-Aug-07, at 4:46 PM, Aljosa Mohorovic wrote:
is this an official bug? I havent heard of it - although i have a
server with about 10 sites and have found one site once or twice


i'm asking because i don't know. i'm not trying to spread FUD but my
impressions are that people use mod_python for 1, maybe 2 django apps
per server. i have a situation where i have many small sites.
anybody here using mod_python for larger number of sites per server?


We have around 30 and have noticed the problems you've mentioned..

Thanks,

Dave

--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Re: mod_python/django problems

2007-08-03 Thread Matt Davies
We've got over 70 sites running on lighttpd, no problems at all.

Why apache?

On 03/08/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
>
> On 03-Aug-07, at 4:46 PM, Aljosa Mohorovic wrote:
>
> > on few blogs/web sites it is stated that > 30 django sites on one
> > server running apache/mod_python have some issues, like untraceable
> > errors and wrong site displaying for some domain.
> > any comments on this?
>
> is this an official bug? I havent heard of it - although i have a
> server with about 10 sites and have found one site once or twice
> mixing with another in admin. But it was only in my browser, and
> since username and password were the same for both sites I felt it
> was a browser cache problem - and it was only for the initial display
> in admin. None of the users of the sites ever saw anything of this.
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
>
>
>
> >
>

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



Re: mod_python/django problems

2007-08-03 Thread Aljosa Mohorovic

On Aug 3, 1:47 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 03-Aug-07, at 4:46 PM, Aljosa Mohorovic wrote:
> is this an official bug? I havent heard of it - although i have a
> server with about 10 sites and have found one site once or twice

i'm asking because i don't know. i'm not trying to spread FUD but my
impressions are that people use mod_python for 1, maybe 2 django apps
per server. i have a situation where i have many small sites.
anybody here using mod_python for larger number of sites per server?

Aljosa


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

2007-08-03 Thread Jonathan Buchanan

> '%s.%s = %s.object_id' %
> (backend.quote_name(Model._meta.db_table),
>
> backend.quote_name(Model._meta.pk.column),
>   rel_table)

Aargh, mangled by Gmail - these lines should look like this (with the
proper level of indentation applied):

'%s.%s = %s.object_id' % (backend.quote_name(Model._meta.db_table),
 backend.quote_name(Model._meta.pk.column),
 rel_table)

Jonathan.

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

2007-08-03 Thread Jonathan Buchanan

> I have a generic relation Flag, with a FlagType:
>
> class FlagType(models.Model):
>  name = models.CharField(maxlength=50)
>  description = models.TextField()
>
> class Flag(models.Model):
>  type = models.ForeignKey(FlagType) # type of flag
>  content_type = models.ForeignKey(ContentType)
>  object_id = models.PositiveIntegerField()
>  content_object = generic.GenericForeignKey()
>  user = models.ForeignKey(User)
>  created = models.DateTimeField()
>
> So, for example "illegal" or "to feature" would be flags. Now we're
> flagging Song objects and I would like a queryset that gets me all Songs
> flagged with a flag of type "illegal".
>
> I can do:
>
>flag = FlagType.objects.get(name='illegal')
>ctype = ContentType.objects.get_for_model(Song)
>flagged = Flag.objects.filter(type=flag,
>content_type=ctype).order_by('-created')
>songs = [item.content_object for item in flagged ]
>
> But the problem is: I can't do extra things to this list like order_by()
> or an extra filter() or exclude().
>
> How can I get the same result, but still have a queryset (containing
> Songs) instead of a list??

This looks similar to what the TaggedItemManager needs to do in
django-tagging [1] - here's a completely untested, adapted version of
its get_by_model method - does this work for you?

models.py::

from django.contrib.contenttypes.models import ContentType
from django.db import backend, models

class FlagManager(models.Manager):
def get_by_model_and_flag_type(self, Model, type_name):
"""
Create a ``QuerySet`` containing instances of the given model
class associated with a ``FlagType`` with the given name.
"""
flag_type = FlagType.objects.get(name=type_name)
ctype = ContentType.objects.get_for_model(Model)
rel_table = backend.quote_name(self.model._meta.db_table)
return Model._default_manager.extra(
tables=[self.model._meta.db_table], # Use a non-explicit join
where=[
'%s.content_type_id = %%s' % rel_table,
'%s.type_id = %%s' % rel_table,
'%s.%s = %s.object_id' %
(backend.quote_name(Model._meta.db_table),

backend.quote_name(Model._meta.pk.column),
  rel_table)
],
params=[ctype.id, flag_type.id],
)

class Flag(models.Model):
...

objects = FlagManager()


Usage::

songs = Flag.objects.get_by_model_and_flag_type(Song, 'illegal')

Regards,
Jonathan.

[1] http://code.google.com/p/django-tagging/

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

2007-08-03 Thread Niels

Interesting. Would this work??

(now - birthday).days * 100 / 36524

Niels

On Aug 3, 1:45 pm, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
> On 8/3/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hey Everyone,
>
> > does anyone have a good age in years calculation function for usage with
> > datetime.date that returns the age in nr of years of a person?
>
> > We were using:
>
> > def get_age(self):
> > now = datetime.today()
> > birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> > return now.year - self.birthday.year - (birthday > now)
>
> > But the trouble is that this fails for people whose birthday falls on a
> > leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) )
>
> > For now I swaped to:
>
> > try:
> >   birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> > except ValueError:
> >   birthday = datetime(now.year, self.birthday.month, self.birthday.day-1)
>
> > But that seems such a hack :-))
>
> >   - bram
>
> http://toys.jacobian.org/presentations/2007/oscon/tutorial/
>
> Slide 14, unit tests too! :)
>
> Jonathan.


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

2007-08-03 Thread daev

You can create Profile model that can have all additional fields. Then
connect it in settings.py to User model with AUTH_PROFILE_MODULE =
"profiles.Profile". And you can get per user profile like this:
user = User.objects.get( username = "foobar" )
profile = user.get_profile()


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

2007-08-03 Thread [EMAIL PROTECTED]

On Aug 3, 1:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Aug 3, 12:54 pm, Bram - Smartelectronix <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > hello all,
>
> > I have a generic relation Flag, with a FlagType:
>
> > class FlagType(models.Model):
> >  name = models.CharField(maxlength=50)
> >  description = models.TextField()
>
> > class Flag(models.Model):
> >  type = models.ForeignKey(FlagType) # type of flag
> >  content_type = models.ForeignKey(ContentType)
> >  object_id = models.PositiveIntegerField()
> >  content_object = generic.GenericForeignKey()
> >  user = models.ForeignKey(User)
> >  created = models.DateTimeField()
>
> > So, for example "illegal" or "to feature" would be flags. Now we're
> > flagging Song objects and I would like a queryset that gets me all Songs
> > flagged with a flag of type "illegal".
>
> > I can do:
>
> >flag = FlagType.objects.get(name='illegal')
> >ctype = ContentType.objects.get_for_model(Song)
> >flagged = Flag.objects.filter(type=flag,
> >content_type=ctype).order_by('-created')
> >songs = [item.content_object for item in flagged ]
>
> > But the problem is: I can't do extra things to this list like order_by()
> > or an extra filter() or exclude().
>
> > How can I get the same result, but still have a queryset (containing
> > Songs) instead of a list??
>
> >   - bram
>
> songs = Song.objects.filter(id__in=[item.content_object.id for item in
> flagged])
>
> .. would hit the DB again .. but requires little code.
>
> Post back if another hit isn't a viable option and we'll take a closer
> look at the problem.

... item.object_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: mod_python/django problems

2007-08-03 Thread Kenneth Gonsalves


On 03-Aug-07, at 4:46 PM, Aljosa Mohorovic wrote:

> on few blogs/web sites it is stated that > 30 django sites on one
> server running apache/mod_python have some issues, like untraceable
> errors and wrong site displaying for some domain.
> any comments on this?

is this an official bug? I havent heard of it - although i have a  
server with about 10 sites and have found one site once or twice  
mixing with another in admin. But it was only in my browser, and  
since username and password were the same for both sites I felt it  
was a browser cache problem - and it was only for the initial display  
in admin. None of the users of the sites ever saw anything of this.

-- 

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



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



Re: age in years calculation

2007-08-03 Thread Jonathan Buchanan

On 8/3/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> Hey Everyone,
>
>
> does anyone have a good age in years calculation function for usage with
> datetime.date that returns the age in nr of years of a person?
>
> We were using:
>
> def get_age(self):
> now = datetime.today()
> birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> return now.year - self.birthday.year - (birthday > now)
>
> But the trouble is that this fails for people whose birthday falls on a
> leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) )
>
> For now I swaped to:
>
> try:
>   birthday = datetime(now.year, self.birthday.month, self.birthday.day)
> except ValueError:
>   birthday = datetime(now.year, self.birthday.month, self.birthday.day-1)
>
> But that seems such a hack :-))
>
>
>   - bram

http://toys.jacobian.org/presentations/2007/oscon/tutorial/

Slide 14, unit tests too! :)

Jonathan.

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



age in years calculation

2007-08-03 Thread Bram - Smartelectronix

Hey Everyone,


does anyone have a good age in years calculation function for usage with 
datetime.date that returns the age in nr of years of a person?

We were using:

def get_age(self):
now = datetime.today()
birthday = datetime(now.year, self.birthday.month, self.birthday.day)
return now.year - self.birthday.year - (birthday > now)

But the trouble is that this fails for people whose birthday falls on a 
leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) )

For now I swaped to:

try:
  birthday = datetime(now.year, self.birthday.month, self.birthday.day)
except ValueError:
  birthday = datetime(now.year, self.birthday.month, self.birthday.day-1)

But that seems such a hack :-))


  - bram

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

2007-08-03 Thread [EMAIL PROTECTED]

On Aug 3, 12:54 pm, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> hello all,
>
> I have a generic relation Flag, with a FlagType:
>
> class FlagType(models.Model):
>  name = models.CharField(maxlength=50)
>  description = models.TextField()
>
> class Flag(models.Model):
>  type = models.ForeignKey(FlagType) # type of flag
>  content_type = models.ForeignKey(ContentType)
>  object_id = models.PositiveIntegerField()
>  content_object = generic.GenericForeignKey()
>  user = models.ForeignKey(User)
>  created = models.DateTimeField()
>
> So, for example "illegal" or "to feature" would be flags. Now we're
> flagging Song objects and I would like a queryset that gets me all Songs
> flagged with a flag of type "illegal".
>
> I can do:
>
>flag = FlagType.objects.get(name='illegal')
>ctype = ContentType.objects.get_for_model(Song)
>flagged = Flag.objects.filter(type=flag,
>content_type=ctype).order_by('-created')
>songs = [item.content_object for item in flagged ]
>
> But the problem is: I can't do extra things to this list like order_by()
> or an extra filter() or exclude().
>
> How can I get the same result, but still have a queryset (containing
> Songs) instead of a list??
>
>   - bram

songs = Song.objects.filter(id__in=[item.content_object.id for item in
flagged])

.. would hit the DB again .. but requires little code.

Post back if another hit isn't a viable option and we'll take a closer
look at the problem.


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



mod_python/django problems

2007-08-03 Thread Aljosa Mohorovic

on few blogs/web sites it is stated that > 30 django sites on one
server running apache/mod_python have some issues, like untraceable
errors and wrong site displaying for some domain.
any comments on this?

i have many small php sites that will eventually became django sites,
how should i deploy?

Aljosa


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

2007-08-03 Thread Jonas

> Also, you should be using a recent SVN checkout for this to work.

It does work with he latest development version. Thank you!

Jonas


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



extending django.contrib.auth

2007-08-03 Thread ocgstyles

Is there a way I can add some attributes to the User model in
django.contrib.auth.models and also have those new attributes render
in admin?  I figure I could just edit the django.contrib.auth.models
and add the attributes manually, but that won't last persist through
future upgrades.


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

2007-08-03 Thread Bram - Smartelectronix

hello all,


I have a generic relation Flag, with a FlagType:

class FlagType(models.Model):
 name = models.CharField(maxlength=50)
 description = models.TextField()

class Flag(models.Model):
 type = models.ForeignKey(FlagType) # type of flag
 content_type = models.ForeignKey(ContentType)
 object_id = models.PositiveIntegerField()
 content_object = generic.GenericForeignKey()
 user = models.ForeignKey(User)
 created = models.DateTimeField()

So, for example "illegal" or "to feature" would be flags. Now we're 
flagging Song objects and I would like a queryset that gets me all Songs 
flagged with a flag of type "illegal".

I can do:

   flag = FlagType.objects.get(name='illegal')
   ctype = ContentType.objects.get_for_model(Song)
   flagged = Flag.objects.filter(type=flag,
   content_type=ctype).order_by('-created')
   songs = [item.content_object for item in flagged ]

But the problem is: I can't do extra things to this list like order_by() 
or an extra filter() or exclude().


How can I get the same result, but still have a queryset (containing 
Songs) instead of a list??


  - bram

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

2007-08-03 Thread Kenneth Gonsalves


On 03-Aug-07, at 2:44 PM, Chris Hoeppner wrote:

> Oh and please don't call Template Monster "professional"... Please...

thank god they dont offer free django templates

-- 

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



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



Re: website template compatible with django

2007-08-03 Thread Chris Hoeppner

Oh and please don't call Template Monster "professional"... Please...

2007/8/3, Chris Hoeppner <[EMAIL PROTECTED]>:
> Though you would still need to adapt them to be used with Django.
> IMHO, there's not much sense in publishing "Django templates" since
> every app is completely different, and this kills the
> "plug-and-play-ability" of any template.
>
> 2007/8/3, Kenneth Gonsalves <[EMAIL PROTECTED]>:
> >
> >
> > On 01-Aug-07, at 12:32 PM, Ben wrote:
> >
> > > I am a total Django newbie.  Hence the probably silly questions:
> > > There are professional-looking website templates for sale in several
> > > places (templatemonster, etc).
> > > Can those be used easily with Django ?
> >
> > yes
> >
> > > Do they need to be designed specifically for Django ?
> >
> > no
> >
> > > Do you know of
> > > any vendor that does it ?
> > > If not, what to look for in a template order to make sure it will be
> > > relatively easy to use with Django ?
> >
> > the template part is completely independant of the rest of django -
> > any template that follows the principles of good HTML design using
> > css, javascript, ajax or whatever will work with Django - even bad
> > design will work. The more modular the design of the template, the
> > better - but again that is not django specific.
> >
> > --
> >
> > regards
> > kg
> > http://lawgon.livejournal.com
> > http://nrcfosshelpline.in/web/
> >
> >
> >
> > > >
> >
>
>
> --
> Best Regards,
> Chris Hoeppner - www.pixware.org // My weblog
>


-- 
Best Regards,
Chris Hoeppner - www.pixware.org // My weblog

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

2007-08-03 Thread Chris Hoeppner

Though you would still need to adapt them to be used with Django.
IMHO, there's not much sense in publishing "Django templates" since
every app is completely different, and this kills the
"plug-and-play-ability" of any template.

2007/8/3, Kenneth Gonsalves <[EMAIL PROTECTED]>:
>
>
> On 01-Aug-07, at 12:32 PM, Ben wrote:
>
> > I am a total Django newbie.  Hence the probably silly questions:
> > There are professional-looking website templates for sale in several
> > places (templatemonster, etc).
> > Can those be used easily with Django ?
>
> yes
>
> > Do they need to be designed specifically for Django ?
>
> no
>
> > Do you know of
> > any vendor that does it ?
> > If not, what to look for in a template order to make sure it will be
> > relatively easy to use with Django ?
>
> the template part is completely independant of the rest of django -
> any template that follows the principles of good HTML design using
> css, javascript, ajax or whatever will work with Django - even bad
> design will work. The more modular the design of the template, the
> better - but again that is not django specific.
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
>
>
>
> >
>


-- 
Best Regards,
Chris Hoeppner - www.pixware.org // My weblog

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

2007-08-03 Thread Chris Hoeppner

What kind of volunteers do are you looking for? What kind of tasks are
you looking to resolve?

If I could have some more details (maybe have a look at the proposed
timeline) I'd be in :)

2007/8/3, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> I'm looking for some volunteers for a new open source project. At the
> Institute of Design (http://www.id.iit.edu ), our next project is a
> system for the management of our job fair (http://www.id.iit.edu/
> recruitID/ )
>
> The systems goal is to allow students and employers to enter their
> availability for interviews and have the system designate times and
> rooms for each to meet for interviews. The system includes much more
> than just this of course, but that is the main goal. We decided that
> this application is generic enough that it should be made into an F/
> OSS project.
>
> So far the system will be built on Django and uses (hopefully)
> Prototype.js
>
> I've only really been using Django for a month now so anyone with real
> experience would be appreciated.
>
> The project is on the ground floor and some basic wire frames and a
> few other preliminary designs.
>
> I'm personally located in Chicago and West Virginia (about half of my
> time spent in each place), though you are welcome to help out from
> anywhere around the world!
>
> If you're interested, reply to this message, or contact me at cezar AT
> id.iit.edu
>
>
> >
>


-- 
Best Regards,
Chris Hoeppner - www.pixware.org // My weblog

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread koenb

There already is a ticket: #4783. Just needs volunteers to do the
writing...

Koen

On 3 aug, 10:41, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> On Aug 3, 4:32 pm, koenb <[EMAIL PROTECTED]> wrote:
>
> > My guess is you are interfering with your admin_media (look at the
> > admin_media_prefix setting).
> > Try using something like r'^sitemedia/... and src="/sitemedia/...".
>
> Thanks koen, that did it. I think it could be nice if it was mention
> on the documentation.
>
> cheers,
> james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Newforms w/ *dynamic* ChoiceField choices?

2007-08-03 Thread Jonathan Buchanan

> Newforms has a spiffy way to dynamically set the "initial" values of
> fields, in the view code when the Form is constructed.
>   choosecolorform = ChooseColorForm(initial={'color': 'black'})
>
> I was hoping it would be just as easy to dynamically define the
> choices available in a ChoiceField, too... but no such luck.

One of the easiest ways is probably to override __init__ in your Form
subclass and pass in the list of Colors you want to have as choices -
I don't know what your Color model looks like, so I'm assuming id and
name fields.

It's important to call super(...).__init__ to get your fields set up
in self.fields before you try to modify them.

class ChooseColorForm(forms.Form):
color = forms.ChoiceField(label='Choose a color')

def __init__(colors, *args, **kwargs):
super(ChooseColorForm, self).__init__(*args, **kwargs)
self.fields['color'].choices = [('unpainted', 'Don\'t paint it')] +
[(color.id, color.name) for color in colors]


Usage::

>>> colors = Color.objects.all()
>>> form = ChooseColorForm(colors)

Jonathan.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread james_027

hi Kai,


> If you do not use it, no.
>

If I use it, how does it affect then?

thanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread james_027

hi,

On Aug 3, 4:32 pm, koenb <[EMAIL PROTECTED]> wrote:
> My guess is you are interfering with your admin_media (look at the
> admin_media_prefix setting).
> Try using something like r'^sitemedia/... and src="/sitemedia/...".
>

Thanks koen, that did it. I think it could be nice if it was mention
on the documentation.

cheers,
james



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread koenb

My guess is you are interfering with your admin_media (look at the
admin_media_prefix setting).
Try using something like r'^sitemedia/... and src="/sitemedia/...".

Koen

On 3 aug, 09:16, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> I already did the
>
> (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root':'d:/private/james/documents/django/ksk/media'}),
>
> in my urls.py
>
> and in my template i have something like this
>
> 
>
> but why is it the image still don't appear?
>
> Thanks
> james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: OR a Q object - Problem with ManyToMany relationships?

2007-08-03 Thread LaundroMat

Driving to work this morning I was thinking of how I should have had a
look at the generated SQL statement (which I can't do now).

I think you are right, it's the only way the exclusion could have
happened. Would you have an idea of how to prevent this, preferrably
without having to write the SQL statement myself?

Thanks,

Mathieu

On Aug 3, 12:54 am, Nowell <[EMAIL PROTECTED]> wrote:
> I believe that this is due to the fact that the last Q is performing
> an INNER JOIN on the Authors table, and therefore is excluding all
> records that do not have an entry in your (what I assume is a)
> ManyToManyField/ForeignKey.
>
> On Aug 2, 5:37 pm, LaundroMat <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Suppose I have defined the models from the django documentation
> > (http://www.djangoproject.com/documentation/db-api/).
>
> > I'm performing a search the entries model, and I want to look through
> > all of its fields:
>
> > from django.db.models import Q
> > query =
> > 'querystring' #
> > User supplied querystring, eg "Lawrence"
> > lookup = Q(headline__icontains = querystring) | \
> > Q(body_text__icontains = querystring) | \
> > Q(authors__name__icontains = querystring)
>
> > p = Prediction.objects.filter(lookup).distinct()
>
> > The models I have built are more complex than the above, but the gist
> > is the same. For one reason or another, I get more results when I
> > leave out the last Q object (the one looking through the authors'
> > names) than when I leave it in. This shouldn't be happening, as all Q
> > objects are being OR'ed.
>
> > I hope I've given enough information for you to try and simulate my
> > problem, and perchance find a solution for it. Many thanks in advance
> > already.
>
> > Mathieu


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread Kai Kuehne

Hi,

On 8/3/07, james_027 <[EMAIL PROTECTED]> wrote:
> does it affect the django.views.static.serve?

If you do not use it, no.

Greetings
Kai

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: help serving static files (css, images, pdf, js)

2007-08-03 Thread james_027

hi,

are this settings used when running under development mode?

MEDIA_ROOT
MEDIA_URL

does it affect the django.views.static.serve?

thanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Newforms - passing form data in sessions - Trouble with ForeignKey

2007-08-03 Thread MichaelMartinides

Hi Rajesh,

Thanks for your answer.

Basically, I have two forms (derived from models) that I validate on
two pages.

On the third page I would like to present the two datasets and save
the models when the user validates them by clicking submit.

One model (order) has a foreignkey to the other (customer). I would
like to avoid writing in the db unless the customer has confirmed the
order.

But I think your suggestion of saving the post data (after the forms
validate then) in a session key solves this worry; thanks for this.

Btw, I am missing a new form method to show the contents of form in an
uneditable way (e.g. input tag set on non editable.)

Cheers,
  >>Michael

On Aug 2, 10:21 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> > But I run into trouble when saving in sessions via clean_data and then
> > trying to initiate a newform with the saved clean_data. This occurs
> > only when ForeignKeys are in the Game.
>
> > This is probably due to the nature foreignkeys are stored as an object
> > in clean_data (see below).
>
> Correct. ModelChoiceField's clean_data results in the corresponding
> related object instance and not its id.
>
> That makes your form.clean_data a dictionary that can not be used to
> instantiate a new form.
>
> What is the flow of your 3 screens? Are you populating a single form
> partially through each of three form submits? Do you need the
> clean_data at each step (for example, are you validating on each
> screen or only on the final screen)?
>
> You could store a copy of request.POST into your session instead of
> form.clean_data. Then at each stage you get the current
> request.POST.copy() and update it with the session's stored
> request.POST.copy() and use that merged dictionary to instantiate that
> stage's form. I am sure that there are other ways to skin this one
> once you tell us a bit more about the flow you are looking to design.


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



help serving static files (css, images, pdf, js)

2007-08-03 Thread james_027

hi,

I already did the

(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root':'d:/private/james/documents/django/ksk/media'}),

in my urls.py

and in my template i have something like this



but why is it the image still don't appear?

Thanks
james


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

2007-08-03 Thread Matt Davies
Hi Przemek

I do, but I hand the request from apache to Lighttpd, which in it's conf
file handles the serving of docs.

I'm not sure but I think you need something extra in apche to tell it where
the static content is.



On 03/08/07, Przemek Gawronski <[EMAIL PROTECTED]> wrote:
>
>
> Hi, I'm having some problems running Django behind an Apache with a
> mod_proxy.
>
> So my router transmits all it's communication on port 80 to 192.168.0.2,
> on which I've setup mod_proxy (with django server on 192.168.1.2, the
> networks see each other)
>
> 
> ProxyRequests On
> ProxyPass /django/ http://192.168.1.2:8000/
> ProxyPassReverse /django/ http://192.168.1.2:8000/
> 
>
> I do hit the login screen to my django app, but then all the files
> (static, js,...) and sub pages aren't served properly :(
>
> Here is a part of my urlpatterns:
>
> urlpatterns = patterns('',
>(r'^/js/(?P.*)$', 'django.views.static.serve',{'document_root':
> '/home/django/work/fw/media/'}),
>(r'^/css/(?P.*)$', 'django.views.static.serve',{'document_root':
> '/home/django/work/fw/media/'}),
>(r'^/accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': '/login.html'}),
>(r'^/accounts/profile/$', 'django.views.generic.simple.redirect_to',
> {'url': '/zlecenia/strona1'}),
>(r'^/$', 'django.contrib.auth.views.login', {'template_name':
> '/login.html'}),
>(r'^/wyloguj/$', 'django.contrib.auth.views.logout_then_login' ),
>(r'^/zlecenia/strona(?P[0-9]+)/$', limited_workorder_list,
> workorder_info_dict ),
> ...
>
> Any one uses django behind apache with mod_proxy?
>
> Przemek
> --
> AIKIDO TANREN DOJO  -   Poland - Warsaw - Mokotow - Ursynow - Natolin
> info: http://www.tanren.pl/ phone: +4850151 email: [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: Newforms w/ *dynamic* ChoiceField choices?

2007-08-03 Thread Thomas Guettler

Am Freitag, 3. August 2007 00:19 schrieb rskm1:
> Newforms has a spiffy way to dynamically set the "initial" values of
> fields, in the view code when the Form is constructed.
>   choosecolorform = ChooseColorForm(initial={'color': 'black'})

I think you only can set initial to a value, not to a dict.


> I was hoping it would be just as easy to dynamically define the
> choices available in a ChoiceField, too... but no such luck.
>
> The choices in my ChoiceField will ultimately come from a database,
> and will vary based on user permissions and/or the state of the page
> that the form is being displayed on, etc.

By looking at the source I found the QueySetIterator:

  choices=forms.models.QuerySetIterator(User.objects.all(), "", False)


HTH,
 Thomas

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

2007-08-03 Thread Matt Davies
Ben, I'd be interested in looking at that application.

Need someone to help with testing?



On 03/08/07, Ben Ford <[EMAIL PROTECTED]> wrote:
>
> I'm working on a django app at the moment that allows you to define and
> save reports. It has a method similar to templatetags for loading user
> defined functions to add to the reports too. As it stands you can build and
> save these reports with a web front end, and download the results in CSV. I
> just need to write a front end for creating filters and it'll be good to go.
> I'll be happy to release it for the benefit of others when it's done.
> Ben
>
> On 03/08/07, Mir Nazim <[EMAIL PROTECTED]> wrote:
> >
> >
> > I understand that views need to be created. I am doing that these
> > days.
> >
> > What specifically I wanted to know is whether anyone else has worked
> > on a similar stuff. So he might want to share his experience.
> >
> > BRIT is Java. I would prefer something more python based solution.
> > even better is there is a django based one. If there is none, its
> > obvious I will have to create one.
> >
> >
> > On Aug 2, 8:20 pm, Lucky B < [EMAIL PROTECTED]> wrote:
> > > You could try Eclipse BIRT for a WYSIWYG interface. But otherwise you
> > > can create a view however you want to report your data doing whatever
> > > manipulation you wanted. I don't see what else you would need other
> > > than to create a view.
> > >
> > > On Aug 2, 5:17 am, Mir Nazim <[EMAIL PROTECTED]> wrote:
> > >
> > > > Anybody has any views on this.
> > >
> > > > --
> > > > PS: posting just to keep this topic fresh
> > >
> > > > On Jul 31, 4:28 pm, Mir Nazim <[EMAIL PROTECTED]> wrote:
> > >
> > > > > Hello
> > >
> > > > > I was wondering has anybody done application that was something
> > like a
> > > > > mini crystal reports. Generating a report based of model items
> > > > > selected in a WYSIWYG(ok this is not important) fashion.  And
> > > > > generating a HTML tables based report with defined calculations
> > etc.
> > >
> > > > > I understand that Django Admin has some kind of similar
> > facilities. I
> > > > > am looking into them. In the mean time thought that may be some
> > one
> > > > > else might be doing similar stuff somewhere.
> >
> >
> >
> >
> >
>
>
> --
> Regards,
> Ben Ford
> [EMAIL PROTECTED]
> +628111880346
> >
>

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

2007-08-03 Thread Ben Ford
I'm working on a django app at the moment that allows you to define and save
reports. It has a method similar to templatetags for loading user defined
functions to add to the reports too. As it stands you can build and save
these reports with a web front end, and download the results in CSV. I just
need to write a front end for creating filters and it'll be good to go. I'll
be happy to release it for the benefit of others when it's done.
Ben

On 03/08/07, Mir Nazim <[EMAIL PROTECTED]> wrote:
>
>
> I understand that views need to be created. I am doing that these
> days.
>
> What specifically I wanted to know is whether anyone else has worked
> on a similar stuff. So he might want to share his experience.
>
> BRIT is Java. I would prefer something more python based solution.
> even better is there is a django based one. If there is none, its
> obvious I will have to create one.
>
>
> On Aug 2, 8:20 pm, Lucky B <[EMAIL PROTECTED]> wrote:
> > You could try Eclipse BIRT for a WYSIWYG interface. But otherwise you
> > can create a view however you want to report your data doing whatever
> > manipulation you wanted. I don't see what else you would need other
> > than to create a view.
> >
> > On Aug 2, 5:17 am, Mir Nazim <[EMAIL PROTECTED]> wrote:
> >
> > > Anybody has any views on this.
> >
> > > --
> > > PS: posting just to keep this topic fresh
> >
> > > On Jul 31, 4:28 pm, Mir Nazim <[EMAIL PROTECTED]> wrote:
> >
> > > > Hello
> >
> > > > I was wondering has anybody done application that was something like
> a
> > > > mini crystal reports. Generating a report based of model items
> > > > selected in a WYSIWYG(ok this is not important) fashion.  And
> > > > generating a HTML tables based report with defined calculations etc.
> >
> > > > I understand that Django Admin has some kind of similar facilities.
> I
> > > > am looking into them. In the mean time thought that may be some one
> > > > else might be doing similar stuff somewhere.
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+628111880346

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



Re: Queryset of instances bound to particular ForeignKey

2007-08-03 Thread James Bennett

On 8/3/07, Collin Grady <[EMAIL PROTECTED]> wrote:
> >>> B.objects.filter(a__isnull=False)
> [, ]

And as pointed out in our IRC discussion, that needs a distinct()
slapped on the end to weed out duplicate results ;)


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Queryset of instances bound to particular ForeignKey

2007-08-03 Thread Collin Grady

I feel silly for not trying this earlier, but it appears to work :)

>>> B.objects.filter(a__isnull=False)
[, ]

Models used for this test: http://dpaste.com/15931/


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



Re: Queryset of instances bound to particular ForeignKey

2007-08-03 Thread James Bennett

On 8/3/07, James Bennett <[EMAIL PROTECTED]> wrote:
> Foo.objects.extra(where=['id IN (SELECT %s FROM %s)' % Bar._meta.db_table])

Should have been:

> Foo.objects.extra(where=['id IN (SELECT foo_id FROM %s)' % 
> Bar._meta.db_table])

(sent before I realized I'd decided not to use quote_name() for the example)

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Queryset of instances bound to particular ForeignKey

2007-08-03 Thread James Bennett

On 8/3/07, Collin Grady <[EMAIL PROTECTED]> wrote:
> He wants every B that has an A fkeyed to it.
>
> In other words, every instance of B where b.a_set.count() > 0

In which case what he wants is probably something like

ModelB.objects.filter(id__in=[o.id for o in ModelA.objects.all()])

Which is kind of scary in terms of what it'll do, since it has to
instantiate every single ModelA object and do an attribute lookup on
each. Using 'values()' instead of 'all()' and specifying just the
foreign key column is a bit better, but still instantiates one
dictionary and performs one key lookup in it for each ModelA object.

Probably the most efficient thing you'll get from using just the
Django ORM methods is something like the following. Assume the models
Foo and Bar as defined here:

class Foo(models.Model):
name = models.CharField(maxlength=250)

class Bar(models.Model):
name = models.CharField(maxlength=250)
foo = models.ForeignKey(Foo)

To look up all those Foo, and only those Foo, which are currently
being referenced by a Bar, do the following:

Foo.objects.extra(where=['id IN (SELECT %s FROM %s)' % Bar._meta.db_table])

This does the whole thing in one query and avoids instantiating any
intermediate objects along the way. Note that variations in DB
implementations of SQL may mean you need to use backend.quote_name()
in there.



-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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