Re: django twisted model

2009-05-21 Thread Timboy

Anyone familiar with using twisted and hooking it to a model?

On May 16, 8:55 pm, Timboy  wrote:
> I am looking to make a webmail client proof of concept in django. I
> ran across twisted mail and this 
> post:http://clemesha.org/blog/2009/apr/23/Django-on-Twisted-using-latest-t...
> showing how to use django on twisted.
>
> Can anyone point me in the right direction for actually getting data
> out of a twisted app into a django mail model?
>
> TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using Ajax with django from different domain and technology

2009-05-21 Thread Abhishoka

Hi:

We are a non-profit charity organization having 25+ websites and want
to maintain a centralized database for the various events happening at
different places. The database (MySql) has been implemented and we use
the django framework admin module to communicate with the database.
Our different sites use asp, php and plain html pages. In order to
fetch data through the django framework and use it in all our sites we
thought of using Ajax technology which runs on client side and should
be independent of server technology. Different web sites are located
in different domains.

How to achieve this? Would Dujo, Jquery, Prototype, etc. help in this
regard? Web sites running in different technologies in different
domains need to communicate with the server running Django framework
and get the data - any suggestions on how to go about implementing
this? Sample code / URLs to the code / information would really help.

- Abhishoka

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



Models with behavior

2009-05-21 Thread vishy

Hi,

I have some functionality which needs to be part of a class,which I
don't want to persist in database.Where should I put such a class? In
models.py?

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



Decimal format fields in Admin

2009-05-21 Thread Kostas M

I have a model/table including a field declaration:

money=models.DecimalField(max_digits=12,
decimal_places=2,verbose_name=u'π/υ').

When I see this field in the Admin pages, this field is just a box,
without any formatting,
e.g. thousand separation marks, which is important for the visibility
of the amounts,
such as 1700 instead of 17.000.000,00   (in my country we use '.'
as thousand
separators, and ',' for decimals).

Is it possible such a display in the Admin pages?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Decimal format fields in Admin

2009-05-21 Thread Kostas M


I have a model/table including a field declaration:

money=models.DecimalField(max_digits=12,
decimal_places=2,verbose_name=u'π/υ').

When I see this field in the Admin pages, this field is just a box,
without any formatting,
e.g. thousand separation marks, which is important for the visibility
of the amounts,
such as 1700 instead of 17.000.000,00   (in my country we use '.'
as thousand
separators, and ',' for decimals).

Is it possible such a display in the Admin pages?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ignoring Definite/Indefinite Articles when Sorting

2009-05-21 Thread Darryl Ross

On 22/05/2009 12:12 PM, Sam Chuparkoff wrote:
> On May 21, 10:10 pm, Darryl Ross  wrote:
>> I have searched around but not really found an answer to this. For a
>> project I am working on the customer wants a list of publications to be
>> sorted alphabetically, but ignoring the definite/indefinite articles
>> "the/a/an".
>
> You could create a new field in the model to hold the text you do want
> to sort and update it on model.save().

Yeah, that's what I've done for the moment, I was just wondering if 
there was another way without having to duplicate the data.

-- 
Darryl Ross, VK5LBJ
AFOYI, Information Technology Solutions
e: dar...@afoyi.com
p: +61 8 7127 1831
f: +61 8 8425 9607

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



Re: Cannot reload a Django models module within a "manage.py shell" session

2009-05-21 Thread Sam Chuparkoff

Reloading your models module is not going to give you different model
classes, because django tracks these classes by name. This is why the
tutorial instructs you to start a new shell after you've modified your
models.

sdc



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



Why does form.is_valid() throw ValueError?

2009-05-21 Thread Rex

I have the following code in a view, where UserSurveyForm is a
ModelForm.

f = UserSurveyForm(request.POST, instance=thisuser)
if f.is_valid():
[...]

When I try submitting valid data, this works fine. However, when I
submit an incomplete form, I get the following traceback:

[...]
  50. if f.is_valid():
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
  319. return save_instance(self, self.instance,
self._meta.fields, fail_message, commit)
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
save_instance
  42.  " validate." % (opts.object_name,
fail_message))

Exception Type: ValueError at /games/pd/survey/
Exception Value: The User could not be changed because the data didn't
validate.

Based on the documentation I've read, I thought that is_valid() should
just return False if the form doesn't validate, instead of throwing an
error. Any information on this?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IOError: request data read error (revisited)

2009-05-21 Thread Graham Dumpleton



On May 22, 12:31 pm, Jeff FW  wrote:
> I've had the same problem, and can't figure out how to resolve it.  It
> seems to have nothing to do with the amount of data being transfered:
> it happens occasionally on the smallest of page requests/responses.
> It also doesn't seem to be related to browser, unless several
> different versions of IE *and* Safari have the same problem.  I tried
> disabling keepalives for Safari at least, and it doesn't seem to have
> helped.  I'd prefer not to disable keepalives in general, if I can
> avoid it.
>
> All of the error messages I've received have shown in the traceback
> that they're coming through this 
> function:http://code.djangoproject.com/browser/django/trunk/django/core/handle...
>
> It seems to me like there's an easy workaround (I'm sure the actual
> fix has to be much lower level, in WSGI or Apache [or even lower])
> that would at least stop my users from getting 500 errors: wrap the
> contents of that function in a try block, and *don't* raise the
> exception.
>
> Otherwise, I'd have to wrap every view that uses POST in that, which
> would be very annoying.  Or maybe write middleware that just peeks at
> POST before anything else gets it, so that I could catch it there.
>
> Thoughts?

If clients are actually see a 500 error response, at least means that
return part of socket connection hasn't been closed. Is that want you
really meant, or is the 500 error in the logs and clients get a blank
page.

If you could duplicate it, which it seems you can't, I would have
suggested using second recipe in:

  
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response

to try and capture request content and response to see how much of the
request is actually being received.

BTW, are you using mod_wsgi embedded mode or daemon mode?

Also post an actual example traceback and what errors you get in the
Apache error log just to validate the nature of the problem.

Graham

> Thanks,
> Jeff
>
> On Mar 31, 6:40 pm, Graham Dumpleton 
> wrote:
>
> > On Apr 1, 1:34 am, akaihola  wrote:
>
> > > We ran into the same issue Chunlei Wu described in January[1]. A user
> > > was trying to upload large files and all we got were 500 errors by e-
> > > mail:
>
> > >   File "/home/citedesarts/src/django/django/http/multipartparser.py",
> > > line 406, inread
> > >IOError:requestdatareaderror
>
> > > The user was on a public library computer with IE7. We're running
> > > Apache 2.2.9 andmod_wsgi2.3 as packaged in Debian 5.0 Lenny.
>
> > > I'm wondering about the HTTP_VIA header, could that have contributed
> > > to the problem?
>
> > The presence of the header itself is not likely to cause the issue,
> > but its presence does indicate that therequestwent via a proxy or
> > other sort of software. That proxy may have been killing off requests
> > which took too long.
>
> > The basic problem remains that the connection to the HTTP server was
> > dropped before alldatacould beread.
>
> > Graham
>
> > > [1]http://groups.google.fi/group/django-users/browse_thread/thread/
> > > 946936f69c012d96
>
> > > 
>
> > > Below is the WSGIRequest dump from the 500 e-mail:
>
> > >  > > GET:,
> > > POST:,
> > > COOKIES:{'sessionid': '83bc617fed936487b17f7d14848d245c'},
> > > META:{'CONTENT_LENGTH': '30977474',
> > >  'CONTENT_TYPE': 'multipart/form-data;
> > > boundary=---7d9c0903da',
> > >  'DOCUMENT_ROOT': '/home/mysite/media',
> > >  'GATEWAY_INTERFACE': 'CGI/1.1',
> > >  'HTTP_ACCEPT': 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> > > application/x-shockwave-flash, application/vnd.ms-excel, application/
> > > vnd.ms-powerpoint, application/msword, */*',
> > >  'HTTP_ACCEPT_LANGUAGE': 'fi',
> > >  'HTTP_CACHE_CONTROL': 'no-cache',
> > >  'HTTP_CONNECTION': 'Keep-Alive',
> > >  'HTTP_COOKIE': 'sessionid=83bc617fed936487b17f7d14848d245c',
> > >  'HTTP_HOST': 'mysite.com',
> > >  'HTTP_REFERER': 'http://mysite.com/myform/',
> > >  'HTTP_UA_CPU': 'x86',
> > >  'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
> > > 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
> > >  'HTTP_VIA': '1.1 EDUISAIMA',
> > >  'PATH': '/usr/local/bin:/usr/bin:/bin',
> > >  'PATH_INFO': u'/myform/',
> > >  'PATH_TRANSLATED': '/home/mysite/deploy/mysite/myform/',
> > >  'QUERY_STRING': '',
> > >  'REMOTE_ADDR': '194.xxx.xxx.xxx',
> > >  'REMOTE_PORT': '26205',
> > >  'REQUEST_METHOD': 'POST',
> > >  'REQUEST_URI': '/myform/',
> > >  'SCRIPT_FILENAME': '/home/mysite/deploy/mysite.wsgi',
> > >  'SCRIPT_NAME': u'',
> > >  'SERVER_ADDR': '78.xxx.xxx.xxx',
> > >  'SERVER_ADMIN': 'ad...@mysine.com',
> > >  'SERVER_NAME': 'mysite.com',
> > >  'SERVER_PORT': '80',
> > >  'SERVER_PROTOCOL': 'HTTP/1.1',
> > >  'SERVER_SIGNATURE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3
> > > Python/2.5.2 Server at mysite.com Port 80\n',
> > >  'SERVER_SOFTWARE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3 Python/2.5.2',
> > > 

Re: Ignoring Definite/Indefinite Articles when Sorting

2009-05-21 Thread Sam Chuparkoff

On May 21, 10:10 pm, Darryl Ross  wrote:
> I have searched around but not really found an answer to this. For a
> project I am working on the customer wants a list of publications to be
> sorted alphabetically, but ignoring the definite/indefinite articles
> "the/a/an".

You could create a new field in the model to hold the text you do want
to sort and update it on model.save().

sdc

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



Re: Installing django

2009-05-21 Thread Graham Dumpleton



On May 22, 10:51 am, LeonTheCleaner  wrote:
> How about I pay someone $20 to do this for me? I just wanna work on
> the python codet, instead of dealing with django installation. Seems
> like a fair trade for me.
>
> On May 21, 5:34 pm, LeonTheCleaner  wrote:
>
> > Thanks guys. So after I install django, I can install the project I
> > want, but when I say change a python file, would it update
> > automatically when I relaunch the website?

With the attitude you are displaying, ie., not wanting to watch a 20
minute video even though you have probably spent almost as much time
as that here complaining about the length of the video, and also
possibly not even wanting to spend the time to properly research
yourself what documentation exists which may answer your questions,
I'd suggest people aren't going to want to help you.

If you want people to help you when you actually get to coding your
Django application, you have to show that you are yourself making an
effort to actually work things out for yourself first. There is lots
of documentation out there which people have spent a lot of time on
exactly so you can be self sufficient and not need to be spoon fed by
others.

As to your specific question about source code reloading, it actually
depends on how you are hosting your Django application. If you are
using Apache/mod_wsgi then read:

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

As much as you seem to want to avoid the details about how your
application may be hosted, reality is that how Python works and the
quality of Python web hosting available out there, means you can't
avoid knowing about it completely.

Sorry if this seems harsh, but we aren't ticket monkeys manning a help
desk. ;-)

Graham

> > Thanks.
>
> > On May 21, 7:35 am, Chris Lawlor  wrote:
>
> > > Just to see what all the fuss is about, most of that video is the guy
> > > configuring his particular application. The actualDjangoinstall is
> > > very straightforward.
>
> > > On May 21, 1:53 am, Kenneth Gonsalves  wrote:
>
> > > > On Thursday 21 May 2009 11:15:29 LeonTheCleaner wrote:
>
> > > > > @sdc, yeah I plan to try webfaction. The only thing is I just quickly
> > > > > checked out their demo video to setupdjangoand itès 21 mins. I am
> > > > > blown away to see how complicated just setting this up, and I am an
> > > > > experienced windows programmer. Just expected a lot less steps.
>
> > > > why follow their steps? just follow the steps in thedjangotutorial.
> > > > --
> > > > regards
> > > > kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IOError: request data read error (revisited)

2009-05-21 Thread Jeff FW

I've had the same problem, and can't figure out how to resolve it.  It
seems to have nothing to do with the amount of data being transfered:
it happens occasionally on the smallest of page requests/responses.
It also doesn't seem to be related to browser, unless several
different versions of IE *and* Safari have the same problem.  I tried
disabling keepalives for Safari at least, and it doesn't seem to have
helped.  I'd prefer not to disable keepalives in general, if I can
avoid it.

All of the error messages I've received have shown in the traceback
that they're coming through this function:
http://code.djangoproject.com/browser/django/trunk/django/core/handlers/wsgi.py#L131

It seems to me like there's an easy workaround (I'm sure the actual
fix has to be much lower level, in WSGI or Apache [or even lower])
that would at least stop my users from getting 500 errors: wrap the
contents of that function in a try block, and *don't* raise the
exception.

Otherwise, I'd have to wrap every view that uses POST in that, which
would be very annoying.  Or maybe write middleware that just peeks at
POST before anything else gets it, so that I could catch it there.

Thoughts?

Thanks,
Jeff

On Mar 31, 6:40 pm, Graham Dumpleton 
wrote:
> On Apr 1, 1:34 am, akaihola  wrote:
>
> > We ran into the same issue Chunlei Wu described in January[1]. A user
> > was trying to upload large files and all we got were 500 errors by e-
> > mail:
>
> >   File "/home/citedesarts/src/django/django/http/multipartparser.py",
> > line 406, inread
> >IOError:requestdatareaderror
>
> > The user was on a public library computer with IE7. We're running
> > Apache 2.2.9 andmod_wsgi2.3 as packaged in Debian 5.0 Lenny.
>
> > I'm wondering about the HTTP_VIA header, could that have contributed
> > to the problem?
>
> The presence of the header itself is not likely to cause the issue,
> but its presence does indicate that therequestwent via a proxy or
> other sort of software. That proxy may have been killing off requests
> which took too long.
>
> The basic problem remains that the connection to the HTTP server was
> dropped before alldatacould beread.
>
> Graham
>
> > [1]http://groups.google.fi/group/django-users/browse_thread/thread/
> > 946936f69c012d96
>
> > 
>
> > Below is the WSGIRequest dump from the 500 e-mail:
>
> >  > GET:,
> > POST:,
> > COOKIES:{'sessionid': '83bc617fed936487b17f7d14848d245c'},
> > META:{'CONTENT_LENGTH': '30977474',
> >  'CONTENT_TYPE': 'multipart/form-data;
> > boundary=---7d9c0903da',
> >  'DOCUMENT_ROOT': '/home/mysite/media',
> >  'GATEWAY_INTERFACE': 'CGI/1.1',
> >  'HTTP_ACCEPT': 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> > application/x-shockwave-flash, application/vnd.ms-excel, application/
> > vnd.ms-powerpoint, application/msword, */*',
> >  'HTTP_ACCEPT_LANGUAGE': 'fi',
> >  'HTTP_CACHE_CONTROL': 'no-cache',
> >  'HTTP_CONNECTION': 'Keep-Alive',
> >  'HTTP_COOKIE': 'sessionid=83bc617fed936487b17f7d14848d245c',
> >  'HTTP_HOST': 'mysite.com',
> >  'HTTP_REFERER': 'http://mysite.com/myform/',
> >  'HTTP_UA_CPU': 'x86',
> >  'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
> > 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
> >  'HTTP_VIA': '1.1 EDUISAIMA',
> >  'PATH': '/usr/local/bin:/usr/bin:/bin',
> >  'PATH_INFO': u'/myform/',
> >  'PATH_TRANSLATED': '/home/mysite/deploy/mysite/myform/',
> >  'QUERY_STRING': '',
> >  'REMOTE_ADDR': '194.xxx.xxx.xxx',
> >  'REMOTE_PORT': '26205',
> >  'REQUEST_METHOD': 'POST',
> >  'REQUEST_URI': '/myform/',
> >  'SCRIPT_FILENAME': '/home/mysite/deploy/mysite.wsgi',
> >  'SCRIPT_NAME': u'',
> >  'SERVER_ADDR': '78.xxx.xxx.xxx',
> >  'SERVER_ADMIN': 'ad...@mysine.com',
> >  'SERVER_NAME': 'mysite.com',
> >  'SERVER_PORT': '80',
> >  'SERVER_PROTOCOL': 'HTTP/1.1',
> >  'SERVER_SIGNATURE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3
> > Python/2.5.2 Server at mysite.com Port 80\n',
> >  'SERVER_SOFTWARE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3 Python/2.5.2',
> >  'mod_wsgi.application_group': 'mysite.com|',
> >  'mod_wsgi.callable_object': 'application',
> >  'mod_wsgi.listener_host': '',
> >  'mod_wsgi.listener_port': '80',
> >  'mod_wsgi.process_group': 'mysite',
> >  'mod_wsgi.reload_mechanism': '1',
> >  'mod_wsgi.script_reloading': '1',
> >  'wsgi.errors': ,
> >  'wsgi.file_wrapper':  > object at 0x24aeeb8>,
> >  'wsgi.input': ,
> >  'wsgi.multiprocess': True,
> >  'wsgi.multithread': True,
> >  'wsgi.run_once': False,
> >  'wsgi.url_scheme': 'http',
> >  'wsgi.version': (1, 0)}>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en

Re: Ignoring Definite/Indefinite Articles when Sorting

2009-05-21 Thread Darryl Ross

Forgot one thing, this is on Django 1.0.2.

Regards
Darryl


On 22/05/2009 11:40 AM, Darryl Ross wrote:
> Hi All,
>
> I have searched around but not really found an answer to this. For a
> project I am working on the customer wants a list of publications to be
> sorted alphabetically, but ignoring the definite/indefinite articles
> "the/a/an".
>
> Eg, the list should sort like
>
> Adherence to ...
> The Effects of ...
> A Low Participation Rate ...
> Trends in ...
> Understanding ...
> What Stops ...
>
> Is there a way of doing this using the ORM or a custom manager without
> having to write custom SQL every time I need to get a list of publications?
>
> I found the following page which has a method of doing it for MySQL:
>
> http://expressionengine.com/wiki/Sort_Entries_by_Title_Ignoring_The_A_An/
>
>


-- 
Darryl Ross, VK5LBJ
AFOYI, Information Technology Solutions
e: dar...@afoyi.com
p: +61 8 7127 1831
f: +61 8 8425 9607

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



Ignoring Definite/Indefinite Articles when Sorting

2009-05-21 Thread Darryl Ross

Hi All,

I have searched around but not really found an answer to this. For a 
project I am working on the customer wants a list of publications to be 
sorted alphabetically, but ignoring the definite/indefinite articles 
"the/a/an".

Eg, the list should sort like

   Adherence to ...
   The Effects of ...
   A Low Participation Rate ...
   Trends in ...
   Understanding ...
   What Stops ...

Is there a way of doing this using the ORM or a custom manager without 
having to write custom SQL every time I need to get a list of publications?

I found the following page which has a method of doing it for MySQL:

http://expressionengine.com/wiki/Sort_Entries_by_Title_Ignoring_The_A_An/


-- 
Darryl Ross, VK5LBJ
AFOYI, Information Technology Solutions
e: dar...@afoyi.com
p: +61 8 7127 1831
f: +61 8 8425 9607

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



Cannot reload a Django models module within a "manage.py shell" session

2009-05-21 Thread chadbraunduin

I know how to reload a regular Python module within a regular Python
interpreter session. For some reason, I am having trouble doing that
within Django's "manage.py shell" interpreter session. To recreate my
issue, start the basic Django tutorial found here:

http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

After creating the "polls" application and "Poll" class, start up the
interpreter via "manage.py shell" and import the "polls" app into it.

import polls.models as pm

Create a new "Poll" object:

p = pm.Poll()

All is well and good so far. Now go back to your source and add any
arbitrary method or attribute. For example, I've added:

def x(self):
return 2+2

Now go back to the interpreter and "reload" the module:

reload(pm)

Now try to use your new method or attribute:

p1 = pm.Poll()
p1.x()

You'll get this message:

'Poll' object has no attribute 'x'

What gives? I've also tried rerunning the import command, importing
the module using different syntax, deleting all references to any
"Poll" objects or to the "Poll" class. I've also tried this with both
the IPython interpreter and with the plain Python (v2.6) interpreter.
Nothing seems to work.

Using the same techniques with an arbitrary Python module in a regular
interpreter session works perfectly. I just can't seem to get it to
work in Django's "shell" session.

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



Re: reverse URLs on Debian Lenny

2009-05-21 Thread Brian May

On Fri, May 22, 2009 at 10:06:50AM +1000, Brian May wrote:
> urlpatterns = patterns('',
> [...]
>  (r'^(.*)', include('microcomaustralia.zoph.urls'))
> [...]
> )

Errr... Sorry, found out it was my fault. That should be:

(r'^', include('microcomaustralia.zoph.urls'))

I suspect I must have got this right on the other computers where it worked. As 
a result django
was expecting another parameter for each url.
-- 
Brian May 

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



Is this a db caching issue or a sessions issue?

2009-05-21 Thread Iqbal Abdullah

Hi guys,

I'm trying to figure out if what is going on with the pages i'm
building and how to fix it.

I have an object of User which I put into the sessions:

class User:

 def _get_points(self):
return UserModel.point.current_value

 def _set_points(self, value):
pass

 points = property(_get_points, _set_points)

These are the models which I have defined:

class UserModel(models.Model):
uid= models.CharField(max_length=255, unique=True)

class Points(models.Model)
user = models.ForeignKey(UserModel)
current_value = models.IntegerField()


In my views, I do:

user = User()
user.points

to get the current value of points for a certain user. However, after
a certain page has been loaded and shown the current value, if I
manually change the value in the db (MySQL) and reload the page, I
still get the old value, before the db change. I've ruled out page
caching as different parts of the page has changes. These other
changes on the page was executed via the user object in the sessions
(not manually through the db) and works fine.

These are the middlewares that I have in:
sessionsMiddleware
commonMiddleware

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



Re: Installing django

2009-05-21 Thread LeonTheCleaner

How about I pay someone $20 to do this for me? I just wanna work on
the python codet, instead of dealing with django installation. Seems
like a fair trade for me.

On May 21, 5:34 pm, LeonTheCleaner  wrote:
> Thanks guys. So after I install django, I can install the project I
> want, but when I say change a python file, would it update
> automatically when I relaunch the website?
>
> Thanks.
>
> On May 21, 7:35 am, Chris Lawlor  wrote:
>
>
>
> > Just to see what all the fuss is about, most of that video is the guy
> > configuring his particular application. The actualDjangoinstall is
> > very straightforward.
>
> > On May 21, 1:53 am, Kenneth Gonsalves  wrote:
>
> > > On Thursday 21 May 2009 11:15:29 LeonTheCleaner wrote:
>
> > > > @sdc, yeah I plan to try webfaction. The only thing is I just quickly
> > > > checked out their demo video to setupdjangoand itès 21 mins. I am
> > > > blown away to see how complicated just setting this up, and I am an
> > > > experienced windows programmer. Just expected a lot less steps.
>
> > > why follow their steps? just follow the steps in thedjangotutorial.
> > > --
> > > regards
> > > kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Free eBook: Django 1.0 Website Development

2009-05-21 Thread leveille

I'm doing my best to give away a few books, however, due to my very
poor site traffic, I'm not having much luck.  So, if you are new to
Django and you are interested a free book (Django 1.0 Website
Development, published by Packt), or if you know someone who could
benefit from a good Django book, than visit:
http://jasonleveille.com/2009/05/free-web-development-ebooks and leave
a comment.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to write subdomain from django apps

2009-05-21 Thread Joshua Partogi

Thanks,

That really helps :-) Just what I was looking for.

On May 22, 5:09 am, Lakshman Prasad  wrote:
> Here is one interesting open source 
> implementation:http://uswaretech.com/blog/2009/03/django-subdomains-easily-create-su...
>

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



reverse URLs on Debian Lenny

2009-05-21 Thread Brian May


Hello,

I have a Django application that works fine on Ubuntu Intrepid with Python 2.5
and Ubuntu Jaunty with Python 2.6.

When I try to get it to work with Debian Lenny however, I keep getting
NoReverseMatch errors.

louie:/home/django/photos# ./manage.py  shell
Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.urlresolvers import reverse
>>> reverse('person_list')
Traceback (most recent call last):
  File "", line 1, in 
  File "/var/lib/python-support/python2.5/django/core/urlresolvers.py", line 
254, in reverse
*args, **kwargs)))
  File "/var/lib/python-support/python2.5/django/core/urlresolvers.py", line 
243, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'person_list' with arguments '()' and keyword 
arguments '{}' not found.

If in my urls.py, I change:

urlpatterns = patterns('',
[...]
 (r'^(.*)', include('microcomaustralia.zoph.urls'))
[...]
)

to:

urlpatterns = patterns('',
[...]
url(r'^photos/person/$', 'django.views.generic.list_detail.object_list', 
person_dict, name='person_list'),
[...]
)

ie. I copied from microcomaustralia.zoph.urls and pasted here, then it works:

louie:/home/django/photos# ./manage.py  shell
Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.urlresolvers import reverse
>>> reverse('person_list')
'/photos/person/'

So it would appear that on Debian Lenny, reverse URLs are broken when using
include(...)

Are there any known compatibility issues with Django and Debian Lenny?

If not, how do I debug this issue?

In all cases I am using the latest stable version of Django (1.0.2)

Thanks
-- 
Brian May 

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



Re: Custom urlconfs in django.contrib.auth tests failing when reverse is used in templates

2009-05-21 Thread Russell Keith-Magee

On Fri, May 22, 2009 at 3:08 AM, Andrew Fong  wrote:
>
> Figured this out somewhat: To get around this, you can do something
> like this when referencing external apps in auth templates:
>
> {% url project.other_app.views.other_view as view %}
>
> This won't raise an error if that reference doesn't work.
>
> Still, this feels a bit hackish. I think brittle auth tests are
> something of a recurring theme here.

"Brittle" is perhaps a little extreme, but yes, there are issues. All
I can say in our defence is that the Django test suite passes for us,
and passes on a wide range of projects on which we use Django.

However, there are use cases that we don't exercise - which leads to
reports like yours. If you open a ticket describing the problem you
are having (and, in this case, the workaround for people that
experience the same problem), we can look at addressing this in the
future.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Installing django

2009-05-21 Thread LeonTheCleaner

Thanks guys. So after I install django, I can install the project I
want, but when I say change a python file, would it update
automatically when I relaunch the website?




Thanks.

On May 21, 7:35 am, Chris Lawlor  wrote:
> Just to see what all the fuss is about, most of that video is the guy
> configuring his particular application. The actualDjangoinstall is
> very straightforward.
>
> On May 21, 1:53 am, Kenneth Gonsalves  wrote:
>
> > On Thursday 21 May 2009 11:15:29 LeonTheCleaner wrote:
>
> > > @sdc, yeah I plan to try webfaction. The only thing is I just quickly
> > > checked out their demo video to setupdjangoand itès 21 mins. I am
> > > blown away to see how complicated just setting this up, and I am an
> > > experienced windows programmer. Just expected a lot less steps.
>
> > why follow their steps? just follow the steps in thedjangotutorial.
> > --
> > regards
> > kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best Django host

2009-05-21 Thread LeonTheCleaner

Thanks for replying. But what about dreamhost which claims to have
unlimited traffic, etc. Do you guys think what webfaction offers is
reasonable?

On May 21, 5:20 pm, Eugene Lazutkin  wrote:
> +1. I used both and some of their competitors => in my opinion
> slicehost and webfaction are the best in their respective classes.
>
> Thanks,
>
> Eugene Lazutkinhttp://lazutkin.com/
>
> On May 20, 1:59 pm, Lakshman Prasad  wrote:
>
> > In a sentence, to sum it up, Use Slicehost for VPS and Webfaction for shared
> > servers. Go shopping if you want to save some bucks and dont mind some extra
> > effort for installation.
>
> > On Wed, May 20, 2009 at 11:19 PM, ringemup  wrote:
>
> > > FWIW, I got django working on Dreamhost by basically using the
> > > instructions here:
>
> > >http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mo...
>
> > > On May 20, 1:13 pm, Masklinn  wrote:
> > > > On 20 May 2009, at 17:10 , Aneesh wrote:
>
> > > > > I've set up a couple Django sites on Dreamhost, as well as one on
> > > > > Webfaction.   Webfaction is great.  Dreamhost requires lots of
> > > > > tweaking, but you can definitely run a Django site just fine there
> > > > > too.  I've had no issues with uptime.  If you need help setting it up
> > > > > on Dreamhost, check out Jeff Croft's helpful guide:
> > > > >http://jeffcroft.com/blog/2006/may/11/django-dreamhost/.
>
> > > > Note that since Jeff's post Dreamhost added Phusion Passenger. Their
> > > > addition of mod_rails doesn't sound that useful, until you know it
> > > > supports wsgi (though that's experimental accodring to phusion).
>
> > > > I haven't done performance (/stability/scalability) tests, but I did
> > > > test deployment of a very basic django app and the deployment is as
> > > > trivial as with mod_wsgi, and seems to work.
>
> > --
> > Regards,
> > Lakshman
> > becomingguru.com
> > lakshmanprasad.com+1
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best Django host

2009-05-21 Thread Eugene Lazutkin

+1. I used both and some of their competitors => in my opinion
slicehost and webfaction are the best in their respective classes.

Thanks,

Eugene Lazutkin
http://lazutkin.com/

On May 20, 1:59 pm, Lakshman Prasad  wrote:
> In a sentence, to sum it up, Use Slicehost for VPS and Webfaction for shared
> servers. Go shopping if you want to save some bucks and dont mind some extra
> effort for installation.
>
>
>
> On Wed, May 20, 2009 at 11:19 PM, ringemup  wrote:
>
> > FWIW, I got django working on Dreamhost by basically using the
> > instructions here:
>
> >http://www.soasi.com/2008/09/django-10-on-dreamhost-with-passenger-mo...
>
> > On May 20, 1:13 pm, Masklinn  wrote:
> > > On 20 May 2009, at 17:10 , Aneesh wrote:
>
> > > > I've set up a couple Django sites on Dreamhost, as well as one on
> > > > Webfaction.   Webfaction is great.  Dreamhost requires lots of
> > > > tweaking, but you can definitely run a Django site just fine there
> > > > too.  I've had no issues with uptime.  If you need help setting it up
> > > > on Dreamhost, check out Jeff Croft's helpful guide:
> > > >http://jeffcroft.com/blog/2006/may/11/django-dreamhost/.
>
> > > Note that since Jeff's post Dreamhost added Phusion Passenger. Their
> > > addition of mod_rails doesn't sound that useful, until you know it
> > > supports wsgi (though that's experimental accodring to phusion).
>
> > > I haven't done performance (/stability/scalability) tests, but I did
> > > test deployment of a very basic django app and the deployment is as
> > > trivial as with mod_wsgi, and seems to work.
>
> --
> Regards,
> Lakshman
> becomingguru.com
> lakshmanprasad.com+1
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get ServerName in settings.py

2009-05-21 Thread Graham Dumpleton



On May 21, 11:51 pm, Donn Ingle  wrote:
> Hi,
> Given that my apache uses many VirtualHosts and within each a ServerName,
> how can I get that ServerName into a variable in my settings.py file?
>
> I am usingWSGIand mod_python. (different setups on dev vs. server)
>
> The reason is that I need to be able to build the wholehttp://servernamein
> functions all over the place, like the models and request context -- places
> where I *don't* have a request variable. All I have is access to
> settings.SOME_VAR -- hence I would like to get:
>
> apache: ServerName ---> settings.py: SERVER_NAME
>
> Any help/suggestions?

Strictly speaking you can't as the relationship between a VirtualHost
and a specific Python sub interpreter is dynamic.

You could work around it though by relying on the name of the sub
interpreter which is created. In mod_python you can access the name of
the sub interpreter using mod_python.apache.interpreter. In mod_wsgi
(requires mod_wsgi >= 2.4) you can access the name of the sub
interpreter as mod_wsgi.application_group. You obviously need to
import those respective modules first.

For the case of mod_wsgi above, the default generated application
group name, ie., sub interpreter, actually has the server name and
WSGI application mount point in it, so you wouldn't even need to
explicitly name the sub interpreter but just extract the server name
component out of mod_wsgi.application_group.

  import mod_wsgi
  server_name = mod_wsgi.application_group.split('|')[0]

Because mod_python defaults to one sub interpreter per virtual host,
vs, one per application like mod_wsgi, then the actual sub interpreter
name is probably the server name. So can just use it as is:

  import mod_python.apache
  server_name = mod_python.apache.interpreter

If you are in a situation where you are forced to run your application
in main interpreter then this will not work. For mod_wsgi you could
use daemon mode and name the process group the same as the server name
and instead access mod_wsgi.process_group. Otherwise the only other
way would be to use PythonImport or WSGIImportScript to import a file
which sets up a variable somewhere you can access, but then you need
to have such a file for each virtual host. Since for mod_wsgi at least
you are going to have one WSGI script file per host anyway, you
probably may as well set it at the start of it.

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



Re: Setting tzinfo for DateTimeFields with Postgresql - workaround

2009-05-21 Thread George Song

On 5/16/2009 10:28 PM, Glenn Maynard wrote:
> This is just a quick hack for anyone else bit by this: tzinfo is never
> set when reading DateTimeFields out of the database, at least with
> Postgresql.
> 
> Now, I have no idea why anyone would want to set TIME_ZONE to anything
> but UTC (and the default of an arbitrary US timezone is rather
> bizarre), but even with UTC, you need a tzinfo set on your datetimes,
> in order to localize them to user time zones with astimezone().  Doing
> this manually is a pain--you need to replace(tzinfo=UTC) before every
> datetime access.

Hi Glenn,

When you get the chance can you review my proposal[1] for fixing 
DateTimeField in Django?

I'm going to try to get this in for 1.2 release.

[1] http://code.djangoproject.com/ticket/10587

-- 
George

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



Re: Best Django host

2009-05-21 Thread scoobygalletas

+1 to Webfaction.

The support is fantastic, 10 points to the uptime and for the admin
panel.

Apart from Django, I also usit for SVN, TRAC, web redirections and
mail, with the same service quality.


Matías.-

On May 21, 3:42 am, LeonTheCleaner  wrote:
> Thanks for replying. When you mention like that, yeah it looks way
> simpler than what is shown.
>
> Can you use a domain name likewww.mysite.com?It does not need to be
> a subdomain, right?
>
> Also after you get the welcome screen, how do you install your django
> application you downloaded from the net?
>
> Thanks.
>
> On May 21, 12:23 am, Laszlo Antal  wrote:
>
> > On Wed, 20 May 2009 10:51 pm, LeonTheCleaner wrote:
>
> > > Thanks all for replying. I appreciate it.
>
> > > Webfaction seems to be popular amongst many. The only thing is I just
> > > quickly
> > > checked out their demo video to setup django and it is 21 mins. I am
> > > blown away to see how complicated just setting this up, and I am an
> > > experienced windows programmer. Just expected a lot less steps.
>
> > Hi,
>
> > I have never watch that video.
> > But all you need to do to setup django is to create a django application
> > in applications and then in sites assign a domain name for it or use
> > the
> > default username.webfactional.com and that's it.
> > You point your browser to the domain name and get the Django welcome
> > screen.
> > It takes about 1minutes or less to do all that.
> > Even installing satchmo took about 10minutes only,including installing
> > all the dependencies.
>
> > I have tried many hosting companies and webfaction is the best so far.
>
> > Hope it helps
>
> > lzantal
>
> >http://twitter.com/lzantalhttp://www.antalconsulting.com
>
> > > Have you guys checked outwww.djangohosting.ch?Theyclaim their
> > > django is
> > > one click solution. I wonder how that one compares to webfaction both
> > > for features
> > > and the ease of installations. Their small django setup thumbnail
> > > looks very straightforward.
>
> > > It was also high up in the django supported site.
>
> > > Thanks again.
> > > Laszlo Antal
>
>

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



Re: psycopg2 name tz error

2009-05-21 Thread Petar Radosevic
There are some solutions posted here, maybe it would help you.

http://lethain.com/entry/2009/feb/13/when-psycopg2-can-t-import-tz/

-- 
With kind regards,
Petar Radosevic

W: wunki.org

PGP Fingerprint: CCDD 7545 4907 D40D C0AC  3AC2 FDDC 2E15 AC44 2A15
PGP Publickey  : http://wunki.org/pgp/


pgpelnkQ4X7LQ.pgp
Description: PGP signature


Custom ManyToMany intermediate table.

2009-05-21 Thread Thomas

Hi,

I have the following models :

--->
class Warehouse(models.Model):
name = models.CharField(max_length=100)
shortname = models.CharField(max_length=3)
description = models.CharField(max_length=1000)

class Product(models.Model):
name = models.CharField(max_length=300)
category = models.ForeignKey(Category)
warehouses = models.ManyToManyField(Warehouse, through='Stock')

# ManyToMany intermediate table
class Stock(models.Model):
product_id = models.ForeignKey(Product)
warehouse_id = models.ForeignKey(Warehouse)
qty = models.IntegerField()
class Meta:
unique_together = ("product_id", "warehouse_id")

<---

What is the best way to write a python function to get the Total
Quantity of a given Product (s1.qty+s2.qty+...+sN.qty) ?
My solution was to select all Stock instance then check the keys
(matching product_id) and add all of them. Not so nice...
Any better solution ?

--
Thomas.

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



Re: Rendering a form based on partly determined model state

2009-05-21 Thread Joakim Hove

I found Collin's Blog entry, and that looked very promising.

Thanks a lot.

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



Re: Rendering a form based on partly determined model state

2009-05-21 Thread google torp

Hi, not on my computet so will keep it short. Try to google "django
form trick" the top result should be a blog post by colin grady.
Basically what you need to do is to override the init method.

~Jakob

On May 21, 8:44 pm, Joakim Hove  wrote:
> Hello,
>
> I have just started using Django - looks very promising!
>
> I am trying to implement  something resembling a web-based shop. A
> simplified overview of my situation is as follows:
>
> models.py
> ---
>
> class Country(models.Model)
>      name     = CharField(max_length  = 100)
>      currency = CharField(max_length  = 3)
>
> class Product(models.Model)
>       name   = CharField(max_length = 100)
>       price     = FloatField()
>       country = ForeignKey(Country , editable = False)
>
> class Transaction(models.Model)
>       country   = ForeignKey( Country , editable = False)
>       product  = ForeignKey( Product )
>       date        = DateField()
>
> views.py
> ---
>
> class NewTransaction(ModelForm):
>        class Meta:
>                 model = Transaction
>
> def newtransaction(request , country):
>        return render_to_response(...)
>
> ...
> Now, an important aspect of this shop is that it operates in several
> different countries, and the available product are different in
> different countries. The database can typically contain four Product
> objects:
>
>      ["Norwegian_Product1" , "Norwegian_Product2" ,
> "Swedish_Product1" , "Swedish_Product2"]
>
> Based on the url the customer used I know which country she is in, and
> whether I should present the Norwegian products or the Swedish
> product. This id comes as the second argument to the view function,
> but when rendering the NewTransaction form I do not understand how to
> limit the rendereing ov available product to only those available in
> the customers country?!
>
> Any tips greatly appreciated.
>
> Regards
>
> Joakim Hove
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Locales

2009-05-21 Thread Gabriel .

Hi all,

I've generated and compiled the locales, under my app path,
locale/LANG/LC_MESSAGES (django.mo and the .po of course)

When I select the language, some of the strings appears translated
(the ones shared with django), but no the strings on the django.mo
file (the one I created - they are all translated)

Am I missing something?

Thanks.
-- 
Kind Regards

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



Contrib.comments permissions?

2009-05-21 Thread ringemup

Contrib.comments seems to provide a lot of permissions beyond the
obvious add / change / delete for comments themselves.  What do the
following permissions grant that the former do not?

'can_moderate',
'add_commentflag',
'change_commentflag',
'delete_commentflag',

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Data view change

2009-05-21 Thread garces.85

Hello,

I have i question, how can a change the data displayed in a template
only when the user changes from one view to another, for example i
have a template that displays some deleted users, but only the recent
ones are marked by a different colour from the other, how can i handle
that wuen the user changes to another view and returns those users are
no longer marked?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



psycopg2 name tz error

2009-05-21 Thread dononyx

Here is the error message. I've googled everywhere and tried
everything, so anybody got any ideas. mod_python, leopard 10.5.X, Mac
Intel

MOD_PYTHON ERROR

ProcessId:  800
Interpreter:'teachingbystandards.com'

ServerName: 'teachingbystandards.com'
DocumentRoot:   '/Library/WebServer/Documents/educate'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/Library/WebServer/Documents/educate/'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)

  File "/Library/Python/2.5/site-packages/django/core/handlers/
modpython.py", line 228, in handler
return ModPythonHandler()(req)

  File "/Library/Python/2.5/site-packages/django/core/handlers/
modpython.py", line 201, in __call__
response = self.get_response(request)

  File "/Library/Python/2.5/site-packages/django/core/handlers/
base.py", line 67, in get_response
response = middleware_method(request)

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
middleware.py", line 9, in process_request
engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
backends/db.py", line 2, in 
from django.contrib.sessions.models import Session

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
models.py", line 4, in 
from django.db import models

  File "/Library/Python/2.5/site-packages/django/db/__init__.py", line
16, in 
backend = __import__('%s%s.base' % (_import_path,
settings.DATABASE_ENGINE), {}, {}, [''])

  File "/Library/Python/2.5/site-packages/django/db/backends/
postgresql_psycopg2/base.py", line 20, in 
raise ImproperlyConfigured("Error loading psycopg2 module: %s" %
e)

ImproperlyConfigured: Error loading psycopg2 module: cannot import
name tz

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



Re: Integrity error handling

2009-05-21 Thread Bobby Roberts

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



Re: How to write subdomain from django apps

2009-05-21 Thread Lakshman Prasad
Here is one interesting open source implementation:
http://uswaretech.com/blog/2009/03/django-subdomains-easily-create-subscription-based-subdomains-enabled-webapps/

On Fri, May 22, 2009 at 12:20 AM, Tom Evans wrote:

>
> On Thu, 2009-05-21 at 16:24 +1000, Joshua Partogi wrote:
> > Sorry for this lame question.
> >
> > I just saw an application called suggestionbox.com and it's able to
> > write subdomain based on the customer id. Do we access and write BIND
> > configuration on the fly for this? Or is there a better way to do it?
> >
> > Anyone that has experience with this?
> >
> > Thanks very much in advance for sharing
> >
> > --
> > Join Scrum8.com.
> >
> > http://scrum8.com/member/jpartogi/
> > http://twitter.com/scrum8
> >
>
> Google for "bind wildcard subdomain" and enjoy.
>
> HTH
>
> Tom
>
>
> >
>


-- 
Regards,
Lakshman
becomingguru.com
lakshmanprasad.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom urlconfs in django.contrib.auth tests failing when reverse is used in templates

2009-05-21 Thread Andrew Fong

Figured this out somewhat: To get around this, you can do something
like this when referencing external apps in auth templates:

{% url project.other_app.views.other_view as view %}

This won't raise an error if that reference doesn't work.

Still, this feels a bit hackish. I think brittle auth tests are
something of a recurring theme here.

On May 20, 5:18 pm, Andrew Fong  wrote:
> I have the contrib.auth app installed, and in order for its tests to
> pass, I have to define certain registration templates. When defining
> those templates, if I use the url tag / reverse to point to a view
> outside the auths app, the auth tests fail.
>
> This occurs because the auth tests use a custom urlconf and have no
> knowledge of views elsewhere in the project -- on one hand, this makes
> sense since the auth app shouldn't be expected to know about the URLs
> in the project it's included in.
>
> On the other hand, the auth app invites us to write its own template
> -- and it seems reasonable that the template used for a login page
> might also have a link to another page in the app. For example, my
> registration templates extend a base template that has a nav bar
> pointing to views in other apps.
>
> Any ideas on how to work around this?
>
> -- Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to write subdomain from django apps

2009-05-21 Thread Tom Evans

On Thu, 2009-05-21 at 16:24 +1000, Joshua Partogi wrote:
> Sorry for this lame question.
> 
> I just saw an application called suggestionbox.com and it's able to
> write subdomain based on the customer id. Do we access and write BIND
> configuration on the fly for this? Or is there a better way to do it?
> 
> Anyone that has experience with this?
> 
> Thanks very much in advance for sharing
> 
> -- 
> Join Scrum8.com. 
> 
> http://scrum8.com/member/jpartogi/
> http://twitter.com/scrum8
> 

Google for "bind wildcard subdomain" and enjoy.

HTH

Tom


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



Re: how can I reset the form object variable (errors)?

2009-05-21 Thread Tom Evans

On Wed, 2009-05-20 at 11:06 -0700, Lokesh wrote:
> Hi Karen,
> 
> In one of my HTML page I have included 2 forms, where both the forms
> have required=True fields and have submit buttons respectively.
> The problem is when a user submits one form (by clicking one of submit
> button form the page)  and if at all it has some errors (as validated
> in clean method of forms)
> I want to populate errors only from the submitted form.
> 
> I am rendering the page in the following way in my views.py
> 
> def login(request, redirect_field_name=REDIRECT_FIELD_NAME):
>if request.method == "POST":
> form1 = loginForm(request.POST)
> form2 = SearchForm(request.POST)
> form1_hidden = request.POST.get('hiddenForm1')
> form2_hidden = request.POST.get('hiddenForm2')
> 
> if form1.is_valid() and form1_hidden == 'True':
>   return render_to_response("homepage.html")
> if form2.is_valid() and form2_hidden == 'True':
>   return render_to_response("searchresults.html")
> else:
> form1 = loginForm()
> form2 = SearchForm()
> return render_to_response("login.html", {
> "form1": form1,
> "form2": form2,
> })
> 
> Now in a case where form1 has errors,  I want to render the both the
> forms  with the errors of  form1 only.
> 
> Request you to let me know a solution for the above problem.
> 
> Thanks for your patience.
> 
> Regards,
> Lokesh

Add an 'action' field to each form, with a static value, eg add this
field to the loginForm class:
action = CharField(initial='login', widget=HiddenInput)
and then use logic like this:

if request.method == 'POST':
action = request.POST.get('action', None)
if action == 'login':
frm = loginForm(request.POST)
elif action == 'otheraction'
frm = otherForm(request.POST)

Even easier would be to submit them to different URIs.

Cheers

Tom


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



Rendering a form based on partly determined model state

2009-05-21 Thread Joakim Hove

Hello,

I have just started using Django - looks very promising!

I am trying to implement  something resembling a web-based shop. A
simplified overview of my situation is as follows:

models.py
---

class Country(models.Model)
 name = CharField(max_length  = 100)
 currency = CharField(max_length  = 3)


class Product(models.Model)
  name   = CharField(max_length = 100)
  price = FloatField()
  country = ForeignKey(Country , editable = False)


class Transaction(models.Model)
  country   = ForeignKey( Country , editable = False)
  product  = ForeignKey( Product )
  date= DateField()

views.py
---

class NewTransaction(ModelForm):
   class Meta:
model = Transaction

def newtransaction(request , country):
   return render_to_response(...)

...
Now, an important aspect of this shop is that it operates in several
different countries, and the available product are different in
different countries. The database can typically contain four Product
objects:

 ["Norwegian_Product1" , "Norwegian_Product2" ,
"Swedish_Product1" , "Swedish_Product2"]

Based on the url the customer used I know which country she is in, and
whether I should present the Norwegian products or the Swedish
product. This id comes as the second argument to the view function,
but when rendering the NewTransaction form I do not understand how to
limit the rendereing ov available product to only those available in
the customers country?!


Any tips greatly appreciated.

Regards

Joakim Hove




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



Re: FileBrowser: Models for media

2009-05-21 Thread patrickk

as mentioned before, one benefit is to _order_ the materials for each
course.
second, I just prefer to use edit-inlines (foreign keys) instead of
m2m-fields (the interface with many-to-many is not really useful,
IMHO).

patrick


On 21 Mai, 17:42, "eric.frederich"  wrote:
> Another change you made was to replace the ManyToMany on Course with a
> Foreign key to Course from Material.
> Could you explain the benefit of that?
>
> On May 21, 4:36 am, patrickk  wrote:
>
> > I´d use a slightly different approach:
>
> > class Course(models.Model):
> >     name = ...
>
> > class Material(models.Model):
> >     course = models.ForeignKey(Course)
> >     media = FileBrowseField(max_length=200, blank=True, null=True)
> >     order = models.PositiveIntegerField("Order", blank=True,
> > null=True)
>
> > the positive side effect is, that you´re able to _order_ your material
> > (which might - sooner or later - be necessary).
>
> > about subclassing filefield or filepathfield: there´s no good reason
> > whatsoever. if you think it´s better to subclass any of the given
> > fields, you may want to submit a patch.
>
> > thanks,
> > patrick
>
> > On May 20, 7:17 pm, "eric.frederich"  wrote:
>
> > > My application models Training courses.  Those courses may have
> > > training material in a variety of formats.
>
> > > I came across FileBrowser and it seems real nice.
>
> > > Are any of you using a FileBrowseField in your models?
>
> > > I get the feeling that what I'm doing below is wrong... creating a
> > > model that holds nothing but a single field just so that I can have a
> > > ManyToMany relationship on it.
>
> > > Also, why is it that FileBrowseField is not a subclass of FileFIeld or
> > > FilePathField ?
>
> > > class Course(models.Model):
> > >     name = models.CharField(max_length=100)
> > >     materials  = models.ManyToManyField('Material')
>
> > > class Material(models.Model):
> > >     media = FileBrowseField(max_length=200, blank=True, null=True)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model form validation always failing

2009-05-21 Thread Stu.Axon

Reposted as own subject with all the details

On May 21, 5:18 pm, "Stu.Axon"  wrote:
> I'm having the same problem - using a modelform
>
> I've got two fields jad_file and jar_file, I notice when I look at the
> html that they turn into
> id_jad_file
> and
> id_jar_file
>
> Is there a reason for this?
>
> On May 20, 7:13 pm, Karen Tracey  wrote:
>
> > On Wed, May 20, 2009 at 2:39 AM, watad  wrote:
>
> > > this is my form after thomas reply:
> > > 
> > >                                 {{ form.as_p }}
> > >                                 
> > >                              
>
> > > and this is my view after your reply :
>
> > > def careerspage(request):
> > >  if request.method == 'POST':
> > >        form = CareerForm(request.POST,request.FILES)
> > >        if form.is_valid():
> > >           form.save()
> > >           return HttpResponseRedirect('/thanks')
> > >  else:
> > >        form = CareerForm()
> > >  return render_to_response('careers.html', {'form':form})
>
> > > the validation for the resume upload still failing when i submit
> > > im reading the link u have posted to check whats wrong another help
> > > will be appriciated :)
>
> > If I cut-and-paste that view, that form (fixing up the oddly broken line)
> > and your models from your earlier note into a test project and test out that
> > view, I get a page with a form.  When I actually submit a file using that
> > form, I get redirected to '/thanks/', which gives me a "Page not found"
> > since I didn't set up any mapping for thanks.  So, somehow you are not
> > actually running the code you have posted, or using the template you think
> > you are.  At this point you need to do the standard debugging things --
> > start putting prints in to test the value of variables, etc.  What you have
> > posted here does work.
>
> > Karen
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using CustomUploadHandler, request.FILES is empty

2009-05-21 Thread Stu.Axon

I'm using a CustomUploadHandler for one of my views, but the form is
always invalid - also request.FILES is also blank ?
I'm a bit new to django, so not entirely sure whats going on

## form
class UploadMidletPairForm(ModelForm):

class Meta:
model = MidletPair

### uploadhandler
class CustomUploadHandler(FileUploadHandler):
def __init__(self, request = None, upload_to = tempfile.gettempdir
()):
self.upload_to = upload_to
FileUploadHandler.__init__(self, request)


def new_file(self, field_name, file_name, content_type,
content_length, charset=None):
#if not is_valid_upload(file_name): # here you can use
a function to filter uploaded files.
#raiseUploadFileException , "forbidden file type"
if not os.path.exists(self.upload_to):
os.makedirs(self.upload_to)
elif not os.path.isdir(self.upload_to):
raise IOError("%s exists and is not a directory." %
self.upload_to)

outPath = os.path.join(self.upload_to, file_name)
self.destination = open(outPath, 'wb+')
FileUploadHandler.new_file(self, field_name, file_name,
content_type, content_length, charset)

def receive_data_chunk(self, raw_data, start):
self.destination.write(raw_data)

def file_complete(self, file_size):
self.destination.close()


### view

@login_required
def validate_build(request):
'''
Jad/Jar upload form
'''

# Save the file to disk
print >> sys.stderr, request.user
request.upload_handlers = [CustomUploadHandler(upload_to =
os.path.join(settings.MEDIA_ROOT, 'superglu', 'userdata', str
(request.user), 'validate'))]
UPLOAD_FORM_TITLE = 'Validate Build'
if request.method == 'POST':
form = UploadMidletPairForm(request.POST, request.FILES)

if form.is_valid():
print >> sys.stderr, 'is valid'
jad = request.FILES['jad_file']
jar = request.FILES['jad_file']

else:
print >> sys.stderr, 'is not valid'
print >> sys.stderr, form.errors
else:
form = UploadMidletPairForm()
return render_to_response('validate/build/index.html',
context_instance = RequestContext(request,\
{
'form': form,
'title': UPLOAD_FORM_TITLE,
}))



### template
{% extends "base.html" %}
{% load i18n %}

{% block breadcrumbs %}

{% trans 'Home' %} 
Validate builds 
Build 

{% endblock %}

{% block content %}

{% if perms.validate %}
Upload Jad/Jar pair


{% if form.image.errors %}

{% for error in form.image.errors %}
{{ error|safe }}
{% endfor %}

{% endif %}
{{ form }}



{% else %}
Sorry, your user is not enabled for validation
{% endif %}


{% endblock %}


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



Re: django captcha

2009-05-21 Thread Dougal Matthews
because its easy for them and they don't really get anything from doing it
otherwise? ;)

You'll find you have to head to SVN quite often to get projects in Django
I'm afraid, it just seems to be fairly common practice. Although, many
people are moving to github and it offers a download.

Cheers,
Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/5/21 online 

>
> So i have to install svn on mymachine? Why people make download so
> complicated...
>
>
>
>
>
>
> On May 20, 10:22 pm, jai  wrote:
> > svn checkouthttp://django-simple-captcha.googlecode.com/svn/trunk/
> > django-simple-captcha-read-only
> >
> > On May 21, 9:30 am, online  wrote:
> >
> > > Could anyone please recommend a open source library captcha working
> > > fine with django?
> >
> > >http://code.google.com/p/django-simple-captcha/ looks but i just
> > > cannot find where to download.
> >
> > > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django captcha

2009-05-21 Thread online

So i have to install svn on mymachine? Why people make download so
complicated...






On May 20, 10:22 pm, jai  wrote:
> svn checkouthttp://django-simple-captcha.googlecode.com/svn/trunk/
> django-simple-captcha-read-only
>
> On May 21, 9:30 am, online  wrote:
>
> > Could anyone please recommend a open source library captcha working
> > fine with django?
>
> >http://code.google.com/p/django-simple-captcha/ looks but i just
> > cannot find where to download.
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model form validation always failing

2009-05-21 Thread Stu.Axon

I'm having the same problem - using a modelform

I've got two fields jad_file and jar_file, I notice when I look at the
html that they turn into
id_jad_file
and
id_jar_file

Is there a reason for this?

On May 20, 7:13 pm, Karen Tracey  wrote:
> On Wed, May 20, 2009 at 2:39 AM, watad  wrote:
>
> > this is my form after thomas reply:
> > 
> >                                 {{ form.as_p }}
> >                                 
> >                              
>
> > and this is my view after your reply :
>
> > def careerspage(request):
> >  if request.method == 'POST':
> >        form = CareerForm(request.POST,request.FILES)
> >        if form.is_valid():
> >           form.save()
> >           return HttpResponseRedirect('/thanks')
> >  else:
> >        form = CareerForm()
> >  return render_to_response('careers.html', {'form':form})
>
> > the validation for the resume upload still failing when i submit
> > im reading the link u have posted to check whats wrong another help
> > will be appriciated :)
>
> If I cut-and-paste that view, that form (fixing up the oddly broken line)
> and your models from your earlier note into a test project and test out that
> view, I get a page with a form.  When I actually submit a file using that
> form, I get redirected to '/thanks/', which gives me a "Page not found"
> since I didn't set up any mapping for thanks.  So, somehow you are not
> actually running the code you have posted, or using the template you think
> you are.  At this point you need to do the standard debugging things --
> start putting prints in to test the value of variables, etc.  What you have
> posted here does work.
>
> Karen

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



Re: FileBrowser: Models for media

2009-05-21 Thread eric.frederich

Another change you made was to replace the ManyToMany on Course with a
Foreign key to Course from Material.
Could you explain the benefit of that?

On May 21, 4:36 am, patrickk  wrote:
> I´d use a slightly different approach:
>
> class Course(models.Model):
>     name = ...
>
> class Material(models.Model):
>     course = models.ForeignKey(Course)
>     media = FileBrowseField(max_length=200, blank=True, null=True)
>     order = models.PositiveIntegerField("Order", blank=True,
> null=True)
>
> the positive side effect is, that you´re able to _order_ your material
> (which might - sooner or later - be necessary).
>
> about subclassing filefield or filepathfield: there´s no good reason
> whatsoever. if you think it´s better to subclass any of the given
> fields, you may want to submit a patch.
>
> thanks,
> patrick
>
> On May 20, 7:17 pm, "eric.frederich"  wrote:
>
> > My application models Training courses.  Those courses may have
> > training material in a variety of formats.
>
> > I came across FileBrowser and it seems real nice.
>
> > Are any of you using a FileBrowseField in your models?
>
> > I get the feeling that what I'm doing below is wrong... creating a
> > model that holds nothing but a single field just so that I can have a
> > ManyToMany relationship on it.
>
> > Also, why is it that FileBrowseField is not a subclass of FileFIeld or
> > FilePathField ?
>
> > class Course(models.Model):
> >     name = models.CharField(max_length=100)
> >     materials  = models.ManyToManyField('Material')
>
> > class Material(models.Model):
> >     media = FileBrowseField(max_length=200, blank=True, null=True)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can't create django project

2009-05-21 Thread ashish

if ur using the Linux u can get the "django-admin.py" on ur command
shell in any dirctry

eg..

ash...@pylone$

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



Re: open flash chart 2 & django

2009-05-21 Thread Bro

I've just installed python-cjson 1.0.5 available here :
http://pypi.python.org/pypi/python-cjson/1.0.5
But the problem remains.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeEncodeError

2009-05-21 Thread Sean Brant

Thanks Karen.

This is a script that fetched some json from a remote service. I  
switched from using the normal simplejson module to the one provided  
by Django and that seems to decode things in a unicode safe way.

On May 21, 2009, at 8:48 AM, Karen Tracey  wrote:

> I see I specified the unicode string incorrectly in my shell  
> example.  Turns out it doesn't make a difference in this case except  
> for the specifics of the exception, but what it should have been was:
>
> >>> u = u'\u2013'
> >>> stderr = open('/tmp/stderr.ascii.out', 'w')
> >>> print >> stderr, '%s' % u
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013'  
> in position 0: ordinal not in range(128)
> >>> import codecs
> >>> stderr = codecs.open('/tmp/stderr.utf8.out', mode='w',  
> encoding='utf-8')
> >>> print >> stderr, '%s' % u
> >>> quit()
>
> Karen
>
> >

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



open flash chart 2 & django

2009-05-21 Thread Bro

Hi,

I'm trying to use Open Flash Chart 2 with django.

+ Installation
- I've downloaded OFC2 in this address : 
http://sourceforge.net/project/showfiles.php?group_id=201148
- In my Django Project, I've created a directory (openFlashChart) for
the module with a __init__.py file inside.
--- I put inside these files : openFlashChart_elements.py,
openFlashChart_varieties.py, openFlashChart.py
- In my settings.py file, I've added in INSTALLED_APPS a line :
myproject.openFlashChart

 + View

In a view, I put this :

importmyproject.openFlashChart.openFlashChart as openFlashChart
frommyproject.openFlashChart.openFlashChart_varieties import
(Line,
 Line_Dot,
 Line_Hollow,
 Bar,
 Bar_Filled,
 Bar_Glass,
 Bar_3d,
 Bar_Sketch,
 HBar,
 Bar_Stack,
 Area_Line,
 Area_Hollow,
 Pie,
 Scatter,
 Scatter_Line)

frommyproject.openFlashChart.openFlashChart_varieties import
(dot_value,
 hbar_value,
 bar_value,
 bar_3d_value,
 bar_glass_value,
 bar_sketch_value,
 bar_stack_value,
 pie_value,
 scatter_value,
 x_axis_labels,
 x_axis_label)

def chart_data(request):
plot1 = Line(text = "line1", fontsize = 20, values = range(0,10))
plot2 = Line(text = "line2", fontsize = 06, values = range(10,0,
-1))
plot3 = Line(text = "line3", fontsize = 12, values = range(-5,5))

plot1.set_line_style(4, 3)
plot2.set_line_style(5, 5)
plot3.set_line_style(4, 8)

plot1.set_colour('#D4C345')
plot2.set_colour('#C95653')
plot3.set_colour('#8084FF')

chart = openFlashChart.template("Line chart")
chart.set_y_axis(min = -6, max = 10)

chart.add_element(plot1)
chart.add_element(plot2)
chart.add_element(plot3)

return chart.encode()

-

But I've got an error : Error was: No module named cjson

How to use Open Flash Chart 2 with Django ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: query reverse

2009-05-21 Thread CrabbyPete

Never mind I figured it out.

On May 21, 10:42 am, CrabbyPete  wrote:
> I want to create a list of items from the most recently added to the
> oldest. I tried this
> message = Message.objects.reverse('date_added')
>
> It still returned the oldest items first. What is the best way to
> return the newest item first?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



query reverse

2009-05-21 Thread CrabbyPete

I want to create a list of items from the most recently added to the
oldest. I tried this
message = Message.objects.reverse('date_added')

It still returned the oldest items first. What is the best way to
return the newest item first?

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



Get ServerName in settings.py

2009-05-21 Thread Donn Ingle

Hi,
Given that my apache uses many VirtualHosts and within each a ServerName, 
how can I get that ServerName into a variable in my settings.py file?

I am using WSGI and mod_python. (different setups on dev vs. server)

The reason is that I need to be able to build the whole http://servername in 
functions all over the place, like the models and request context -- places 
where I *don't* have a request variable. All I have is access to 
settings.SOME_VAR -- hence I would like to get:

apache: ServerName ---> settings.py: SERVER_NAME

Any help/suggestions?

\d



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



Re: Installing django

2009-05-21 Thread Chris Lawlor

Just to see what all the fuss is about, most of that video is the guy
configuring his particular application. The actual Django install is
very straightforward.

On May 21, 1:53 am, Kenneth Gonsalves  wrote:
> On Thursday 21 May 2009 11:15:29 LeonTheCleaner wrote:
>
> > @sdc, yeah I plan to try webfaction. The only thing is I just quickly
> > checked out their demo video to setup django and itès 21 mins. I am
> > blown away to see how complicated just setting this up, and I am an
> > experienced windows programmer. Just expected a lot less steps.
>
> why follow their steps? just follow the steps in the django tutorial.
> --
> regards
> kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeEncodeError

2009-05-21 Thread Karen Tracey
I see I specified the unicode string incorrectly in my shell example.  Turns
out it doesn't make a difference in this case except for the specifics of
the exception, but what it should have been was:

>>> u = u'\u2013'
>>> stderr = open('/tmp/stderr.ascii.out', 'w')
>>> print >> stderr, '%s' % u
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
position 0: ordinal not in range(128)
>>> import codecs
>>> stderr = codecs.open('/tmp/stderr.utf8.out', mode='w', encoding='utf-8')
>>> print >> stderr, '%s' % u
>>> quit()

Karen

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



Re: UnicodeEncodeError

2009-05-21 Thread Karen Tracey
On Thu, May 21, 2009 at 2:48 AM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On May 20, 11:56 pm, Sean Brant  wrote:
> > Traceback (most recent call last):
> >[snip]
> >   File "/home/58124/containers/django/contest/apps/entries/management/
> > commands/grabentries.py", line 73, in handle
> > print '[%s] Saved - Entry "%s"' % (datetime.now(), entry.title)
> > UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
> > position 56: ordinal not in range(128)
> >
> > Is there any way to insure that this error does not occur? Do I need
> > to do some sort of unicode conversion with Django?
>
> Since you haven't showed us any actual code, we can't help you.


Well, we've got the line causing the exception, and the exception, and
that's probably enough code in this case.  We could use more information on
the environment.

The line in question is trying to print possibly Unicode data to a
device/file that is apparently set up to use the ascii codec.  What is
stdout here?  If it's a file, perhaps you can open it via the right codec.
Plain open() is going to use the ascii codec, which will be a problem for
any non-ascii data.  Using codecs.open() you can specify whatever encoding
you like that will be capable of representing the data you have:

>>> u = u'\2013'
>>> stderr = open('/tmp/stderr.ascii.out', 'w')
>>> print >> stderr, '%s' % u
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'ascii' codec can't encode character u'\x81' in position
0: ordinal not in range(128)
>>> import codecs
>>> stderr = codecs.open('/tmp/stderr.utf8.out', mode='w', encoding='utf-8')
>>> print >> stderr, '%s' % u
>>> quit()

If stdout is a device, and you can't reconfigure it to support non-ASCII
output, then you'll have to take care not to send non-ASCII data to it.  You
can print repr of the Unicode strings instead...that will be ugly but at
least it won't cause an exception.

Karen

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



Re: How do I migrate

2009-05-21 Thread madhan...@gmail.com

Hi kg, Thanks for your prompt reply. It was really helpful. Is there
any tutorial which explains on how to migrate the Applications
developed using Django. Django has been setup in our server. Our task
would be to setup the application in our server from the current
server.

Thanks again for timely help.

Thanks,
\madhan

On May 18, 4:57 pm, Kenneth Gonsalves  wrote:
> On Monday 18 May 2009 15:54:13 madhan...@gmail.com wrote:
>
> > 1. Do we need to install and configure Django form scratch inorder to
> > make the system workable?
>
> yes.
>
> > 2. Is it not possible to make it work just by move the files and DB.
>
> no
>
> check the django documentation for details. Oh, and, if you do not have shell
> access, it is going to be near impossible to do this.
>
> --
> regards
> kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Decimal format fields in Admin

2009-05-21 Thread Kostas M


I have a model/table with a field declaration:

money=models.DecimalField(max_digits=12,
decimal_places=2,verbose_name=u'π/υ').

When I see this field in the Admin pages, this field is just a box,
without any formatting,
e.g. thousand separation marks, which is important for the visibility
of the amounts,
such as 1700 instead of 17.000.000,00   (in my country we use '.'
as thousand
separators, and ',' for decimals).

Is it possible such a display in the Admin pages?

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



ViewDoesNotExist error on Apache2 with mod_wsgi

2009-05-21 Thread Miguel Martins

Greetings.

I have to deploy a Django application in Ubuntu for my current
assignment. I've already finished my application on Windows, yet I'm
having trouble migrating it to Ubuntu. It runs just fine when I use
Django's server (python manage.py runserver). However, my assignment
specifically requires that the application runs on Apache2 (and other
web servers later on, but for now I just need to worry about Apache2).

httpd.conf:

LoadModule rewrite_module libexec/mod_rewrite.so
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /home/miguel/Blog/apache/django.wsgi

django.wsgi:

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'Blog.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
sys.path.append('/home/miguel/')
sys.path.append('/home/miguel/Blog/')

-

My Django project is, naturally, located in /home/miguel/Blog/. The
blog application is located in /home/miguel/Blog/blog/.

Here's what the apache log reads:


[Thu May 21 11:10:55 2009] [warn] module rewrite_module is already
loaded, skipping
[Thu May 21 11:10:55 2009] [warn] module wsgi_module is already
loaded, skipping
[Thu May 21 11:10:55 2009] [notice] mod_python: Creating 8 session
mutexes based on 6 max processes and 25 max threads.
[Thu May 21 11:10:55 2009] [notice] mod_python: using mutex_directory /
tmp
[Thu May 21 11:10:55 2009] [notice] Apache/2.2.9 (Ubuntu) mod_python/
3.3.1 Python/2.5.2 mod_wsgi/2.3 configured -- resuming normal
operations
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=13276): Exception occurred processing WSGI script '/home/miguel/
Blog/apache/django.wsgi'.
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/handlers/wsgi.py", line 239, in
__call__
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] response =
self.get_response(request)
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/handlers/base.py", line 67, in
get_response
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] response =
middleware_method(request)
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/middleware/common.py", line 57, in
process_request
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]
_is_valid_path("%s/" % request.path_info)):
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/middleware/common.py", line 142, in
_is_valid_path
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]
urlresolvers.resolve(path)
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 246, in
resolve
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] return
get_resolver(urlconf).resolve(path)
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 181, in
resolve
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] sub_match =
pattern.resolve(new_path)
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 124, in
resolve
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] return
self.callback, args, kwargs
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]   File "/usr/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 133, in
_get_callback
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1] raise
ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str
(e))
[Thu May 21 05:11:00 2009] [error] [client 127.0.0.1]
ViewDoesNotExist: Could not import Blog.blog.views. Error was: No
module named blog.views

Can anyone help me solve this? Any ideas why it's stating that the
"blog.views" module doesn't exist? 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Manual selection of database connections

2009-05-21 Thread junqed

I have some DB servers with similar structure but with different data.
I want to select a connection manually. How can I do it?

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



Re: Cache and i18n

2009-05-21 Thread Dmitriy Sodrianov

On 20 май, 23:13, Alex Gaynor  wrote:
> On Wed, May 20, 2009 at 12:01 PM, Dmitriy Sodrianov wrote:
>
>
>
>
>
> > Hi, there!
>
> > I've configured bilingual site. At this site some forms are present.
> > All the forms field 'verbose_name' attribute are marked with ugettext
> > utility.
>
> > The problem is that when language is changed labels for form's fields
> > does not change.
>
> > All the localization files are provided and properly configured.
>
> > Is that somehow related to cache of page? Tried to use never_cache
> > decorator, didn't help.
>
> You need to use ugettext_lazy, since strings for fields are defined at the
> module level and are therefore evaluated when the class is compiled.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

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



Re: perfomance question

2009-05-21 Thread James Bennett

On Thu, May 21, 2009 at 5:10 AM, Chris Withers  wrote:
> What was your solution in the end? I'm always interested this kind of
> batching of results, and I'm very new to Django...

The Django tutorial mentions this -- a Django QuerySet is "lazy",
which means that it doesn't do a query until it absolutely has to. So,
for example, simply writing "SomeModel.objects.all()" doesn't
immediately execute the query -- you can tack filters and whatnot onto
it, and all they'll do is refine the query that eventually gets
executed. In this specific case, slicing a QuerySet (e.g.,
"SomeModel.objects.all()[:5]" or whatever) will just add a LIMIT
clause to the query that gets executed, rather than retrieving all the
objects and then plucking a few out.


-- 
"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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Split models.py to smaller parts.

2009-05-21 Thread x_O

First of all thanks for all responses.

I've still one more question which is connected to that one particular
issue. What if classes are importing each other.

models/
   __init__.py
   one.py
   two.py

== __init__.py ===

from one import ModelOne
from two import ModelTwo

=== one.py 

from django.db import models
from two import ModelTwo

class ModelOne(models.Model):
two = models.ForeignKey('ModelTwo')
class Meta:
app_label = 'appname'

def all_one(self):
return ModelTwo.objects.all()


=== two.py 

from django.db import models
from one import ModelOne

class ModelTwo(models.Model):
one = models.ForeignKey('ModelOne')

class Meta:
app_label = 'appname'

def all_two(self):
return ModelOne.objects.all()


In case above appears  problem with cyclic import. I know that example
is a bit silly but I'm trying to use it in real project files with
more than 1000 lines ~300 per class.

 Traceback 
./manage.py validate
Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/var/lib/python-support/python2.5/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/var/lib/python-support/python2.5/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 219, in execute
output = self.handle(*args, **options)
  File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 348, in handle
return self.handle_noargs(**options)
  File "/var/lib/python-support/python2.5/django/core/management/
commands/validate.py", line 9, in handle_noargs
self.validate(display_num_errors=True)
  File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 246, in validate
num_errors = get_validation_errors(s, app)
  File "/var/lib/python-support/python2.5/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/var/lib/python-support/python2.5/django/db/models/
loading.py", line 128, in get_app_errors
self._populate()
  File "/var/lib/python-support/python2.5/django/db/models/
loading.py", line 57, in _populate
self.load_app(app_name, True)
  File "/var/lib/python-support/python2.5/django/db/models/
loading.py", line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/.../appname/models/__init__.py", line 1, in 
from one import ModelOne
  File "/.../appname/models/one.py", line 2, in 
from two import ModelTwo
  File "/.../appname/distmodels/models/two.py", line 2, in 
from one import ModelOne
ImportError: cannot import name ModelOne


Regards
x_O

On 3 Maj, 19:48, Malcolm Tredinnick  wrote:
> On Sun, 2009-05-03 at 10:01 -0700, Rick Wagner wrote:
> > > > Thank you for the explanation. I think this trick is not in the
> > > > Documentation yet
>
> > > That's because it's pretty basic Python knowledge. I'm sure I've read  
> > > on this list that basic Python knowledge isn't supposed to be  
> > > documented in Django as it's already part of the official Python  
> > > documentation (http://docs.python.org/tutorial/modules.html#packages)
>
> > Most of it is a knowledge of Python, but the need for adding things
> > like app_label is not obvious. Once I'm clear on how Django's model
> > framework introspects the Python classes it finds in an application,
> > I'll try to write up an internally consistent addition to the docs.
>
> The preferred solution is to fix the problem so that app_label doesn't
> have to be specified. There's already a ticket open that, I'm sure,
> since people keep saying "I'll work on it". It's probably not even that
> hard to get right -- although all attempts to do so to date have only
> fixed the basic cases and not the general situation (arbitrary levels of
> imports).
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: perfomance question

2009-05-21 Thread Chris Withers

Rodrigo Aliste P. wrote:
> OH! It does it alone! Another awesome thing to my awesomeness list of 
> django.

What was your solution in the end? I'm always interested this kind of 
batching of results, and I'm very new to Django...

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk

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



Re: Multiple decorator and maybe caching, not sure

2009-05-21 Thread mark hellewell
2009/5/21 Jarek Zgoda 

> Use low-level Django cache framework to cache retrieved object but
> don't forget to invalidate the cache upon each change to this object.
> Like:
>
> obj = cache.get(obj_key)
> if not obj:
> obj = ObjClass.objects.get(pk=obj_pk)
> cache.set(obj_key, obj)
> return obj
>

It's really that straight-forward,  what a nice surprise!

Thanks,
Mark


> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl
>
>
> >
>

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



Re: FileBrowser: Models for media

2009-05-21 Thread patrickk

I´d use a slightly different approach:

class Course(models.Model):
name = ...

class Material(models.Model):
course = models.ForeignKey(Course)
media = FileBrowseField(max_length=200, blank=True, null=True)
order = models.PositiveIntegerField("Order", blank=True,
null=True)

the positive side effect is, that you´re able to _order_ your material
(which might - sooner or later - be necessary).

about subclassing filefield or filepathfield: there´s no good reason
whatsoever. if you think it´s better to subclass any of the given
fields, you may want to submit a patch.

thanks,
patrick


On May 20, 7:17 pm, "eric.frederich"  wrote:
> My application models Training courses.  Those courses may have
> training material in a variety of formats.
>
> I came across FileBrowser and it seems real nice.
>
> Are any of you using a FileBrowseField in your models?
>
> I get the feeling that what I'm doing below is wrong... creating a
> model that holds nothing but a single field just so that I can have a
> ManyToMany relationship on it.
>
> Also, why is it that FileBrowseField is not a subclass of FileFIeld or
> FilePathField ?
>
> class Course(models.Model):
>     name = models.CharField(max_length=100)
>     materials  = models.ManyToManyField('Material')
>
> class Material(models.Model):
>     media = FileBrowseField(max_length=200, blank=True, null=True)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple decorator and maybe caching, not sure

2009-05-21 Thread mark hellewell
Hello,

I've written a few decorators for my views. Each of the decorators operate
on the same object obtained from the db backend using ORM and each checks
different things.  I'll chain them together sometimes,  but not always.  In
the decorated view I'll usually be doing yet another
MyObjectClass.objects.get(...) (as I've done in each of the decorators
already) to carry out some operation or other on the object.

My question is,  is there some way to either avoid having to make repeated
ORM queries in each of the decorators or to cache the result of the first
ORM query (no matter which decorator it's obtained from)? All I'm usually
doing it a .get(id=123) to get an object to work on and it feels wasteful.

Is some form of middleware to cache db queries the "done thing" here?  Not
sure where to start.

Thanks for any help!
Mark

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



UploadHandlers and the Storage API

2009-05-21 Thread Ian Lewis
Hi all,

I am currently using an implementation of the django.files.storage API to
read/write files from Amazon S3 using the django storage API. This has
worked well except for in cases where one wants to read from one stream and
write to the storage API.

One case I am running into is that I would like to create an Upload handler
that skips putting files in tmp/ and uploads them directly to S3 as the
files could be quite large. I could do this by writing directly to S3 but I
would rather go through the storage API as I would like to change it out for
the local storage API when developing/running tests.

The storage API currently handles writing itself in the save method by
reading from a file like object, but you currently can't do the opposite
where you are given chunks of data and you want to pass them along.

Is there a particularly good way to solve this kind of problem?

Ian

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



Re: Admin interface is slow

2009-05-21 Thread BinseerN Forent
Thank you guys for your reply .. Actually i am using django+satchmo (sorry
for not mentioning that.. my bad).. I thought admin interface related stuffs
are related to Django only.. Thats why i didn't mentioned satchmo...

In satchmo there is a patch for my particular problem explicitly ..

http://www.satchmoproject.com/trac/ticket/631

On Wed, May 20, 2009 at 8:15 PM, Alex Gaynor  wrote:

>
>
> On Wed, May 20, 2009 at 9:31 AM, Skylar Saveland <
> skylar.savel...@gmail.com> wrote:
>
>>
>> Is this something having to do with pools?
>>
>>
> Django doesn't pool connections, so unless the original poster is using an
> external pool, no.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
>
> >
>

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



NullBooleanField fails as radio buttons

2009-05-21 Thread worksology

I'm struggling to get a NullBooleanField to work as radio buttons. By
default, a NullBooleanField (NBF) shows up as a select widget with
options: "Unknown", "Yes", "No".  I assumed I could add this to
"radio_fields" and have it turn those options into radio buttons with
the same labels. But no dice: I get an error that radio_fields only
works with FKs and when choices is set (I think this is an oversight,
as BooleanFields and NullBooleanFields have implicit choices).

Anyway, I wrote my own choices, add 0, 1, and '' blank options to the
field, which works fine, except that Django insists on giving me an
additional blank option "None" when I have blank=True set (which is
required if I want the field to allow saving as None/blank).

Ok, so I consider those two things bugs -- 1) boolean-type fields
should accommodate the RadioSelect widget without extra work and, 2)
given explicit "choices", the field should not add its own
"blank" ("None") option (especially when a blank option is provided in
those choices).

My real question is: how can I change the label of the "None" option?
As it stands, the only way I can get NBF to work as radio buttons is
with the options: "None", "No", "Yes", which is completely ambiguous.
I would like to change "None" to "Hidden" (even "Unknown" -- which is
what's used in the select widget -- would be fine).

Am I overlooking an easy way to change this label? If the answer is to
subclass the RadioSelect widget (presumably to get it to work the way
it already should), could someone help start me with the code, or
point me to a good resource for subclassing widgets?

Thanks!

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



Re: Installing django

2009-05-21 Thread Kenneth Gonsalves

On Thursday 21 May 2009 12:09:05 LeonTheCleaner wrote:
> I did not know that. Can you tell me how to do that? Is there a link
> that shows the procedure?

just follow the django install docs for apache/mod_python. There is an apache 
config file in webfaction where you can make changes
>
> I use svn myself, but the apache stuff, not sure how to set that up.

the key thing is to set it up on your own home box - once you know how to do 
that, you are never dependent on any 'third-party' deployment and you will be 
all set to move to a VPS which is the next step up the food chain.

-- 
regards
kg
http://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeEncodeError

2009-05-21 Thread Daniel Roseman

On May 20, 11:56 pm, Sean Brant  wrote:
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
>   File "/home/58124/data/python/django/django/core/management/
> __init__.py", line 362, in execute_manager
>     utility.execute()
>   File "/home/58124/data/python/django/django/core/management/
> __init__.py", line 303, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/home/58124/data/python/django/django/core/management/
> base.py", line 195, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/home/58124/data/python/django/django/core/management/
> base.py", line 222, in execute
>     output = self.handle(*args, **options)
>   File "/home/58124/containers/django/contest/apps/entries/management/
> commands/grabentries.py", line 73, in handle
>     print '[%s] Saved - Entry "%s"' % (datetime.now(), entry.title)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
> position 56: ordinal not in range(128)
>
> Is there any way to insure that this error does not occur? Do I need
> to do some sort of unicode conversion with Django?

Since you haven't showed us any actual code, we can't help you.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best Django host

2009-05-21 Thread LeonTheCleaner

Thanks for replying. When you mention like that, yeah it looks way
simpler than what is shown.

Can you use a domain name like www.mysite.com? It does not need to be
a subdomain, right?

Also after you get the welcome screen, how do you install your django
application you downloaded from the net?



Thanks.

On May 21, 12:23 am, Laszlo Antal  wrote:
> On Wed, 20 May 2009 10:51 pm, LeonTheCleaner wrote:
>
> > Thanks all for replying. I appreciate it.
>
> > Webfaction seems to be popular amongst many. The only thing is I just
> > quickly
> > checked out their demo video to setup django and it is 21 mins. I am
> > blown away to see how complicated just setting this up, and I am an
> > experienced windows programmer. Just expected a lot less steps.
>
> Hi,
>
> I have never watch that video.
> But all you need to do to setup django is to create a django application
> in applications and then in sites assign a domain name for it or use
> the
> default username.webfactional.com and that's it.
> You point your browser to the domain name and get the Django welcome
> screen.
> It takes about 1minutes or less to do all that.
> Even installing satchmo took about 10minutes only,including installing
> all the dependencies.
>
> I have tried many hosting companies and webfaction is the best so far.
>
> Hope it helps
>
> lzantal
>
> http://twitter.com/lzantalhttp://www.antalconsulting.com
>
>
>
>
>
> > Have you guys checked outwww.djangohosting.ch?They claim their
> > django is
> > one click solution. I wonder how that one compares to webfaction both
> > for features
> > and the ease of installations. Their small django setup thumbnail
> > looks very straightforward.
>
> > It was also high up in the django supported site.
>
> > Thanks again.
> > Laszlo Antal
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Installing django

2009-05-21 Thread LeonTheCleaner

I did not know that. Can you tell me how to do that? Is there a link
that shows the procedure?

I use svn myself, but the apache stuff, not sure how to set that up.



Thanks.

On May 21, 12:29 am, Kenneth Gonsalves  wrote:
> On Thursday 21 May 2009 11:46:54 LeonTheCleaner wrote:
>
> > You mean for dreamhost? Yeah I was following those. It is just that
> > when people mentioned webfaction is easier I wanted mention their 21
> > min video which is still lots of work.
>
> I meant for webfaction - I use webfaction, but do not use their django set up
> method. I set it up like I would set up django on my own box - using the
> latest svn trunk and configuring apache. It certainly doesn't take 21 minutes.
> --
> regards
> kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Installing django

2009-05-21 Thread Kenneth Gonsalves

On Thursday 21 May 2009 11:46:54 LeonTheCleaner wrote:
> You mean for dreamhost? Yeah I was following those. It is just that
> when people mentioned webfaction is easier I wanted mention their 21
> min video which is still lots of work.

I meant for webfaction - I use webfaction, but do not use their django set up 
method. I set it up like I would set up django on my own box - using the 
latest svn trunk and configuring apache. It certainly doesn't take 21 minutes.
-- 
regards
kg
http://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to write subdomain from django apps

2009-05-21 Thread Joshua Partogi
Sorry for this lame question.

I just saw an application called suggestionbox.com and it's able to write
subdomain based on the customer id. Do we access and write BIND
configuration on the fly for this? Or is there a better way to do it?

Anyone that has experience with this?

Thanks very much in advance for sharing

-- 
Join Scrum8.com.

http://scrum8.com/member/jpartogi/
http://twitter.com/scrum8

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



Re: Best Django host

2009-05-21 Thread Laszlo Antal


On Wed, 20 May 2009 10:51 pm, LeonTheCleaner wrote:
>
> Thanks all for replying. I appreciate it.
>
> Webfaction seems to be popular amongst many. The only thing is I just
> quickly
> checked out their demo video to setup django and it is 21 mins. I am
> blown away to see how complicated just setting this up, and I am an
> experienced windows programmer. Just expected a lot less steps.
Hi,

I have never watch that video.
But all you need to do to setup django is to create a django application 
in applications and then in sites assign a domain name for it or use 
the
default username.webfactional.com and that's it.
You point your browser to the domain name and get the Django welcome 
screen.
It takes about 1minutes or less to do all that.
Even installing satchmo took about 10minutes only,including installing 
all the dependencies.

I have tried many hosting companies and webfaction is the best so far.

Hope it helps

lzantal

http://twitter.com/lzantal
http://www.antalconsulting.com

>
> Have you guys checked out www.djangohosting.ch? They claim their
> django is
> one click solution. I wonder how that one compares to webfaction both
> for features
> and the ease of installations. Their small django setup thumbnail
> looks very straightforward.
>
> It was also high up in the django supported site.
>
>
>
> Thanks again.
> Laszlo Antal

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



Re: Installing django

2009-05-21 Thread LeonTheCleaner

You mean for dreamhost? Yeah I was following those. It is just that
when people mentioned webfaction is easier I wanted mention their 21
min video which is still lots of work.



Thanks.

On May 20, 11:53 pm, Kenneth Gonsalves  wrote:
> On Thursday 21 May 2009 11:15:29 LeonTheCleaner wrote:
>
> > @sdc, yeah I plan to try webfaction. The only thing is I just quickly
> > checked out their demo video to setup django and itès 21 mins. I am
> > blown away to see how complicated just setting this up, and I am an
> > experienced windows programmer. Just expected a lot less steps.
>
> why follow their steps? just follow the steps in the django tutorial.
> --
> regards
> kghttp://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---