Re: how to scale (was: how to do something at startup)

2007-10-03 Thread Udi

Check out: http://ant.apache.org/

These types of deployment & initialization tasks should be handled by
the surrounding environment, not Django itself.  I suggest you use ant
or something similar to set up some scripts for yourself that
coordinate everything.



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



Freelance Django Developers

2007-10-03 Thread Martin Ostrovsky

Hello Django Developers,

We're looking for Django developers to work on various web
applications. You can be located anywhere in the world, but your
English has to be very strong. You should be familiar with the
following:

- source control (svn)
- unit testing with Django
- AJAX
- and of course, really, really, really good with Python & Django !

If you can commit at least 20 hours a week, then we want to hear from
you. Just reply to this post with your details and we'll get in
contact with you.

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: python script

2007-10-03 Thread Don Arbow

On Oct 3, 2007, at 7:55 AM, Xan wrote:
>
> In http://code.djangoproject.com/ticket/5534 there is a howto for
> doing that.
> But it's only when the script is in the root project directory.
> What happens if we want the script in other location? What line we
> have to add?
>
> Thanks a lot,
> Xan.



Everything you wanted to know about running Django from a script:

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

Don



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



QuerySet.extra() and bind variables

2007-10-03 Thread tzeskimo

I'm trying to write a custom QuerySet, but I'm a bit confused about
how to properly use the method extra().  From my understanding,
extra() accepts both "select" and "where" arguments, both of which can
contain bind variables.  You then pass the appropriate bind variable
values to the "param" argument.

This method seems like it will fall apart if two QuerySets are chained
together, both of which pass "select" and "where" arguments to extra.
For example, wouldn't the following cause an issue:

class FooQuerySet:

def query1(self):

 self.extra(select = {'something': "item * %s"}, where = "item
< %s", params = (3, 5))

def query2(self):

self.extra(select = {'something_else': "item / %s"}, where =
"item > %s", params = (3, 5))

model.custom_manager.all().query1().query2()


In this example, the two select statements will appear at the
beginning of the query, and therefore bind to the first two
parameters.  However, due to the order in which the bind parameters
are passed to extra(), the second bind parameter should actually
belong to the "where" statement of query1.  Is this simply an
unsupported method of using extra?  Is there a better alternative?
The only thing I can think of is to do the quoting myself, or write
the raw sql myself, in which case the query set can't be chained.
Both of these options seem less than idea.


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



Re: Does setting a session cause a redirect?

2007-10-03 Thread Rob Hudson

After the few responses here and Malcolm telling me I was on drugs
(grin) I dug deeper and found the problem...

On my list result page I had a model method returning an empty string
for a URL to a related image which resulted in the following HTML:



That cause an extra GET request to the same page.  I fixed the model
method and all is good.

Thanks to all,
Rob

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



Re: Linking dropdowns using newforms

2007-10-03 Thread Richard Dahl
I have used both mochikit and yahoo YUI for this, both of them work well.
JQuery show a great deal of promise as well although I have never used it.
-richard

On 10/3/07, Emmchen <[EMAIL PROTECTED]> wrote:
>
>
> @ Hraban - Thank you for your reply.
>
> Yes, I want to display up to four columns. The content of one column
> depend on the selection in the previous column (exept for the first
> one).
>
> Column 1: Display a list of choices - (eg Systematic, Collection,
> Growthplace, Heritage).
> Column 2: Display a filtered result of PropertyValueCombo instances
> with the selected value from Column 1.
> Column 3: Display a filtered result of PropertyValueCombo instances
> with the selected value from Column 2.
> Column 4: Display a filtered result of PropertyValueCombo instances
> with the selected value from Column 3.
>
> I want the result from the first column to still be displayed while
> the value in the second column get selected, and that the result from
> the first and second column is displayed while the value in the third
> column get selected etc.
>
> The selected value in the last column (Column 4) will then be used to
> filter out the Individual that correspond to that selected value.
>
> Is it possible to use two or more forms at the same time? And is it
> possible to desplay the selected values from one form while the next
> form doesn't have a selected value yet. How does this work with
> request/response?
>
> My experience with JavaScript is seriously limited. Therefore do you
> or does anybody else have any pointers where to start with JavaScript?
>
> Thanks,
> Emma
>
>
> >
>

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

2007-10-03 Thread Henning Hraban Ramm

Am 2007-10-03 um 20:52 schrieb Emmchen:

> Is it possible to use two or more forms at the same time? And is it
> possible to desplay the selected values from one form while the next
> form doesn't have a selected value yet. How does this work with
> request/response?
>
> My experience with JavaScript is seriously limited. Therefore do you
> or does anybody else have any pointers where to start with JavaScript?

I'm a django newbie myself and never tried how to handle AJAX with it.

I made something similar in a PHP app, but that uses some proprietary  
framework and Smarty templating with custom plugins, so it would be  
no help if I'd show you the code.

Basically you need
- a simple JS requester/handler that you can bind to an onChange event
- views that deliver your selections as JSON or whatever

I like the jQuery library, but there are a lot of useful JS  
libraries, don't know yet which fits best with django.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: IOError from HttpResponse(somefile) -- via S3 storage

2007-10-03 Thread Marty Alchin

On 10/3/07, fdraft <[EMAIL PROTECTED]> wrote:
> So I'm keeping uploaded files in an S3 bucket. For private documents,
> their S3 permissions are set to private. So my plan has been that
> Django will check if a user is authenticated, and if so, pull the
> document from S3 and send it to the client. I'm using the boto S3
> library to do the actuall interactions with S3 (that's what all the
> get_key stuff is based on below). This functions are:
>
> 
>
> I thought I had found a discussion that linked this error to threading
> in python - but I can't seem to find it again. Any ideas you have on
> how to resolve this would be appreciated...

I don't know about this particular problem, but I've been working on a
way to plug different file storage mechanisms into Django easily, and
S3 is high on my list. I have a backend written for it, but I don't
use S3 so I haven't tested it yet, and the file storage code hasn't
landed in trunk anyway.

I'm only saying all this to let you know that I'll be keeping an eye
on this discussion, and there may be a much easier way to do all this
in the near future. I don't know if my code will have the same problem
as yours though, so it's still best to sort out what you're dealing
with in the mean time.

-Gul

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

2007-10-03 Thread James Bennett

On 10/3/07, staff-gmail <[EMAIL PROTECTED]> wrote:
 > So my question was how do I do ORM in a view ??  Where is "choice_set"
> coming from ??

http://www.djangoproject.com/documentation/db-api/#backward


-- 
"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: Custom View for a file upload

2007-10-03 Thread jacoberg2

the thing is that i am trying to update this site for a previous
developer and he created a base template that extends to all the
pages in the site, so i assume that he used those functions and when
clicking around the site and seeing his other views,
all he did was put at login required, and when i log into the site i
can click around all the pages except the one i made and it
keeps me logged in, so i dont understand y it doesnt work for my new
view and template.

On Oct 3, 2:52 pm, fdraft <[EMAIL PROTECTED]> wrote:
> "when i connect to the pages that should handle the upload, the person
> is no longer logged in"
>
> If that's true, then the problem isn't with this bulk_reg() function -
> presumably it isn't running if you aren't logged in, right? Are you
> using the suggested methods for loggin a user in 
> (http://www.djangoproject.com/documentation/authentication/#how-to-log...
> ) ?
>
> On Oct 3, 11:46 am, jacoberg2 <[EMAIL PROTECTED]> wrote:
>
> > Hey,
>
> >   I've posted a few times about saving files through the admin and all
> > the problems its caused, but i figured out that the save method i
> > tried to write was screwing it all up by not completing due to the
> > error in opening the file. But since this is occuring it still is
> > screwing up what i went out to do. So i am curious if this can be done
> > in the view instead of the save method.
>
> > I can get the file to save to the system through the admin interface,
> > but what i cant seem to do is create a view that will save the file.
> > the model has user and file fields and i want the view to be
> > @login_required. What i have tried doesnt seem to follow with the
> > login, meaning in the templates, which extends a base template that
> > controls the login, when i connect to the pages that should handle the
> > upload, the person is no longer logged in. and when i try the upload i
> > dont get any errors, but the file is not saved to the file system or
> > registered in the admin, so if anyone has any pointers or code it
> > would be a great help. this is the view i have:
>
> > @login_required
> > def bulk_reg(request):
> > """Add large numbers of registrations by uploading a file"""
> > manipulator = FileManipulator()
> > data_domain = get_object_or_404(DataDomain, user=request.user.id)
> > new_data = {}
> > errors = {}
>
> > if request.POST:
> > new_data = request.POST.copy()
> > new_data.update(request.FILES)
> > errors = manipulator.get_validation_errors(new_data)
>
> > if not errors:
> > manipulator.do_html2python(new_data)
>
> > fi = BulkDataRegFile(user = request.user.id,
> >  domain = data_domain,
> >  bulk = new_data['bulk'],)
> > fi.save()
>
> > return HttpResponseRedirect('/provider/')
>
> > form = forms.FormWrapper(manipulator, new_data, errors)
> > return render_to_response('provider/dataset/bulkreg.dht',
> >   {'form': form},)
>
> > the file manipulator is a custom manipulator that only includes the
> > fileuploadfield and is_required is true.
> > So i am hoping to get this to work and maybe open the file from the
> > view and then parse it for more information if that would work. Any
> > suggestions or code would be greatly appreciated.
>
> > Jaco


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

2007-10-03 Thread Emmchen

@ Hraban - Thank you for your reply.

Yes, I want to display up to four columns. The content of one column
depend on the selection in the previous column (exept for the first
one).

Column 1: Display a list of choices - (eg Systematic, Collection,
Growthplace, Heritage).
Column 2: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 1.
Column 3: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 2.
Column 4: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 3.

I want the result from the first column to still be displayed while
the value in the second column get selected, and that the result from
the first and second column is displayed while the value in the third
column get selected etc.

The selected value in the last column (Column 4) will then be used to
filter out the Individual that correspond to that selected value.

Is it possible to use two or more forms at the same time? And is it
possible to desplay the selected values from one form while the next
form doesn't have a selected value yet. How does this work with
request/response?

My experience with JavaScript is seriously limited. Therefore do you
or does anybody else have any pointers where to start with JavaScript?

Thanks,
Emma


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

2007-10-03 Thread fdraft

"when i connect to the pages that should handle the upload, the person
is no longer logged in"

If that's true, then the problem isn't with this bulk_reg() function -
presumably it isn't running if you aren't logged in, right? Are you
using the suggested methods for loggin a user in (
http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in
) ?

On Oct 3, 11:46 am, jacoberg2 <[EMAIL PROTECTED]> wrote:
> Hey,
>
>   I've posted a few times about saving files through the admin and all
> the problems its caused, but i figured out that the save method i
> tried to write was screwing it all up by not completing due to the
> error in opening the file. But since this is occuring it still is
> screwing up what i went out to do. So i am curious if this can be done
> in the view instead of the save method.
>
> I can get the file to save to the system through the admin interface,
> but what i cant seem to do is create a view that will save the file.
> the model has user and file fields and i want the view to be
> @login_required. What i have tried doesnt seem to follow with the
> login, meaning in the templates, which extends a base template that
> controls the login, when i connect to the pages that should handle the
> upload, the person is no longer logged in. and when i try the upload i
> dont get any errors, but the file is not saved to the file system or
> registered in the admin, so if anyone has any pointers or code it
> would be a great help. this is the view i have:
>
> @login_required
> def bulk_reg(request):
> """Add large numbers of registrations by uploading a file"""
> manipulator = FileManipulator()
> data_domain = get_object_or_404(DataDomain, user=request.user.id)
> new_data = {}
> errors = {}
>
> if request.POST:
> new_data = request.POST.copy()
> new_data.update(request.FILES)
> errors = manipulator.get_validation_errors(new_data)
>
> if not errors:
> manipulator.do_html2python(new_data)
>
> fi = BulkDataRegFile(user = request.user.id,
>  domain = data_domain,
>  bulk = new_data['bulk'],)
> fi.save()
>
> return HttpResponseRedirect('/provider/')
>
> form = forms.FormWrapper(manipulator, new_data, errors)
> return render_to_response('provider/dataset/bulkreg.dht',
>   {'form': form},)
>
> the file manipulator is a custom manipulator that only includes the
> fileuploadfield and is_required is true.
> So i am hoping to get this to work and maybe open the file from the
> view and then parse it for more information if that would work. Any
> suggestions or code would be greatly appreciated.
>
> Jaco


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

2007-10-03 Thread Chris Brand

staff-gmail wrote:
> Where is "choice_set" coming from ?? 
That one's easy - 
http://www.djangoproject.com/documentation/db-api/#backward

Chris



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



Re: confused over using ORM in view/template

2007-10-03 Thread Malcolm Tredinnick

On Wed, 2007-10-03 at 12:40 -0600, staff-gmail wrote:
> So my question was how do I do ORM in a view ?? 

See [1] where it explains how dotted references are mapped back to
Python objects.

> Where is "choice_set" 
> coming from ??

Based on the name and the examples shown, it's related to the
one-to-many relation between the Choice and Poll models. To avoid having
to put in annotations on both models, the reverse name is
auto-generated. See [2] and [3] (the 'related_name' attribute in the
latter case and links to the examples near there are good follow-ups,
too).

[1] http://www.djangoproject.com/documentation/templates/#variables
[2] http://www.djangoproject.com/documentation/db-api/#backward
[3]
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships

Regards,
Malcolm



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



Custom View for a file upload

2007-10-03 Thread jacoberg2

Hey,

  I've posted a few times about saving files through the admin and all
the problems its caused, but i figured out that the save method i
tried to write was screwing it all up by not completing due to the
error in opening the file. But since this is occuring it still is
screwing up what i went out to do. So i am curious if this can be done
in the view instead of the save method.

I can get the file to save to the system through the admin interface,
but what i cant seem to do is create a view that will save the file.
the model has user and file fields and i want the view to be
@login_required. What i have tried doesnt seem to follow with the
login, meaning in the templates, which extends a base template that
controls the login, when i connect to the pages that should handle the
upload, the person is no longer logged in. and when i try the upload i
dont get any errors, but the file is not saved to the file system or
registered in the admin, so if anyone has any pointers or code it
would be a great help. this is the view i have:

@login_required
def bulk_reg(request):
"""Add large numbers of registrations by uploading a file"""
manipulator = FileManipulator()
data_domain = get_object_or_404(DataDomain, user=request.user.id)
new_data = {}
errors = {}

if request.POST:
new_data = request.POST.copy()
new_data.update(request.FILES)
errors = manipulator.get_validation_errors(new_data)

if not errors:
manipulator.do_html2python(new_data)

fi = BulkDataRegFile(user = request.user.id,
 domain = data_domain,
 bulk = new_data['bulk'],)
fi.save()

return HttpResponseRedirect('/provider/')

form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('provider/dataset/bulkreg.dht',
  {'form': form},)

the file manipulator is a custom manipulator that only includes the
fileuploadfield and is_required is true.
So i am hoping to get this to work and maybe open the file from the
view and then parse it for more information if that would work. Any
suggestions or code would be greatly appreciated.

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: confused over using ORM in view/template

2007-10-03 Thread staff-gmail

So my question was how do I do ORM in a view ??  Where is "choice_set" 
coming from ??   I'm just looking for some very practical answers so I 
can get something working - and if I'm a fairly bright guy and can't 
figure it out, obviously there's some improvement required - and maybe I 
will contribute some documentation if I can figure some things out - or 
maybe I just say the heck with Django attitudes and go back to Rails.  
I'm losing productivity fast here.

Malcolm Tredinnick wrote:
> On Wed, 2007-10-03 at 11:22 -0600, staff-gmail wrote:
> [...]
>   
>> Honestly, the official tutorial needs to be re-written.
>> 
>
> The tutorial is for people wanting a step-by-step introduction to a
> basic project. If you want more information, we have truckloads of
> reference documentation for people to read. So, if you're working
> through the tutorial, don't try to skip ahead -- it's a very basic
> introduction. The reverse to this is that if you want more information,
> don't try to use the tutorial as your reference guide. The database.txt
> file and templates.txt file should answer most of the questions you are
> asking about.
>
> A lot of people have found the tutorial to be very valuable. That
> doesn't mean you necessarily will, but keep in mind that different
> people obviously learn and process things in different ways. So we have
> the step-by-step introduction as well as more extensive reference docs.
>
> There's also a place for more mid-level and advanced tutorials. There's
> nothing like that in the core docs at the moment. Maybe there will be in
> the future if somebody writes them.
>
>
> Regards,
> Malcolm
>
>
> >
>
>   


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



IOError from HttpResponse(somefile) -- via S3 storage

2007-10-03 Thread fdraft

So I'm keeping uploaded files in an S3 bucket. For private documents,
their S3 permissions are set to private. So my plan has been that
Django will check if a user is authenticated, and if so, pull the
document from S3 and send it to the client. I'm using the boto S3
library to do the actuall interactions with S3 (that's what all the
get_key stuff is based on below). This functions are:

@login_required
def priv_document(request, itemid):
from myapp.media.models import Document
import mimetypes
d = get_object_or_404(Document, pk=itemid)
f = get_from_s3(d.file_key)
mtype = mimetypes.guess_type(d.file_key)
resp = HttpResponse(f, mimetype=mtype[0])
resp['Content-Disposition'] = 'attachment; filename=%s' %
d.file_key.split('/')[-1]
return resp

def get_from_s3(skey):
import tempfile
k = get_key()
k.key = skey
f = tempfile.TemporaryFile(mode="wb")
k.get_contents_to_file(f)
f.seek(0)
return f

However, I'm getting a corrupted file. When I did `diff origfile.pdf
downloadedfile.pdf` I found the following error inserted into the
file:

> 
> Mod_python error: "PythonHandler django.core.handlers.modpython"
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in 
> HandlerDispatch
> result = object(req)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", 
> line 181, in handler
> return ModPythonHandler()(req)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", 
> line 172, in __call__
> for chunk in response:
>
>   File "/usr/lib/python2.5/site-packages/django/http/__init__.py", line 329, 
> in next
> chunk = self._iterator.next()
>
> IOError: [Errno 0] Error
>
> 

I thought I had found a discussion that linked this error to threading
in python - but I can't seem to find it again. Any ideas you have on
how to resolve this would be appreciated...


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



Re: Linking dropdowns using newforms

2007-10-03 Thread Emmchen

@ Hraban - Thank you for your reply.

Yes, I want to display up to four columns. The content of one column
depend on the selection in the previous column (exept for the first
one).

Column 1: Display a list of choices - (eg Systematic, Collection,
Growthplace, Heritage).
Column 2: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 1.
Column 3: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 2.
Column 4: Display a filtered result of PropertyValueCombo instances
with the selected value from Column 3.

I want the result from the first column to still be displayed while
the value in the second column get selected, and that the result from
the first and second column is displayed while the value in the third
column get selected etc.

The selected value in the last column (Column 4) will then be used to
filter out the Individual that correspond to that selected value.

Is it possible to use two or more forms at the same time? And is it
possible to desplay the selected values from one form while the next
form doesn't have a selected value yet. How does this work with
request/response?

My experience with JavaScript is seriously limited. Therefore do you
or does anybody else have any pointers where to start with JavaScript?

Thanks,
Emma


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: def __str__(self) error in tutorial part 1

2007-10-03 Thread Will McCutchen

Hi,

On Oct 2, 1:18 pm, rhett <[EMAIL PROTECTED]> wrote:
> 1) I am working in TextMate and copied/pasted below code. In TextMate
> the "def __str__(self)" is not indented from the pub_date line - it's
> the same indent.

I too use TextMate to do a lot of my Python development.  It
consistently over-indents my code when I copy and paste.  It's trying
to be helpful and "intelligently" indent the pasted code, but the
smart indentation doesn't seem to work very well with Python.

> I know indents are important - is there a way to set
> up TextMate to show correct indentation?

If you highlight the code that you want unindented, you can use
Command-[ to decrease the indentation by one level.

Hope this helps,


Will.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Error message when viewing admin? (ViewDoesNotExist at /admin/)

2007-10-03 Thread Gabriel Farrell

Did you have a view named "startsess" that you subsequently deleted?
Admin is looking for it but not finding it.  You may need to remove it
from django_content_type.  Try dropping that table from your database
and running python manage.py syncdb.

On Oct 3, 12:34 pm, Greg <[EMAIL PROTECTED]> wrote:
> Hello,
> Whenever I login to my admin view the very first thing I see if the
> following error.  It also happens occasionally when I'm going through
> my admin pages.
>
> ViewDoesNotExist at /admin/
> Tried startsess in module mysite.rugs.views. Error was: 'module'
> object has no attribute 'startsess'
> Request Method: GET
> Request URL:http://127.0.0.1:8000/admin/
> Exception Type: ViewDoesNotExist
> Exception Value:Tried startsess in module mysite.rugs.views. Error
> was: 'module' object has no attribute 'startsess'
> Exception Location: c:\Python24\lib\site-packages\django\core
> \urlresolvers.py in _get_callback, line 184
> Python Executable:  c:\Python24\python.exe
> Python Version: 2.4.4
>
> //
>
> Template error
>
> In template c:\python24\lib\site-packages\django\contrib\admin
> \templates\admin\base.html, error at line 28
> Caught an exception while rendering: Tried startsess in module
> mysite.rugs.views. Error was: 'module' object has no attribute
> 'startsess'
> 18  {% if not is_popup %}
> 19  
> 20  
> 21  
> 22  {% block branding %}{% endblock %}
> 23  
> 24  {% if user.is_authenticated and user.is_staff %}
> 25  
> 26  {% trans 'Welcome,' %} {% if user.first_name %}
> {{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %} strong>.
> 27  {% block userlinks %}
> 28  {%
> trans 'Documentation' %}
> 29  / {%
> trans 'Change password' %}
> 30  / {% trans
> 'Log out' %}
> 31  {% endblock %}
> 32  
> 33  {% endif %}
> 34  {% block nav-global %}{% endblock %}
> 35  
> 36  
> 37  {% block breadcrumbs %}{%
> trans 'Home' %}{% if title %} › {{ title|escape }}{% endif
> %}{% endblock %}
> 38  {% endif %}
>
> //
>
> Line 28 is highlighted in the above code.  This code is in red '{% url
> django.contrib.admin.views.doc.doc_index %}' from line 28
>
> Thanks for any help


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

2007-10-03 Thread Henning Hraban Ramm

Am 2007-10-03 um 18:30 schrieb Emmchen:


> I am wondering if it's possible to link dropdowns using newforms. I
> want to use the selected value in the first dropdown as the
> filtervalue for the next dropdown etc.
>

You want the options of the second select to change after selection  
of the first?
If you don't want to use two forms, you must use JavaScript (with or  
without AJAX) to change the values after the change.
Either you place different sets of options in hidden selects and show  
one of them depending on the selection,
or you must send an AJAX request to a django view that provides the  
needed values.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)

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

2007-10-03 Thread Joseph Heck

You're on the right track - missing the MySQL python libraries. It
looks like Python is also missing the zlib libraries...

not sure which OS you're using, but there's probably an "apt-get
install ..." or "rpm -Uvh ..." command that will get you the MySQL
Python libraries that you need. Looking on an Ubuntu box, the package
I installed was:

"apt-get install python-mysqldb"

-joe

On 10/3/07, swati <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I am setting up first django project. When I set up django without any
> database settings, I could see the first welcome page from django.
> After this initial success, when I specify the database settings in
> the 'settings.py' and tried to run django, I am getting error,-
>
> "ImproperlyConfigured: Error loading MySQLdb module: No module named
> MySQLdb"
>
> I have downloaded python-mysql and tried installing it, where I am
> getting error,-
>
> ---
> Traceback (most recent call last):
>   File "setup.py", line 5, in ?
> import ez_setup; ez_setup.use_setuptools()
>   File "/home/djtstdir/MySQL-python-1.2.2/ez_setup.py", line 85, in
> use_setuptools
> import setuptools; setuptools.bootstrap_install_from = egg
> zipimport.ZipImportError: can't decompress data; zlib not available
> ---
>
> I have installed zlib also, but getting same error.
>
> I am working remotly on linux
> I am working as root
> I have apache, mysql, python 2.4, and mod_python installed in my
> machine.
>
> Any idea what I am missing out? Please help.
>
> Many Thanks,
> Swati
>
>
> >
>

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

2007-10-03 Thread swati

Hi All,

I am setting up first django project. When I set up django without any
database settings, I could see the first welcome page from django.
After this initial success, when I specify the database settings in
the 'settings.py' and tried to run django, I am getting error,-

"ImproperlyConfigured: Error loading MySQLdb module: No module named
MySQLdb"

I have downloaded python-mysql and tried installing it, where I am
getting error,-

---
Traceback (most recent call last):
  File "setup.py", line 5, in ?
import ez_setup; ez_setup.use_setuptools()
  File "/home/djtstdir/MySQL-python-1.2.2/ez_setup.py", line 85, in
use_setuptools
import setuptools; setuptools.bootstrap_install_from = egg
zipimport.ZipImportError: can't decompress data; zlib not available
---

I have installed zlib also, but getting same error.

I am working remotly on linux
I am working as root
I have apache, mysql, python 2.4, and mod_python installed in my
machine.

Any idea what I am missing out? Please help.

Many Thanks,
Swati


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

2007-10-03 Thread James Bennett

On 10/3/07, Nabuco <[EMAIL PROTECTED]> wrote:
> I have a view which receives a list of items in my app to be deleted.
> After the deletion, I need to return a page containing the same origin
> page plus a message like "the items (items here) have been
> successfully deleted".

http://www.djangoproject.com/documentation/authentication/#messages

(this is how the admin displays that "X was successfully created" and
other such things)

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



Adding extra info to HttpResponseRedirect

2007-10-03 Thread Nabuco

I have a view which receives a list of items in my app to be deleted.
After the deletion, I need to return a page containing the same origin
page plus a message like "the items (items here) have been
successfully deleted".

So, after doing all the required stuff in the view, if I want to avoid
the typical browser scenario where the user "accidentally" re-submits
the POST information hitting the "reload" button (on that case the
view would return an error because the items have been already deleted
in the previous submit) I need to do an http redirect to an
intermediate view. I am trying to use HttpResponseRedirect but I
cannot figure out how to do this in a right way:

If I use GET as a container for the items with the redirect call,  the
items will appear as part of the URL in the browser, this looks ugly
to me

I don't know how to add POST info in a Danjo-way to the
HttpResponseRedirect, guess it's not possible unless I write the POST
manually in the HttpResposeRedirect header/body (no!). Anyway, using
POST to hide information also looks ugly to me.

So I may try to pass the Django request object to hold all the
information, that would be great, but how?

thanks in advance,

hector


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

2007-10-03 Thread Benjamin Slavin

Malcolm,

As always, your expedient and thoughtful reply is appreciated.

On 10/3/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> The only thing that is really guaranteed to be loaded sufficiently early
> in the process is the settings module (along with the __init__.py file
> in the directory containing settings.py). So one solution is to place
> the hook loading in there.

This was my first thought, but it feels very hackish.  As you point
out, there are reasons why this is not desirable (dependence on
settings and portability of the app).


> Another solution is to subclass the handler for the types of request you
> are doing (modpython or wsgi) and install your hooks as part of the
> request processing in the subclass.

This is certainly a possibility, but again it doesn't feel right.


> [...] in this case, there is no reliable way to ensure your code is run
> sufficiently early.

Thus, my question :-)

> There might be an argument for putting a hook in all
> the handlers (and the interactive shell setup in django-admin.py) to
> call a Python function that you specify in your settings file. That
> would allow use to do any pre-runtime setup in a portable fashion.

I like the direction of this approach, and think it is worth looking
into further.  I assume that your vision is for an iterable object
like MIDDLEWARE_CLASSES that can specify multiple pre-runtime
functions?

I'd be happy to file a ticket and provide a patch (assuming there's no
nastiness I'm overlooking).  I'll bring this up on django-dev once I
have the ticket and patch in place.


> The workaround [for the management shell] will be removed eventually
> [...] It's harmless in any case, so not a really high priority.

Understood.  I've tested it without the work-around, and have had no
problems (other than the one discussed here).


Many thanks,
  - Ben

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

2007-10-03 Thread Greg

Hello,
Whenever I login to my admin view the very first thing I see if the
following error.  It also happens occasionally when I'm going through
my admin pages.

ViewDoesNotExist at /admin/
Tried startsess in module mysite.rugs.views. Error was: 'module'
object has no attribute 'startsess'
Request Method: GET
Request URL:http://127.0.0.1:8000/admin/
Exception Type: ViewDoesNotExist
Exception Value:Tried startsess in module mysite.rugs.views. Error
was: 'module' object has no attribute 'startsess'
Exception Location: c:\Python24\lib\site-packages\django\core
\urlresolvers.py in _get_callback, line 184
Python Executable:  c:\Python24\python.exe
Python Version: 2.4.4

//

Template error

In template c:\python24\lib\site-packages\django\contrib\admin
\templates\admin\base.html, error at line 28
Caught an exception while rendering: Tried startsess in module
mysite.rugs.views. Error was: 'module' object has no attribute
'startsess'
18  {% if not is_popup %}
19  
20  
21  
22  {% block branding %}{% endblock %}
23  
24  {% if user.is_authenticated and user.is_staff %}
25  
26  {% trans 'Welcome,' %} {% if user.first_name %}
{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}.
27  {% block userlinks %}
28  {%
trans 'Documentation' %}
29  / {%
trans 'Change password' %}
30  / {% trans
'Log out' %}
31  {% endblock %}
32  
33  {% endif %}
34  {% block nav-global %}{% endblock %}
35  
36  
37  {% block breadcrumbs %}{%
trans 'Home' %}{% if title %} › {{ title|escape }}{% endif
%}{% endblock %}
38  {% endif %}

//

Line 28 is highlighted in the above code.  This code is in red '{% url
django.contrib.admin.views.doc.doc_index %}' from line 28

Thanks for any help

lp


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



Linking dropdowns using newforms

2007-10-03 Thread Emmchen

Hi,

I am wondering if it's possible to link dropdowns using newforms. I
want to use the selected value in the first dropdown as the
filtervalue for the next dropdown etc.

My model looks something like this:

///
models.py

class Property(models.Model):
""" Contains a list of properties that can be reused in several
property/value combinations. Category is the "top" property."""

property_name = models.CharField()

class PropertyValueCombo(models.Model):
""" Combines property with a value in a Combo that are the
buildingblocks that makes up the Individuals."""

property_name = models.ForeignKey(Property)
value_word = models.CharField(null = True, blank = True)
value_text = models.TextField(null = True, blank = True)
value_date = models.DateField(null = True, blank = True)
parent_combo = models.ForeignKey('self', null = True, blank = True,
related_name = 'parent_combo_child_set')
hybrid_parent_combo = models.ForeignKey('self', null = True, blank =
True, related_name = 'hybrid_parent_combo_child_set')

def __unicode__(self):
return '%s %s %s' % (self.value_word, self.value_text,
self.value_date)

class Individual(models.Model):
""" These objects represent the individual plants and animals that
are registered in the database."""

combo = models.ManyToManyField(PropertyValueCombo, filter_interface =
models.HORIZONTAL)
parent_individual = models.ForeignKey('self', null = True, blank =
True, related_name = 'parent_individual_child_set')
index_id = str(id)

def __unicode__(self):
return self.index_id


views.py

class FirstColumnForm(forms.Form):
alla_combo = PropertyValueCombo.objects.all()
val = []
for instance in alla_combo:
test=unicode(instance.property_name)
if test=='Category':
val.append(instance.value_word)
category = forms.MultipleChoiceField(choices=[(c, c) for c in val])

def first_column(request):
if request.method == 'POST':
kolumn_1 = FirstColumnForm(request.POST)
selected_category = request.POST['category']
return render_to_response('search.html',{'kolumn_1':kolumn_1,
'selected_category':selected_category})
else:
kolumn_1 = FirstColumnForm()
return render_to_response('search.html', {'kolumn_1':kolumn_1})
///

The form produces a MultipleChoiceField (MCF) and the user is able to
select a value. The value is then presented next to the first MCF. The
next step would be to  use the selected value as the filtervalue for
the second column, but this is where I've run into trubble.

I've tried to create a second form class for the second column, but I
then got an error saying that the form class had unknown parameters.
Since the class is validated  before any value is selected ie the
selected parameter is unknown.

I also have a second problem, which is that my first column will
display the wrong set of data when the request change. Anybody have a
better suggestion how I should go about displaying the data? This
might to a great extent be connected to the first problem...

I have been looking like crazy for a solution, but I still don't know
how to proceed. I would greatly appreciate if anybody could give me a
hint in the right direction (if there is one...)

Thanks in advance.

Emma


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

2007-10-03 Thread Richard Dahl
I can't see why that would cause a redirect, it is hard to diagnose a
problem without seeing the code or the server logs.  Is the get request for
the same URL?

On 10/3/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
>
> I'm working on an advanced search feature for a website and am using
> request.session to store the search terms so pagination will remember
> and paginate correctly.  While working with the built-in server I'm
> seeing that my search submit come through as a POST then almost
> immediately after I see another GET request.  I suspect that this code
> is causing the redirect...
>
> request.session['mykey'] = mydict
>
> Does that seem right that it would redirect?
>
> Thanks,
> Rob
>
>
> >
>

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



Re: python script

2007-10-03 Thread Joseph Heck

just modify sys.path as you need...

On 10/3/07, Xan <[EMAIL PROTECTED]> wrote:
>
> In http://code.djangoproject.com/ticket/5534 there is a howto for
> doing that.
> But it's only when the script is in the root project directory.
> What happens if we want the script in other location? What line we
> have to add?
>
> Thanks a lot,
> Xan.
>
> On Sep 18, 8:27 pm, Horst Gutmann <[EMAIL PROTECTED]> wrote:
> > You mean an error telling you that you need to set the
> > DJANGO_SETTINGS_MODULE environment variable? Or something else?
> >
> > os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'
> >
> > right at the top of yourscript(after the #! and the import for os ;) )
> > should solve this.
> >
> > Then you should probably also add the parent directory of your project
> > to sys.path :-)
> >
> > - Horst
> >
> > Xan wrote:
> > > Hi,
> >
> > > If we have the models models.py:
> >
> > > from django.db import models
> >
> > > class Poll(models.Model):
> > > question = models.CharField(max_length=200)
> > > pub_date = models.DateTimeField('date published')
> >
> > > class Choice(models.Model):
> > > poll = models.ForeignKey(Poll)
> > > choice = models.CharField(max_length=200)
> > > votes = models.IntegerField()
> >
> > > [example extracted 
> > > frohttp://www.djangoproject.com/documentation/tutorial01/]
> >
> > > how can I write apythonscriptfor create various polls?
> >
> > > I tried:
> >
> > > a.py:
> >
> > > #!/usr/bin/python
> > > from mysite.polls.models import Poll
> > > import datetime
> >
> > > i = 0
> > > while i<4:
> > > a = str(i)
> > > print a
> > > Poll.create(question=a, data=datetime.date.today())
> > > i = i+1
> >
> > > but when I runpythona.py in bash, there are problems with imports.
> > > What lines of imports we need for running a standalonepythonscript?
> >
> > > Thanks in advance,
> > > Xan.
> >
> > > PS: There is no doc in official site mentioning that. Maybe good to
> > > add it to site.
>
>
> >
>

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



Re: Does setting a session cause a redirect?

2007-10-03 Thread Joe

Can you post the command line output?

On Oct 3, 11:45 am, Rob Hudson <[EMAIL PROTECTED]> wrote:
> I'm working on an advanced search feature for a website and am using
> request.session to store the search terms so pagination will remember
> and paginate correctly.  While working with the built-in server I'm
> seeing that my search submit come through as a POST then almost
> immediately after I see another GET request.  I suspect that this code
> is causing the redirect...
>
> request.session['mykey'] = mydict
>
> Does that seem right that it would redirect?
>
> Thanks,
> Rob


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



Re: how to scale

2007-10-03 Thread James Bennett

On 10/3/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
> The only thing django app should know is that there are two different
> *kinds* of servers: read-only and whole access.  It doesn't matter how many
> servers you have - you may well have pool of masters and pool of slaves, it
> doesn't matter.

For *your* case. But remember that Django is expected to be generic
and broadly usable, which means that actually the decorators would
have to support, say, people who are sharding and want to have this
view write to that shard, and that view read from another, etc., etc.,
which means that your decorator scheme basically comes down, in the
end, to hard-coding database or cluster or shard names alongside each
view.

And again, I'd argue that this isn't something the application layer
needs to know or should have to know.

> And, completely unrelated to above, some companies made *business* decision
> to use MySQL Replication widely.  So if django doesn't support it, no big
> projects using django.

You mean no projects using MySQL Replication, which is very, very,
VERY far from "no big projects" -- there are plenty of big projects
using Django, they're just using smarter DB setups. Personally, I
think MySQL's standard attitude of "well, just completely rewrite your
application when you need more than one database" is the thing that's
not suitable for big projects (where you need to be thinking about,
and planning for, configurable scaling across multiple machines from
the very start, not pausing and rewriting when it's necessary);
anybody who paid a consultant to get that recommendation should ask
for their money back.


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



Does setting a session cause a redirect?

2007-10-03 Thread Rob Hudson

I'm working on an advanced search feature for a website and am using
request.session to store the search terms so pagination will remember
and paginate correctly.  While working with the built-in server I'm
seeing that my search submit come through as a POST then almost
immediately after I see another GET request.  I suspect that this code
is causing the redirect...

request.session['mykey'] = mydict

Does that seem right that it would redirect?

Thanks,
Rob


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



Re: Effective use of class_prepared signal

2007-10-03 Thread Malcolm Tredinnick

On Wed, 2007-10-03 at 11:23 -0400, Benjamin Slavin wrote:
> Hello all,
> 
> I'm trying to make use of the class_prepared signal to add some
> functionality to all models.
> 
> The problem I'm facing is how to properly register my listener.
> 
> I need to register the listener before any models are prepared, but I
> can't seem to figure out how to accomplish this.
> 
> Right now I have it registered in __init__.py in my application, and
> put that application first in my settings module.

The only thing that is really guaranteed to be loaded sufficiently early
in the process is the settings module (along with the __init__.py file
in the directory containing settings.py). So one solution is to place
the hook loading in there.

Now, it's possible/probable you don't want to do anything really
complicated in settings.py, particularly if what you want to do would
rely upon the settings. Since that module is still being imported when
your code is executed, you have to be a little careful. For simple
things, particularly code that doesn't rely on settings, you're fine:
just install your method immediately.

For more complex cases, install an initial method that works out whether
it has been called before or not and replaces itself with the real
method on the first call (registers the "real handler" and deregisters
itself, for example).

Another solution is to subclass the handler for the types of request you
are doing (modpython or wsgi) and install your hooks as part of the
request processing in the subclass.

Neither of these solutions would work if you were wanting to do this as
a third-party app, since both intrude on the setup of the user. However,
in this case, there is no reliable way to ensure your code is run
sufficiently early. There might be an argument for putting a hook in all
the handlers (and the interactive shell setup in django-admin.py) to
call a Python function that you specify in your settings file. That
would allow use to do any pre-runtime setup in a portable fashion. If
there's not some obvious reason why this is a bad idea, you might like
to open a ticket for this. I can't immediately think of any slippery
slope to doom that this would open up and I can think of some situations
where it would be useful.

> This works in the shell because of a work-around for #1796 that forces
> loading of all models through get_models (a work-around which,
> perhaps, should be removed since #1796 was fixed).  This work-around
> isn't present in the mod_python or wsgi handlers, so this approach
> doesn't work for non-interactive (shell) sessions.

The workaround will be removed eventually. I didn't remove it
immediately in case the last round of fixes to #1796 didn't completely
work -- people would have wanted the workaround put back immediately and
I didn't want the hassle for myself or the user base. It's harmless in
any case, so not a really high priority.

Regards,
Malcolm


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



Effective use of class_prepared signal

2007-10-03 Thread Benjamin Slavin

Hello all,

I'm trying to make use of the class_prepared signal to add some
functionality to all models.

The problem I'm facing is how to properly register my listener.

I need to register the listener before any models are prepared, but I
can't seem to figure out how to accomplish this.

Right now I have it registered in __init__.py in my application, and
put that application first in my settings module.

This works in the shell because of a work-around for #1796 that forces
loading of all models through get_models (a work-around which,
perhaps, should be removed since #1796 was fixed).  This work-around
isn't present in the mod_python or wsgi handlers, so this approach
doesn't work for non-interactive (shell) sessions.

Any assistance/ideas would be appreciated.

Thanks,
 - Ben

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

2007-10-03 Thread omat

So, here is my version, using the cache backend:

from datetime import timedelta, datetime
from django.core.cache import cache
from django.contrib.sites.models import Site

ONLINE_MINUTES = 10
CACHE_KEY = '%s_online_user_ids' % Site.objects.get_current().domain

_last_purged = datetime.now()

def get_online_user_ids():
user_dict = cache.get(CACHE_KEY)
return hasattr(user_dict, 'keys') and user_dict.keys() or []

class OnlineUsers(object):
def process_request(self, request):
if request.user.is_anonymous():
return

user_dict = cache.get(CACHE_KEY)
if not user_dict:
# initialization
user_dict = {}

now = datetime.now()
user_dict[request.user.id] = now

# purge
global _last_purged
if _last_purged + timedelta(minutes=ONLINE_MINUTES) < now:
purge_older_than = now - timedelta(minutes=ONLINE_MINUTES)
for user_id, last_seen in user_dict.items():
if last_seen < purge_older_than:
del(user_dict[user_id])
_last_purged = now

cache.set(CACHE_KEY, user_dict, 60*60*24)


This stores a dictionary in the form: {user_id: last_seen_time, ...}
in the cache and updates the cache once for every request by an
authenticated user.

An alternative would be to store a structure like Jeremy's,
{minute_seen: set(user_id, ...), ...} which I think will result in
nearly the same amount of cache hits on average.

I would like to hear your comments.




On 3 Ekim, 16:09, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On 10/3/07, omat <[EMAIL PROTECTED]> wrote:
>
> > I used it for some time and observed some inconsistencies. I think
> > this is because the code is not thread-safe.
>
> > Do you know a thread safe way of applying this approach?
>
> Well, "thread-safe" is a confusing term for something like this, but
> you're right that it has to do with the operating environment. I had
> similar problems with an application of mine, when I used a
> module-level dictionary to store a cache that would be updated. What I
> ended up having to do is using Django's cache framework, which will
> work fine in multi-process setups, as long as you don't use the
> "simple" or "local" cache backends.
>
> Don't let the local backend's claim of being multi-process thread-safe
> fool you. What that means is that multiple threads and processes won't
> interact with each other, which is the usual definition of the term.
> But since you actually do want multiple threads and processes to share
> that information, its multi-process/thread-safety is actually a
> problem. That's why I said it's a confusing term for this situation.
> If you use the file, db or memcached backends, you should be fine.
>
> -Gul


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



Re: python script

2007-10-03 Thread Xan

In http://code.djangoproject.com/ticket/5534 there is a howto for
doing that.
But it's only when the script is in the root project directory.
What happens if we want the script in other location? What line we
have to add?

Thanks a lot,
Xan.

On Sep 18, 8:27 pm, Horst Gutmann <[EMAIL PROTECTED]> wrote:
> You mean an error telling you that you need to set the
> DJANGO_SETTINGS_MODULE environment variable? Or something else?
>
> os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'
>
> right at the top of yourscript(after the #! and the import for os ;) )
> should solve this.
>
> Then you should probably also add the parent directory of your project
> to sys.path :-)
>
> - Horst
>
> Xan wrote:
> > Hi,
>
> > If we have the models models.py:
>
> > from django.db import models
>
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
>
> > class Choice(models.Model):
> > poll = models.ForeignKey(Poll)
> > choice = models.CharField(max_length=200)
> > votes = models.IntegerField()
>
> > [example extracted 
> > frohttp://www.djangoproject.com/documentation/tutorial01/]
>
> > how can I write apythonscriptfor create various polls?
>
> > I tried:
>
> > a.py:
>
> > #!/usr/bin/python
> > from mysite.polls.models import Poll
> > import datetime
>
> > i = 0
> > while i<4:
> > a = str(i)
> > print a
> > Poll.create(question=a, data=datetime.date.today())
> > i = i+1
>
> > but when I runpythona.py in bash, there are problems with imports.
> > What lines of imports we need for running a standalonepythonscript?
>
> > Thanks in advance,
> > Xan.
>
> > PS: There is no doc in official site mentioning that. Maybe good to
> > add it to site.


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



Re: deleting many2many relationship in object

2007-10-03 Thread Nabuco

Thanks a lot Russ, I am sometimes lazy reading documentation and miss
things...

cheers,

hector

On Oct 3, 1:44 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 10/3/07, Nabuco <[EMAIL PROTECTED]> wrote:
>
>
>
> > In a view I receive some videokeyword id's existing in a Video to be
> > deleted. I tried
>
> > sql = 'videokeyword_id IN (keywords)' <-- (filling keywords
> > placeholder with the id's, of course)
> > keywords = get_list_or_404(video.keywords_list.extra(where=[sql]))
> > for k in keywords:
> > k.delete()
>
> It looks to me that what you want is:
>
> video.keywords_list.remove(keywords)
>
> where keywords is a list of Keyword objects, or a list of primary keys
> of Keyword objects.
>
> For more details:http://www.djangoproject.com/documentation/db-api/#backward
>
> 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: default values within postgres as defined in the model

2007-10-03 Thread Txus Sanchez

Hi again, I answer myself

> http://code.google.com/p/django-check-constraints/
>
> But unlucky (nothing to download). What happened? Did it finished?
>

http://code.google.com/p/google-summer-of-code-2007-django/downloads/list

Here it is. BTW, are you going to include in the django svn version?

Cheers

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



Re: Unexpected date translation

2007-10-03 Thread Dirk Eschler

On Mittwoch, 3. Oktober 2007, Malcolm Tredinnick wrote:
> On Wed, 2007-10-03 at 15:37 +0200, Dirk Eschler wrote:
> > Hi,
> >
> > i'm using a date based generic on a multi-language website. When the
> > online language is set to German, {{ date|date:"M"|lower }} returns a
> > localized value - "mär" instead of "mar" that is. This breaks the link i
> > intend to build. Can the localisation be turned of somehow in this case?
>
> Not directly, no. The date filter is locale-aware and designed for
> created human readable strings.
>
> You would need to write your own filter that does the same thing but
> after first calling django.utils.translation.deactivate() (or maybe call
> activate('en') so that the result isn't dependent on your settings
> file). Remember to retrieve the current locale with get_language() first
> and set it back afterwards or you may get some weird side-effects.

Thanks for your help Malcolm. I will give it a try.

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 
http://www.krusader.org

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



how to apply model method to Queryset in the most efficient way?

2007-10-03 Thread zeliboba

hi all

I have a model like this (I intentionally replaced the details by
dots):

class Family(...):
   name = ... # field contains non-unique values
   age = ...
   # model method to get children, here operations with another model
are involved
   def getChildren():
 return ...

when I prepare data for custom view, I need to process like like this:

def old(request):
   a = Family.objects.filter(age__gt=50)
   # then I need to apply getChildren() to all members of queryset a
   # the most the easiest way is
   b = [m.getChildren() for m in a]
   # then I pass it to template

the questions are:
1. is it efficient way?
2. is it better for performance to send queryset to template? it does
it matter?
3. if "yes" to 2nd question, how to form such queryset, taking into
account need to execute model method?
4. if b contain non-unique values and I want to use .distinct()
method, how to create a queryset instead of list?


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



Re: default values within postgres as defined in the model

2007-10-03 Thread Txus Sanchez

Hi all,

Here a new Django user (shortly I hope developer). Congratulations for
the framework!

> There is a Google Summer of Code project going on at the moment for
> Django which is designed to allow for adding database constraints. You
> might want to have a look at that (search for django-check-constraints
> on Google projects hosting).

I've just checked

http://code.google.com/p/django-check-constraints/

But unlucky (nothing to download). What happened? Did it finished?

Thank you 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: Unexpected date translation

2007-10-03 Thread Malcolm Tredinnick

On Wed, 2007-10-03 at 15:37 +0200, Dirk Eschler wrote:
> Hi,
> 
> i'm using a date based generic on a multi-language website. When the online 
> language is set to German, {{ date|date:"M"|lower }} returns a localized 
> value - "mär" instead of "mar" that is. This breaks the link i intend to 
> build. Can the localisation be turned of somehow in this case? 

Not directly, no. The date filter is locale-aware and designed for
created human readable strings.

You would need to write your own filter that does the same thing but
after first calling django.utils.translation.deactivate() (or maybe call
activate('en') so that the result isn't dependent on your settings
file). Remember to retrieve the current locale with get_language() first
and set it back afterwards or you may get some weird side-effects.

Regards,
Malcolm



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



fieldsets in newforms

2007-10-03 Thread jrs

I am trying to use fieldsets and newforms,  looking at the newforms-
admin branch it appears as if support will be included in the admin,
but I am not sure of how to integrate this into my custom forms.

Is the following possible / are there plans for doing something like
the following?

{{ form.as_table }}

resulting html along the lines of:


  
   
  



  
  
  



or even

{{ form.fieldset1.as_table }}

{{ form.fieldset2.as_table }}

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



Unexpected date translation

2007-10-03 Thread Dirk Eschler

Hi,

i'm using a date based generic on a multi-language website. When the online 
language is set to German, {{ date|date:"M"|lower }} returns a localized 
value - "mär" instead of "mar" that is. This breaks the link i intend to 
build. Can the localisation be turned of somehow in this case? 

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 
http://www.krusader.org

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



Re: keeping track of online users

2007-10-03 Thread Marty Alchin

On 10/3/07, omat <[EMAIL PROTECTED]> wrote:
> I used it for some time and observed some inconsistencies. I think
> this is because the code is not thread-safe.
>
> Do you know a thread safe way of applying this approach?

Well, "thread-safe" is a confusing term for something like this, but
you're right that it has to do with the operating environment. I had
similar problems with an application of mine, when I used a
module-level dictionary to store a cache that would be updated. What I
ended up having to do is using Django's cache framework, which will
work fine in multi-process setups, as long as you don't use the
"simple" or "local" cache backends.

Don't let the local backend's claim of being multi-process thread-safe
fool you. What that means is that multiple threads and processes won't
interact with each other, which is the usual definition of the term.
But since you actually do want multiple threads and processes to share
that information, its multi-process/thread-safety is actually a
problem. That's why I said it's a confusing term for this situation.
If you use the file, db or memcached backends, you should be fine.

-Gul

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



Re: how to do something at startup

2007-10-03 Thread Forest Bond
Hi,

On Sat, Sep 29, 2007 at 10:06:19PM -0700, pength wrote:
> well, I am doing some similiar things, for example, I want to show the
> time when this Django/Apache server start, and set some "gloabl
> variables" which all of my apps can use, just do like this:
> I have a primary app named "city", and every other app's views.py will
> add a line as "from myproject.city.models import * ". So in this
> models.py, just add codes like:
> SERVER_START_TIME = datetime.datetime.now()
> MY_GLOBAL_VAR = (1,2,3)
> #test
> def my_init():
> for i in range(1,11):
> print i
> 
> my_init()

Except when apache spawns multiple processes or threads you'll probably get a
different answer depending on which one you happen to end up talking to.  That
may be acceptable, though.

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


signature.asc
Description: Digital signature


Re: forum to mailing list integration

2007-10-03 Thread Ian Lawrence

Ola
I should think this functionality would be a valuable addition to
Django so thx for your pointers.
abracos
Ian

On 10/2/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2007-10-02 at 13:22 -0400, Ian Lawrence wrote:
> > Hi
> > I have a requirement for all forum posts to go to a mailing list (this
> > i have implemented) but also that all subsequent posts on the mailing
> > list to the thread appear on the forum too.
> > Has anyone ever implemented anything like this before?  I would prefer
> > a mailman solution but that is not crucial
>
> Not a lot of Django relevance here.
>
> Search for mail2news gateways and things like that. There are plenty of
> SMTP <-> NNTP solutions around, so customising one for a forum wouldn't
> be too hard. The only semi-tough part if identifying which thread to
> attach things to on the forum side, but even that's usually pretty easy.
>
> Malcolm
>
>
>
> >
>


-- 
http://ianlawrence.info

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

2007-10-03 Thread AniNair

time: '00:00:00'
I found it .
Thank you.


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

2007-10-03 Thread niklas.voss

On 3 Okt., 13:18, peschler <[EMAIL PROTECTED]> wrote:
> Hi Niklas,
>
> > So in code it should look like this:
> > If user is my argument that was given to render_to_response, i want to
> > give the function the submodel status of user; like this:
> > {{ percentbar user.status }}
>
> Some docs on how to achieve this can be found 
> here:http://www.djangoproject.com/documentation/templates_python/#passing-...
>
> Hope that helps,
> Peter
>
> > Is there a way to give this variable to the percentbar function in the
> > template?
> > Or should I do it through the views.py...
>
> > I hope you understood my problem, because my english is very bad :)
>
> > Niklas Voss

Thank you, i was looking for that :)
You helped me very well, so big thanks!

Niklas Voss


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

2007-10-03 Thread Panos Laganakos

Thanks for the answer Lemuel :)

I added a get_images method in the (example) Toy model, which returns
a list of the pictures related to it. Which basically just wraps
things up:

def get_images(self):
images = self.toypicture_set.all()
return images

Doing a select_related, sounds more efficient though, I'll try it out.

On Oct 2, 6:51 pm, Lemuel Formacil <[EMAIL PROTECTED]> wrote:
> On Sep 29, 2007, at 6:14 PM, Panos Laganakos wrote:
>
>
>
>
>
> > On Sep 28, 12:18 pm, Panos Laganakos <[EMAIL PROTECTED]>
> > wrote:
> >> Having two different models, ie: Toy, ToyPicture.
>
> >> ToyPicture, has a ForeignKey to Toy, so you can define many pictures,
> >> that relate to a specific toy.
>
> >> The question is this: in which way should I make the data available
> >> for viewing?
>
> >> 1. Create list/detail generic views for Toy? That would mean I would
> >> have to create a custom template tag, in order to make the  
> >> ToyPicture,
> >> available at the template level of Toy.
>
> >> 2. Create my own custom views of Toy/ToyPicture.
>
> >> What we should consider best practice, or is there's a completely
> >> different way to do it?
>
> Hi, Panos.
>
> Total newbie here with the same "problem" you have, but I think your  
> ToyPicture objects should already be accessible in your template by  
> doing a 'toypicture_set.all' call to your Toy object.
>
> In the template called by your Toy model's object_detail view, for  
> example, you can do a
>
> {% for toypicture in object.toypicture_set.all %}
>
> to iterate through the ToyPicture objects.  In my case though, I'm  
> also not so sure if this is a good way (or "the way") for accessing  
> the related objects when using the generic views.  (I hope someone  
> can clarify this.)
>
> > I created a list/detail generic view for Toy, and passed ToyPicture
> > objects, as an extra_context. That seems to work, not sure, how to
> > filter the objects at a URLconf level though, if that's possible, or
> > if I'll have to filter it at a template level.
>
> > Still not sure if this is the *best* way to do it.
>
> Regarding doing a 'filter' on the queryset supplied to generic views,  
> I found this article by Malcolm Tredinnick while searching the 'net  
> for example usage of generic views:
>
> http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-
> generic-views/
>
> In that article he wrote a view to wrap the call to the generic_view  
> and supply a filtered queryset.  (I think it's also a good idea to  
> supply a 'select_related()'ed queryset to your Toy model's  
> object_detail so you don't incur another database hit when accessing  
> the related ToyPicture objects).
>
> HTH,
>
> Lemuel


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

2007-10-03 Thread peschler

Hi Niklas,



> So in code it should look like this:
> If user is my argument that was given to render_to_response, i want to
> give the function the submodel status of user; like this:
> {{ percentbar user.status }}
>

Some docs on how to achieve this can be found here:
http://www.djangoproject.com/documentation/templates_python/#passing-template-variables-to-the-tag

Hope that helps,
Peter

> Is there a way to give this variable to the percentbar function in the
> template?
> Or should I do it through the views.py...
>
> I hope you understood my problem, because my english is very bad :)
>
> Niklas Voss


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



Re: how to scale

2007-10-03 Thread Andrey Khavryuchenko


 JB> On 10/2/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
 >> Shouldn't it?  In case of MySQL replication (which is quite widely used)
 >> and transactions someone somehow *has* to decide where the whole
 >> transaction is going - to a master or to a slave.

 JB> In the case of MySQL, use MySQL Cluster, which designates a "SQL Node"
 JB> to receive the queries and route them through the cluster.

I know about MySQL Cluster.  The obvious disadvantage is that the whole
database should be in main memory.  Kiss goodbye to a bunch of cheap
servers sitting close to actual users.

There are also replication tweaks like multi-master replication, but they
are what they are - the tweaks.  If they break, you keep both pieces of
your db.

 >> The most obvious candidate for "someone" is the developer and the
 >> housekeeping stuff could be hidden in decorators.  I wrote a bit more on
 >> this at [1] (no working code yet, sorry).

 JB> So when you change the number of databases in your cluster, do you
 JB> also have to update *every* view in your application? 

Why?

The only thing django app should know is that there are two different
*kinds* of servers: read-only and whole access.  It doesn't matter how many
servers you have - you may well have pool of masters and pool of slaves, it
doesn't matter.

And, completely unrelated to above, some companies made *business* decision
to use MySQL Replication widely.  So if django doesn't support it, no big
projects using django.

-- 
Andrey V Khavryuchenko - http://a.khavr.com/
Django NewGate -  http://www.kds.com.ua/djiggit/
Chytach - http://www.chytach.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
-~--~~~~--~~--~--~---



new django install

2007-10-03 Thread Matt Davies

Hello everyone

Can anyone recommed a good tutorial on  how to install django mysql
and fastcgi on a Fedora Core 6 box?

It's my box so there's no need to worry about hosting companies not
allowing certain things.

Any help, greatly appreciated.

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



keeping track of online users

2007-10-03 Thread omat

Hi,

In this thread, closed due to inactivity:
http://groups.google.com/group/django-users/browse_thread/thread/6f5f759d3fd4318a/
Jeremy Dunck offers a resource friendly way to keep track of online
users (http://groups.google.com/group/django-users/attach/
c2f60227b0f2d040/OnlineUsers.py?part=2)

I used it for some time and observed some inconsistencies. I think
this is because the code is not thread-safe.

Do you know a thread safe way of applying this approach?

Regards,
oMat


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



fixtures

2007-10-03 Thread AniNair

Hi...
My yaml file is
-   fields: {time: '0:00'}
model: utils.Hour
pk: 01
-   fields: {time: '0:30'}
model: utils.Hour
pk: 02
-   fields: {time: '1:00'}
model: utils.Hour
pk: 03

 The model for this is
from django.db import models

class Hour(models.Model):
time=models.TimeField(max_length=10)

class Admin:
pass

def __str__(self):
return "%s" % self.time

from the site admin, when trying to access Hours, this gives me an
error
ValueError at /admin/utils/hour/
need more than 2 values to unpack
Request Method: GET
Request URL: http://localhost:8000/admin/utils/hour/
Exception Type: ValueError
Exception Value: need more than 2 values to unpack
Exception Location: D:\Python25\Lib\site-packages\django\db\backends
\util.py in typecast_time, line 63
Python Executable: D:\Python25\python.exe
Python Version: 2.5.1
Can someone please help?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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: Problems creating a project with django-admin startproject (New Django user)

2007-10-03 Thread Nis Jørgensen

[EMAIL PROTECTED] skrev:
> Just installed python/apache/django/mod_python with all the latest
> versions.
>
> I think I got most of my PATH variables set up correctly. However,
> when I try:
>
> C:\django>django-admin.py startproject testproject1
> Traceback (most recent call last):
>   File "C:\Python25\Scripts\django-admin.py", line 5, in 
> management.execute_from_command_line()
>   File "C:\Python25\lib\site-packages\django\core\management
> \__init__.py", line
> 255, in execute_from_command_line
> utility.execute()
>   File "C:\Python25\lib\site-packages\django\core\management
> \__init__.py", line
> 215, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python25\lib\site-packages\django\core\management\base.py",
> line 70,
> in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "C:\Python25\lib\site-packages\django\core\management\base.py",
> line 84,
> in execute
> output = self.handle(*args, **options)
>   File "C:\Python25\lib\site-packages\django\core\management\base.py",
> line 152,
>  in handle
> label_output = self.handle_label(label, **options)
>   File "C:\Python25\lib\site-packages\django\core\management\commands
> \startproje
> ct.py", line 30, in handle_label
> settings_contents = open(main_settings_file, 'r').read()
> IOError: [Errno 2] No such file or directory: 'C:\\django\
> \testproject1\\setting
> s.py'
>
> What might be wrong ? :/ Googling in general hasn't turned up much.
> I'm pretty newb all around though so it very well may be something
> simple and obvious. If more information is needed I can furnish that.
>   
Was the directory "c:\django\testproject1" created? Is there a
settings.py file? Is there something screwy going on with permissions?
Which version of Windows is this - it seems "everyone" is having
problems with permissions in Vista ...

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: Custom validation for models in admin

2007-10-03 Thread Rob Slotboom

Hi Mike,

I have the same problem with my model. (Link below)
Reading your "points to a .validate() on the model" raises the
following question.
Have you tried it?

http://groups.google.com/group/django-users/browse_thread/thread/bd2b2c24f3879690


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

2007-10-03 Thread Rob Slotboom

Addition:

> This is my model and I use a custom save to prevent the creation of a
> category with a parent_id which is the same a the current_id (child of
> itself)

When an error occurs an ugly error message apears so I tried to create
a custom validator.
Custom validator didn't work because of "no object_id to check upon".
Creating a Custom manipulator doesn't seem to work in admin.

Can someone show me a solution to get the validation done in admin?

Thanks


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



Re: trying to make Django work with fastcgi

2007-10-03 Thread [EMAIL PROTECTED]

I actually got fed up, and nearly resolved to switch either
frameworks(pylons, turbogears) or webhosts(webfaction, dreamhost).

I deleted everything in a fit and started doing some research. I ran
across this in a python installation guide:

"At this point, every tutorial around the web will tell you to use
flup and then there will be pain and hair pulling because you won't
understand why it's not working (unless you ask Allan Saddi to check
your setup, that is. Thank you Allan!).

The solution is to use the supposed to be obsolete fcgi.py script, so
let's install it:

The problem with flup (as found by Allan itself) is that it takes too
long to start and it seems that FastCGI on Dreamhost will wait for a
maximum of 3 seconds. fcgi.py instead is simpler (doesn't do thread
pooling for example) and therefore faster to start. "

What ended up working was simply downloading fcgi.py into my webroot.

Not entirely sure why (and I'm ok with that for now), but it works
like a dream.

I do appreciate your responses regardless. Thank you.

And David, you might want to check out 
http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/.
It's a tutorial for getting started with Django on Dreamhost, but is
excellent and cross-applicable. The only difference is that dreamhost
and ASO handle subdomain differently, so where he writes ~/
django.mydomain.com, substitute ~/www/django (which is automatically
created for you when you create the django.mydomain.com subdomain in
cPanel)



On Oct 2, 11:19 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
> Have you already tried it with method=prefork instead of method=threaded?
>
> 2007/10/2, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
>
> > I'm exactly there with you, David. Same with the manage.py. I can even
> > sync up fine with MYSQL.
>
> > If anybody has any ideas, I'm more than willing to try pretty much
> > anything at this point.
>
> > On Oct 2, 5:30 am, David Brown <[EMAIL PROTECTED]> wrote:
> > > I'm actually having the exact same problem (I'm even an ASO customer, as
> > > well). I got rid of the permission errors by changing the permissions on
> > > dispatch.fcgi to 755. However, my .htaccess and dispatch.fcgi are
> > > exactly the same (except that I removed the path stuff, since django and
> > > flup are already in my path). I was able to run manage.py without any
> > > errors, so that pretty much rules out import exceptions and such.
>
> > > Any ideas what else might be causing this?
>
> > > Thanks,
> > > David Brown
>
> > > [EMAIL PROTECTED] wrote:
> > > > Hi,
>
> > > > I'm new at this - learning as I go, but I can't seem to get Django
> > > > running with fastcgi.
>
> > > > A Small Orange, my webhost, doesn't have mod_python support, so I've
> > > > been trying to follow a number of different recommendations online to
> > > > try and get my site up and running.
>
> > > > I've installed flup, downloaded the django trunk, created a project,
> > > > and placed a 'dispatch.fcgi' file in the web root.
>
> > > > If I point my browser to the dispatch.fcgi file, it spins and spins
> > > > forever, not even bothering with the kindness of timing out.
>
> > > > If I run the dispatch.fcgi file in the shell, I get the following
> > > > error:
>
> > > >> # ./dispatch.fcgi
> > > >> WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
> > > >> WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
> > > >> WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
> > > >> WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
> > > >> Status: 301 MOVED PERMANENTLY
> > > >> content-type: text/html; charset=utf-8
> > > >> location:http://localhost:80/
>
> > > > my .htaccess file:
> > > > 
> > > > AddHandler fastcgi-script .fcgi
> > > > RewriteEngine On
> > > > RewriteBase /
> > > > RewriteRule ^(media/.*)$ - [L]
> > > > RewriteRule ^(admin_media/.*)$ - [L]
> > > > RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> > > > RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
> > > > 
>
> > > > my dispatch.fcgi file:
> > > > 
> > > > #!/usr/bin/env python
> > > > import sys, os
>
> > > > # Add a custom Python path.
> > > > sys.path.insert(0, "/home/soulgt/projects/django/trunk")
> > > > sys.path.insert(0, "/home/soulgt/projects/flup/trunk/flup")
> > > > sys.path.insert(0, "/home/soulgt/projects")
>
> > > > # Set the DJANGO_SETTINGS_MODULE environment variable.
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = "pythonlearning.settings"
>
> > > > from django.core.servers.fastcgi import runfastcgi
> > > > runfastcgi(method="threaded", daemonize="false")
> > > > 
>
> > > > I have no idea what's going on and really want to get this off the
> > > > ground. Any help would be greatly appreciate - 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 

Re: trying to make Django work with fastcgi

2007-10-03 Thread Horst Gutmann

Have you already tried it with method=prefork instead of method=threaded?

2007/10/2, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> I'm exactly there with you, David. Same with the manage.py. I can even
> sync up fine with MYSQL.
>
> If anybody has any ideas, I'm more than willing to try pretty much
> anything at this point.
>
> On Oct 2, 5:30 am, David Brown <[EMAIL PROTECTED]> wrote:
> > I'm actually having the exact same problem (I'm even an ASO customer, as
> > well). I got rid of the permission errors by changing the permissions on
> > dispatch.fcgi to 755. However, my .htaccess and dispatch.fcgi are
> > exactly the same (except that I removed the path stuff, since django and
> > flup are already in my path). I was able to run manage.py without any
> > errors, so that pretty much rules out import exceptions and such.
> >
> > Any ideas what else might be causing this?
> >
> > Thanks,
> > David Brown
> >
> > [EMAIL PROTECTED] wrote:
> > > Hi,
> >
> > > I'm new at this - learning as I go, but I can't seem to get Django
> > > running with fastcgi.
> >
> > > A Small Orange, my webhost, doesn't have mod_python support, so I've
> > > been trying to follow a number of different recommendations online to
> > > try and get my site up and running.
> >
> > > I've installed flup, downloaded the django trunk, created a project,
> > > and placed a 'dispatch.fcgi' file in the web root.
> >
> > > If I point my browser to the dispatch.fcgi file, it spins and spins
> > > forever, not even bothering with the kindness of timing out.
> >
> > > If I run the dispatch.fcgi file in the shell, I get the following
> > > error:
> >
> > >> # ./dispatch.fcgi
> > >> WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
> > >> WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
> > >> WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
> > >> WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
> > >> Status: 301 MOVED PERMANENTLY
> > >> content-type: text/html; charset=utf-8
> > >> location:http://localhost:80/
> >
> > > my .htaccess file:
> > > 
> > > AddHandler fastcgi-script .fcgi
> > > RewriteEngine On
> > > RewriteBase /
> > > RewriteRule ^(media/.*)$ - [L]
> > > RewriteRule ^(admin_media/.*)$ - [L]
> > > RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> > > RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
> > > 
> >
> > > my dispatch.fcgi file:
> > > 
> > > #!/usr/bin/env python
> > > import sys, os
> >
> > > # Add a custom Python path.
> > > sys.path.insert(0, "/home/soulgt/projects/django/trunk")
> > > sys.path.insert(0, "/home/soulgt/projects/flup/trunk/flup")
> > > sys.path.insert(0, "/home/soulgt/projects")
> >
> > > # Set the DJANGO_SETTINGS_MODULE environment variable.
> > > os.environ['DJANGO_SETTINGS_MODULE'] = "pythonlearning.settings"
> >
> > > from django.core.servers.fastcgi import runfastcgi
> > > runfastcgi(method="threaded", daemonize="false")
> > > 
> >
> > > I have no idea what's going on and really want to get this off the
> > > ground. Any help would be greatly appreciate - 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
-~--~~~~--~~--~--~---