Re: help request using python_twitter api with django and errno 25

2008-06-27 Thread James Bennett

On Fri, Jun 27, 2008 at 11:02 PM, Hani <[EMAIL PROTECTED]> wrote:
> My questions are:
> 1. can anyone explain the error a little better to me?
> 2. Is it a bug in the python-twitter api, or in django, or in my code?
> 3. Is there a fix that does not involve using the patch?
> 4. If I have to use the patch, could someone provide easy to follow
> steps for me to apply it (absolutely no clue here)?

Question 1 (this is going to gloss over a lot of things, but hopefully
will help):

Basically, on Unix and Unix-like systems, there is a concept of a
"controlling terminal" -- for example, if you're on Mac OS X (which is
BSD-ish Unix under the hood), you can open a Terminal and launch a
Python interpreter; in this case, the instance of Terminal.app you're
using will be the "controlling terminal" of the process the Python
interpreter is running in.

It's often useful to get information about your controlling process,
because this can answer some fairly practical question; in the case of
the Twitter API, it was looking for the username of the logged-in user
who launch the Python process, which is available if, for example, it
was launched directly from a command line. Python's standard 'os'
module allows you to do this sort of thing fairly easily. However,
there are cases where the controlling process doesn't support this
sort of thing, and in those cases the Python functions will raise an
IOError (you can also take some steps to determine in advance whether
your controlling process supports these functions).

Question 2: Yes, it is (or was) a bug in the Twitter module.

Question 3: the ticket you're looking at is a duplicate of one I filed
earlier, and which was marked fixed some time ago:
http://code.google.com/p/python-twitter/issues/detail?id=14

The relevant patch catches the IOError and falls back to a default
value when the necessary information isn't available:
http://code.google.com/p/python-twitter/source/detail?r=113#

So if you do an svn up on your copy of the Twitter module, it should work.


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

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



Displaying in template ManyToMany

2008-06-27 Thread dxLogan

Hi all,

I am a new user to Django. It's great =) I have to first commend that.

Anyway, I have a question about ManyToMany. Suppose I got object like
Email, and with a ManyToMany relationship with Recipients.

I couldn't do this in template :


context = {'emails':emails.objects.all()}
---
{% for email in emails %}
{% for author in email.authors %}
author.name
{% endfor %}
{% endfor %}


The email.author is a
 like that. I am not suppose to copy every data out to an
explicit dictionary {} , right?

Thank you very much!

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



help request using python_twitter api with django and errno 25

2008-06-27 Thread Hani

Hi,

First, please know that I am a novice to django and python so please
be patient.

Am trying to use the python-twitter api with a little django app. When
I test the commands from the terminal, they run perfectly, however,
when run from django, they produce an errno 25 as follows:

[Errno 25] Inappropriate ioctl for device
Request Method: GET
Request URL:http://192.168.2.6/loa/
Exception Type: OSError
Exception Value:[Errno 25] Inappropriate ioctl for device
Exception Location: build/bdist.linux-i686/egg/twitter.py in
_GetUsername, line 1498
Python Executable:  /usr/bin/python
Python Version: 2.5.1

The code that produces this error is as follows:

def sendtwit(twit):
twitter_api=twitter.Api(username='user', password='pw')
twitter_api.PostUpdate(twit)
return

Anyway, it seems the issue has been documented here:
http://code.google.com/p/python-twitter/issues/detail?id=16  with a
patch attached.

My questions are:
1. can anyone explain the error a little better to me?
2. Is it a bug in the python-twitter api, or in django, or in my code?
3. Is there a fix that does not involve using the patch?
4. If I have to use the patch, could someone provide easy to follow
steps for me to apply it (absolutely no clue here)?

Thanks tons in advance,

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



Re: method="POST" form problems. Help required

2008-06-27 Thread Peter of the Norse

Nested forms are allowed in XHTML5[1]. Since there isn’t a browser  
that does it yet, you’ll have to wait.

On Jun 21, 2008, at 5:36 PM, [EMAIL PROTECTED] wrote:

> Atlast, I found the bug, login.html inherits from base page. So, the
> form mentioned in the above code is nested inside a GET form.
>
> Now I get one doubt. Can't we nest the forms?  Does nesting of forms
> make sense in any context?



[1]: http://www.whatwg.org/specs/web-forms/current-work/#changes
-- 
Peter of the Norse


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



Re: Need help including a queryset in every view

2008-06-27 Thread Brandon Taylor

Holy shiesse, the man himself! Thank you very much for pointing me to
that portion of the documentation, I hadn't quite made it there in my
Definitive Guide book, but that's exactly what I needed. I ordered the
Practical Django projects book the other day, can't wait to get it!

Kind regards,
Brandon

On Jun 27, 6:14 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 27, 2008 at 4:27 PM, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> > What's the best way to go about this? Obviously I don't want to have
> > to pass the queryset into the context of every action, in every view
> > across the entire site :)
>
> Same way you make anything accessible to lots of different template contexts:
>
> http://www.djangoproject.com/documentation/templates_python/#subclass...
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Encoding issue. Weird characters showing up.

2008-06-27 Thread Karen Tracey
On Fri, Jun 27, 2008 at 10:03 PM, Malcolm Tredinnick <
[EMAIL PROTECTED]> wrote:

> On Fri, 2008-06-27 at 05:17 -0700, jwpeddle wrote:
> > I'm using latest svn with postgres. My db is UTF-8. Django is UTF-8.
> > My HTML is UTF-8.
> >
> > When I pull a string that has é in it, it shows up as a little box (or
> > a little box with 0082 in it in Firefox 3). If I try to print the
> > value to runserver, I get:
> > UnicodeEncodeError at /contact/request-info/
> > 'charmap' codec can't encode character u'\x82' in position 2:
> > character maps to 
> >
> > What am I missing? How do I get these characters to display properly?
>
> The data is broken, so it's not a display question. In UTF-8, small e
> with an acute would be 0xc9 0xa9. I don't know what encoding is going to
> give you 0x82 for that character (it's not even Microsoft's silly cp1252
> encoding).
>

Small e with acute is 0x82 in some of the old DOS codepages like 437 and
850, if that's any help.

Karen

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



Re: Install of SVN Django on Cygwin fails on sqlite3

2008-06-27 Thread Michael Wieher

not hard to test this, just open up a python shell and type 'import
sqlite3' and see what happens

Python 2.5.1 (r251:54863, Mar  7 2008, 03:41:45)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>>


that is good.  if it says error, something is broken, although I can't
speak for Python2.5 in Windoze.


On Fri, Jun 27, 2008 at 9:06 PM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:
>
>
> On Fri, 2008-06-27 at 07:54 -0700, yellowbkpk wrote:
>> I just did a fresh install of Cygwin (and Cygwin's python version),
>> checked out django-trunk, and ran python setup.py install.
>>
>> When I try to runserver, I get:
>>
>> $ python2.5 manage.py runserver
>> Validating models...
>> Unhandled exception in thread started by > 0x7fd61bfc>
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.5/site-packages/django/core/management/
>> commands/runserver.py", line 47, in inner_run
>> self.validate(display_num_errors=True)
>>   File "/usr/lib/python2.5/site-packages/django/core/management/
>> base.py", line 112, in validate
>> num_errors = get_validation_errors(s, app)
>>   File "/usr/lib/python2.5/site-packages/django/core/management/
>> validation.py", line 22, in get_validation_errors
>> from django.db import models, connection
>>   File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line
>> 17, in 
>> backend = __import__('%s%s.base' % (_import_path,
>> settings.DATABASE_ENGINE), {}, {}, [''])
>>   File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
>> base.py", line 22, in 
>> raise ImproperlyConfigured, "Error loading %s module: %s" %
>> (module, e)
>> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
>> module: No module named pysqlite2
>
> That tells you exactly what the error is. It's a little odd, thouh,
> since I thought "import sqlite3" worked always for Python 2.5. It will
> only fall back to trying to import pysqlite2 if "import sqlite3" doesn't
> work.
>
> So, basically, your Python installation isn't correct. The problem isn't
> with Django, it's earlier in the pipeline.
>
> Regards,
> Malcolm
>
>
>
> >
>

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



Re: Install of SVN Django on Cygwin fails on sqlite3

2008-06-27 Thread Malcolm Tredinnick


On Fri, 2008-06-27 at 07:54 -0700, yellowbkpk wrote:
> I just did a fresh install of Cygwin (and Cygwin's python version),
> checked out django-trunk, and ran python setup.py install.
> 
> When I try to runserver, I get:
> 
> $ python2.5 manage.py runserver
> Validating models...
> Unhandled exception in thread started by  0x7fd61bfc>
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/runserver.py", line 47, in inner_run
> self.validate(display_num_errors=True)
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 112, in validate
> num_errors = get_validation_errors(s, app)
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> validation.py", line 22, in get_validation_errors
> from django.db import models, connection
>   File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line
> 17, in 
> backend = __import__('%s%s.base' % (_import_path,
> settings.DATABASE_ENGINE), {}, {}, [''])
>   File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 22, in 
> raise ImproperlyConfigured, "Error loading %s module: %s" %
> (module, e)
> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
> module: No module named pysqlite2

That tells you exactly what the error is. It's a little odd, thouh,
since I thought "import sqlite3" worked always for Python 2.5. It will
only fall back to trying to import pysqlite2 if "import sqlite3" doesn't
work.

So, basically, your Python installation isn't correct. The problem isn't
with Django, it's earlier in the pipeline.

Regards,
Malcolm



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



Re: Encoding issue. Weird characters showing up.

2008-06-27 Thread Malcolm Tredinnick


On Fri, 2008-06-27 at 05:17 -0700, jwpeddle wrote:
> I'm using latest svn with postgres. My db is UTF-8. Django is UTF-8.
> My HTML is UTF-8.
> 
> When I pull a string that has é in it, it shows up as a little box (or
> a little box with 0082 in it in Firefox 3). If I try to print the
> value to runserver, I get:
> UnicodeEncodeError at /contact/request-info/
> 'charmap' codec can't encode character u'\x82' in position 2:
> character maps to 
> 
> What am I missing? How do I get these characters to display properly?

The data is broken, so it's not a display question. In UTF-8, small e
with an acute would be 0xc9 0xa9. I don't know what encoding is going to
give you 0x82 for that character (it's not even Microsoft's silly cp1252
encoding).

How did the data get into the database in the the first place? That
would seem to be where the problem lies. If you did it all through
Django, please try to create a small example (a few lines of code) that
shows how you can insert this type of data.

Regards,
Malcolm



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



Re: Models in multiple files and django command extensions

2008-06-27 Thread M.Ganesh

Vidja wrote:
> Hi all
>
> Thanks to the help of Magus on IRC i have been able to setup my models
> and their functions as separate files.
> This works great for maintenance (the models.py file is created
> automatically through a (ehm, perl) script)
> But unfortunately it breaks Django command extensions.
> This is the structure I have (between <> means directory):
>
> 
>   
>   views.py
>   __init__.py
>   
>   __init__.py
>   modelfile1.py
>   modelfile2.py
>   modelfile3.py
>
>
> in my __init__.py in  i'm importing modelfile1.py etc.
>
> I can use the models and methods in my views using 'from
> project.app.models import classname'
> So far so good, works like a charm exept that the django command
> extensions does not SEE the models using  shell_plus or graph_models.
> I guess it has something to do with app_label not set but I don't know
> how to.
>
> Could someone help me getting this kind of setup working with the
> command extensions?
>
>   
Do you mean this?

#modelfile1.py

class MyModel(models.Model):
..
..

class Meta:
   app_label = 'your.app.name'

Regards Ganesh

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



Re: default user authentication, and session timeout

2008-06-27 Thread hyde

this works, Thanks!

On Jun 27, 7:24 pm, Alex Slesarev <[EMAIL PROTECTED]> wrote:
> On Jun 28, 1:13 am, hyde <[EMAIL PROTECTED]> wrote:
>
> > How to control thesessiontimeoutvalue if using Django's default
> > user authentication?
>
> Look in django docs (available in svn trunk). You should set
> SESSION_COOKIE_AGE variable (in seconds) in the settings.py file.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems retrieving array from POST

2008-06-27 Thread [EMAIL PROTECTED]

> @Daniel
> If I use $.post("/post_test/",{'data':data});, in firebug the post
> data shows as undefined.

That doesn't sound right, I have some jQuery Ajax stuff(http://
github.com/alex/django-ajax-validation/tree/master/ajax_validation/
templatetags/jquery_validation.py) and it posts arrays like that just
fine(see the views.py file for how I recieve the post).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: default user authentication, and session timeout

2008-06-27 Thread Alex Slesarev

On Jun 28, 1:13 am, hyde <[EMAIL PROTECTED]> wrote:
> How to control the session timeout value if using Django's default
> user authentication?

Look in django docs (available in svn trunk). You should set
SESSION_COOKIE_AGE variable (in seconds) in the settings.py file.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems retrieving array from POST

2008-06-27 Thread Alex Slesarev

> How would I use 'print post_text'? I'd have to do it in the
> interactive shell, in which case, how would I replicate
> request.POST...?

Just insert it to the 'post_handler' function and see results in
console (of course, application should be started in console with
'manage.py runserver').
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need help including a queryset in every view

2008-06-27 Thread James Bennett

On Fri, Jun 27, 2008 at 4:27 PM, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> What's the best way to go about this? Obviously I don't want to have
> to pass the queryset into the context of every action, in every view
> across the entire site :)

Same way you make anything accessible to lots of different template contexts:

http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext


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

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



Re: Need help including a queryset in every view

2008-06-27 Thread ristretto.rb

> I have a navigation list powered by a model in my base site template.
> So, I need to create a queryset object that will be available to every
> view.

Middleware comes to mind (see the docs), but I'm new to django, and
perhaps that's not the best way.  I'd be interested to see what other
djangonauts say.



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



Dynamic rtf files with Django templates

2008-06-27 Thread Juanjo Conti

Hi, I have just comment in my blog how to use Django template system to 
generate dynamic rtf files.

A string filter was made to encode unicode strings into rtf format.

BTW, it's in spanish:
http://www.juanjoconti.com.ar/2008/06/27/generar-archivos-rtf-en-forma-dinamica-desde-django/

Juanjo

PS: has anyone used Django tempalte system for this stuff?
-- 
mi blog: http://www.juanjoconti.com.ar

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



Re: sessions in template (outside of views)

2008-06-27 Thread Brandon Taylor

Hi Bobby,

Typically what I do is set the value from the session into a variable
that I pass into the context.

#in views.py
def my_action(request)
account_num = request.session['AccountNum']
return render_to_response('the_template.html', {'account_num' :
account_num})

#in the_template.html
{{ account_num }}

HTH,
Brandon

On Jun 27, 3:33 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> i'm trying to view session variables on the screen in a template.  I
> know the session variable has a value because i've tested it in my
> view.  I'm trying this in my template but not getting any results:
>
> Account #: {{ request.session.AccountNum }}
>
> What could I be doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: The Lost Fingers

2008-06-27 Thread Juanjo Conti

Could you recommend me some Django (the artist) hits?

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

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



Need help including a queryset in every view

2008-06-27 Thread Brandon Taylor

Hello everyone,

I have a navigation list powered by a model in my base site template.
So, I need to create a queryset object that will be available to every
view.

What's the best way to go about this? Obviously I don't want to have
to pass the queryset into the context of every action, in every view
across the entire site :)

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



customizing django-admin.py

2008-06-27 Thread Michael P. Soulier
I am supporting an environment where users will be adding "plugin" pages
to an existing Web interface. As such they will be running
"startproject" and "startapp" on a regular basis. I would like to
customize the output to the environment.

Is there a standard way to do this beyond wrapping django-admin.py in a
shell script and post-processing the created files?

Thanks,
Mike
-- 
Michael P. Soulier <[EMAIL PROTECTED]>
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein



signature.asc
Description: OpenPGP digital signature


sessions in template (outside of views)

2008-06-27 Thread Bobby Roberts

i'm trying to view session variables on the screen in a template.  I
know the session variable has a value because i've tested it in my
view.  I'm trying this in my template but not getting any results:

Account #: {{ request.session.AccountNum }}

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



Re: problem getting mod_python to serve application..

2008-06-27 Thread Mike Caldwell
I've had a very similar problem and it turned out to be a permission
problem.  I had used svn to get the latest django in my home directory and
then linked django from there to /usr/lib/python2.4/site-packages.  The
apache user had read/execute privileges up the /usr/lib pathway to
django/core/handlers/modpython.py but not through /home/user.  So I had add
read/execute permission to my home directory (luckily no one else is on this
server) and then it started working.  You may wish to check the permissions
all the way through the /home directories to make sure the apache user can
get to modpython.py.

On Thu, Jun 26, 2008 at 12:34 PM, Adi <[EMAIL PROTECTED]> wrote:

>
> I get the following error when I hit my website
> http://ipaddress/enterathletes/
>
> DocumentRoot:   '/var/www/html'
>
> URI:'/enterathletes/'
> Location:   '/enterathletes/'
> Directory:  None
> Filename:   '/var/www/html/enterathletes'
> PathInfo:   '/'
>
> Phase:  'PythonHandler'
> Handler:'django.core.handlers.modpython'
>
> Traceback (most recent call last):
>
>  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1537, in HandlerDispatch
>default=default_handler, arg=req, silent=hlist.silent)
>
>  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1202, in _process_target
>module = import_module(module_name, path=path)
>
>  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 304, in import_module
>return __import__(module_name, {}, {}, ['*'])
>
> ImportError: No module named django.core.handlers.modpython
>
> In my /usr/lib/python2.5/site-packages, I have
> lrwxrwxrwx  1 root root 34 Jun 25 13:52 django -> /home/adi/django-
> trunk/django/
>
> In my python.conf apache conf file,
>
> LoadModule python_module modules/mod_python.so
>
> # Override type-map handler for /var/www/manual
> 
>
>SetHandler default-handler
>
> 
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>PythonDebug On
>PythonPath "['/home/adi/Enterathletes_py/src','/home/arustgi/
> django-trunk'] + sys.path"
> 
>
> I was able to do
> python manage.py validate
> and
> python manage.py load data
> from '/home/adi/Enterathletes_py/src/mysite
>
> What am I missing? What should I check?
> >
>

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



Re: psycopg2

2008-06-27 Thread Federico Di Gregorio

On Jun 25, 4:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Why not put it up on Google Code? It's SVN so importing should be a
> breeze (if not, I'm sure the Google guys would be glad to lend a
> hand), you have a Wiki and a Bug tracker also.

I will never, *ever*, put my code in a system that is not 100% free
software. So, no Launchpad, no Google Code, no sourceforge and so on.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django newforms and dynamically adding "lines"

2008-06-27 Thread Hendrijk Templehov

Hey there,

I am currently diving into django and experiment with the newforms
api. I have found some nice blog entries about it and read the docs
but for now I am wondering what the best practice for a use case like
that would be:

There is a model called "Bill" which holds a bill with a receipient, a
date and so on AND: BillLines. This BillLine holds information about
every dicounted entry. A complete bill would look as expected:

Customer
Address

100 nails $0.5
1 hammer $19

total  $19.5

My BillLine - model looks like this:

class BillLine(models.Model):
 sortoder = models.FloatField()
 amount   = models.FloatField()
 description = models.CharField(max_length=255)
 price = models.FloatField()

 bill = models.ForeignKey(Bill, related_name='bill_lines')


The user should see an interface which stores all the "global" data
such as "receipient" and a table with "bill lines". He enteres
100nails0.5 and clicks a Plus-Button to add a new line. This
should add a new empty row below the "nails line" via ajax but should
be executable with deactivated JS, too.

What would the django way be to achieve that goal?


Thank you!
nuzux

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



Re: intial form field values using session variables

2008-06-27 Thread Arien

On Fri, Jun 27, 2008 at 1:12 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> [...] I'm trying to print those session variables to the screen in
> step 2 (ie the 2nd form) so the user can review what was previously
> entered on the first fom.

(If this page immediately follows the first page, you could of course
take the values for the request itself.)

> as an old ASP programmer when we wanted to just print a session
> variable we'd code:
>
> <%=session("whatever")%>
>
> What is the django equiv?
>
> I'm trying this:
>
> {{request.session["whatever"] }}
>
> but it says it can't parse the remainder...

Use the syntax of Django's template language:

{{ request.session.whatever }}


Arien

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



Re: Problems setting up LDAP backend

2008-06-27 Thread satish

Thanks Jeff for this tip. When I explicitly do "from django.conf
import settings' it seems to print the AUTHETICATION_BACKENDS. Looks
like if I do not do explicit import- I can print the
AUTHENTICATION_BACKENDS.

Python 2.4.3 (#1, Oct 23 2006, 14:19:45)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.AUTHENTICATION_BACKENDS
'reviewboard.accounts.backends.LDAPBackend'


(InteractiveConsole)
>>> settings.AUTHENTICATION_BACKENDS
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'settings' is not defined

manage.py is already doing the import right?
try:
 import settings # Assumed to be in the same directory.

when I changed that line to

try:
# import settings # Assumed to be in the same directory.
from django.conf import settings # Assumed to be in the same
directory.

I get the following error.

Traceback (most recent call last):
  File "manage.py", line 121, in ?
if settings.DEBUG:
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

I set an environment variable -

 setenv DJANGO_SETTINGS_MODULE django.conf

Still the same issue.

What am I doing wrong?

Thanks



On Jun 27, 10:29 am, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> satish wrote:
> > Hi Jeff,
>
> > Thanks for helping me out here.
>
> > I did enable logging on the LDAP server. Looks like the requests are
> > not going to the LDAP server. I removed backends.pyc. When I run the
> > server the next time, it should have generated the backends.pyc right?
> > I also removed django.contrib.auth.backends.ModelBackend.pyc- which is
> > not getting re-generated as well.  Any thoughts?
>
> Well, I still don't know exactly what is going wrong...
> When you attempt to authenticate, what exactly happens? Do you get a
> "bad username/password" when you try to log in?
>
> Is 'settings_local.py' even being used? Usually the settings module is
> 'settings.py'. Do you have one of those as well? I've never had any
> problem with the patch from #2507 for ldap auth. Is that what you are
> using? I put the authentication_backends and ldap-specific settings into
> my settings.py
>
> Try this:
>
>     $ python manage.py shell
>     >>> from django.conf import settings
>     >>> settings.AUTHENTICATION_BACKENDS
>     ('reviewboard.accounts.backends.LDAPBackend',)
>
> (to make sure it is in fact set correctly)
>
> Jeff Anderson
>
>  signature.asc
> 1KDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopg2

2008-06-27 Thread James Bennett

On Fri, Jun 27, 2008 at 6:19 AM, Will <[EMAIL PROTECTED]> wrote:
> Ah, sorry. Reading the Django book had led me to believe I was stuck
> with psycopg:

The change which allows user-defined backends to be plugged in
happened after the 0.96 release, so the book is accurate for 0.96.


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

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



Re: intial form field values using session variables

2008-06-27 Thread Bobby Roberts

> You can pass in an "initial" argument when you instantiate your Form,
> as explained 
> here:http://www.djangoproject.com/documentation/newforms/#dynamic-initial-...
>
> Arien

cool!  I overlooked that.  I've got it working great.  I'm trying to
print those session variables to the screen in step 2 (ie the 2nd
form) so the user can review what was previously entered on the first
fom.

as an old ASP programmer when we wanted to just print a session
variable we'd code:

<%=session("whatever")%>

What is the django equiv?

I'm trying this:

{{request.session["whatever"] }}

but it says it can't parse the remainder...


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



ManyToMany field has old value in custom save method

2008-06-27 Thread [EMAIL PROTECTED]

Here is a part of a model:
~
class News(models.Model):
title = models.CharField(max_length=255)
categories = models.ManyToManyField(Category)
def save(self):
print self.title
print self.categories.all()
super(News, self).save()
print self.categories.all()
print
~

If I update a news and change the categories - the changes will be
save, but self.categories will show the old categories (until next
save call). How can I get to the new objects of a ManyToMany  relation
in the save method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using Google App engine helper with Django and getting a templat not found error

2008-06-27 Thread Chuck

I have created the polls application verbatum from the tutorial with
the exception that I am using the helper code to run the app on
Google.  The app works just fine on the SDK but whenever I upoade the
app to Google I get the following error:

Template does not exist at \
index.html

Template-loader postmortem
Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.load_template_source:
/base/data/home/apps/myapp/1.41/templates/index.html (File does not
exist)
/templates/index.html (File does not exist)
Using loader
django.template.loaders.app_directories.load_template_source:

My dirs in settings.py is set up as follows:

ROOT_PATH = os.path.dirname(__file__)


TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/
www/
#django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
ROOT_PATH + "/templates",
'/templates',
)


I have looked everywhere and do not know what to do.

Is there something in the helper that could be causing this?  Any
other ideas?

Please help

Chuck

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



Re: Problems setting up LDAP backend

2008-06-27 Thread Jeff Anderson

satish wrote:

Hi Jeff,

Thanks for helping me out here.

I did enable logging on the LDAP server. Looks like the requests are
not going to the LDAP server. I removed backends.pyc. When I run the
server the next time, it should have generated the backends.pyc right?
I also removed django.contrib.auth.backends.ModelBackend.pyc- which is
not getting re-generated as well.  Any thoughts?
  

Well, I still don't know exactly what is going wrong...
When you attempt to authenticate, what exactly happens? Do you get a 
"bad username/password" when you try to log in?


Is 'settings_local.py' even being used? Usually the settings module is 
'settings.py'. Do you have one of those as well? I've never had any 
problem with the patch from #2507 for ldap auth. Is that what you are 
using? I put the authentication_backends and ldap-specific settings into 
my settings.py


Try this:

   $ python manage.py shell
   >>> from django.conf import settings
   >>> settings.AUTHENTICATION_BACKENDS
   ('reviewboard.accounts.backends.LDAPBackend',)

(to make sure it is in fact set correctly)


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: At what point is the WSGI request or server object available?

2008-06-27 Thread Daniel Roseman

On Jun 27, 3:52 pm, "Leeland (The Code Janitor)" <[EMAIL PROTECTED]>
wrote:
> Sorry if this seems obvious I am a new comer to Django development.
>
> There are attributes I want to get at in the request or WSGI server
> objects to test if I should set up some specialized channels in my
> Django application.
>
> Problem is neither of these seem to be available until I get to the
> view method call.
>
> Specifically what I am trying to do is figure out if the server has
> been run as a mod_python, FCGI process, AJP process or by the built in
> test server. Then take the appropriate actions to so that print goes
> to the server's access logs, print >> sys.stderr goes to the server's
> error logs. I'd also like to automatically get the python logger doing
> the same.
>
> I have found that in a given view I can do something like
>
> if 'wsgi.errors' in request.META:
>    # do setup work here
>
> I can't seem to put this code anywhere else (like in my settings.py
> file) where it can get picked up by the whole system.
>
> I am sure I am missing something here that is probably obvious and
> silly.
>
> Thanks in advance!
>
> + Leeland


Sounds like that should go in a custom piece of middleware -
specifically, one that implements process_request.

See the documentation here:
http://www.djangoproject.com/documentation/middleware/#writing-your-own-middleware

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



Re: Newforms and textareas

2008-06-27 Thread Roodie

Dang, thanks, I knew it is something obvious...
Interesting thing is that it worked so far, I mean it rendered
properly :-)

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



Re: Problems setting up LDAP backend

2008-06-27 Thread satish

Hi Jeff,

Thanks for helping me out here.

I did enable logging on the LDAP server. Looks like the requests are
not going to the LDAP server. I removed backends.pyc. When I run the
server the next time, it should have generated the backends.pyc right?
I also removed django.contrib.auth.backends.ModelBackend.pyc- which is
not getting re-generated as well.  Any thoughts?

I even try to put log statement (reviewboard...)LDAPBackend, which is
not getting printed. Which is weird,

class LDAPBackend:
"""
Authenticate against a user on an LDAP server.
"""

def authenticate(self, username, password):
try:
sys.stderr.write("in init")


My config looks like the following. Do I need to define anything else
in settings_local.py. Your help is very much appreciated. Thanks.

AUTH_PROFILE_MODULE = 'accounts.Profile'
BUILTIN_AUTH = False
AUTHENTICATION_BACKENDS = (
'reviewboard.accounts.backends.LDAPBackend'
)
#'django.contrib.auth.contrib.ldapauth.LDAPBackend'
LDAP_EMAIL_DOMAIN =
LDAP_URI =
LDAP_SERVER_URI = 'ldap://..
LDAP_UID_MASK =
LDAP_ANON_BIND_UID =
LDAP_ANON_BIND_PASSWD =
LDAP_DEBUG = True
DEBUG = True

Thanks
Satish

On Jun 26, 11:04 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> satish wrote:
> > Hi All,
>
> > I was able to setup review board with the default auth backend.
> > However I am having problem setting it with LDAP.
>
> It looks like you are using the patch from ticket #2507
>
> When you say "no errors or warnings" what undesired behavior are you
> experiencing?
>
> some things that might help to diagnose:
>
> * tail the log of the ldap server to see if a request is actually
> hitting it.
> * try authenticating a user from the python shell
>
> If you are still stuck, provide some more details, and I'll be happy to
> help from there.
>
> Jeff Anderson
>
>  signature.asc
> 1KDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm's error dict is filled before is_valid() is called

2008-06-27 Thread omat

Thanks, you are right. My generic form template accesses forms errors
and they get populated.

This is behavior seems a little strange but other way (errors being
populated only when is_valid is called) would have different
complications I guess.

FYI, in my blog app, a blog item has several entries (i.e. pages). A
user can start a new blog item and submit his entry at the same time,
or select an existing blog item and append a new page to that item,
all using the same form. This is what I am tring to do.

Thanks for the replies.



On Jun 27, 7:35 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 27, 2008 at 12:10 PM, omat <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the clarification.
>
> > Apparently my demo case of the problem was not appropriate, but my
> > real problem is still there.
>
> > I have 2 ModelForms that I want to receive data at a single form
> > submission.
>
> > item_form is required only if 'item' field of the entry_form is
> > empty.
>
> > So I build the logic in my view that handles the form as follows:
>
> > def form(request):
> > ...
> >if request.method == 'POST':
> >item_form = ItemForm(request.POST, instance=item)
> >entry_form = EntryForm(request.POST, instance=entry)
> >if entry_form.is_valid():
> >e = entry_form.save(commit=False)
> >e.user = request.user
> >if not form.cleaned_data['item']:
> >if item_form.is_valid():
> >e.item = item_form.save()
> >else:
> >return render_to_response(...)
> >e.save()
> >return HttpResponseRedirect(...)
> >else:
> >return render_to_response('blog/form.html',
> >  {'entry_form': entry_form,
> >   'item_form': item_form,
>
> > context_instance=RequestContext(request))
>
> > But when I submit an invalid entry_form (i.e. nothing related to item
> > form is executed or accessed other then the initialization item_form =
> > ItemForm(request.POST, instance=item)) the item_form arrives at my
> > template with a filled errors dictionary.
>
> > Any opinions?
>
> item_form doesn't 'arrive at' your template with a filled in errors
> dictionary.  Rather, rendering of item_form checks for (accesses) the errors
> attribute, which triggers validation and populates the errors dictionary.
> If you ever (including during rendering in the template) attempt to access
> errors, errors gets populated.  So you need to change your logic so that you
> do not generate a form that will get validation errors in cases where you
> don't care to see those errors because of some other circumstance.  Sorry,
> it isn't quite clear to me what you are trying to do exactly so it's hard
> for me to be more specific as to recommendations.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newforms and textareas

2008-06-27 Thread Arien

On Fri, Jun 27, 2008 at 11:04 AM, Roodie <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have a slight problem. I am using a custom form field to do some
> extra validation / filtering on a specific kind of field. The code is
> very simple:
>
> class HtmlEditorField(forms.Textarea):
>def clean(self, value):
>value = filter_common( value )
>return super(HtmlEditorField, self).clean(value)

This won't work. The forms.Textarea you're subclassing is a *widget*,
not a *field*!

> And I use this field to render the textareas:
>
> class RandomEditForm( ModelForm ):
>description = HtmlField()
>
> Now the question is: where can I set the ROWS attribute for this
> Textarea?

See http://www.djangoproject.com/documentation/newforms/#specifying-widgets


Arien

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



Re: Newforms and textareas

2008-06-27 Thread [EMAIL PROTECTED]

You are creating a field that subclasses a widget, which makes no
sense.  forms.Textare is a widget, not a field.

On Jun 27, 11:04 am, Roodie <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a slight problem. I am using a custom form field to do some
> extra validation / filtering on a specific kind of field. The code is
> very simple:
>
> class HtmlEditorField(forms.Textarea):
>         def clean(self, value):
>                 value = filter_common( value )
>                 return super(HtmlEditorField, self).clean(value)
>
> And I use this field to render the textareas:
>
> class RandomEditForm( ModelForm ):
>         description = HtmlField()
>
> Now the question is: where can I set the ROWS attribute for this
> Textarea?
>
> Tried to do it in my class definition:
>
> class HtmlEditorField(forms.Textarea):
>     widget=forms.Texarea( attrs={'rows':20} )
>
> It simply does nothing. In the rendered HTML code the rows are fixed
> at 10, no matter where I put the attrs part. Any suggestions where
> should I put the row information? I probably missed a very obvious
> piece of documentation somewhere but I am trying to get it working for
> more than a hour now without any success...
>
> Roodie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm's error dict is filled before is_valid() is called

2008-06-27 Thread Karen Tracey
On Fri, Jun 27, 2008 at 12:10 PM, omat <[EMAIL PROTECTED]> wrote:

>
> Thanks for the clarification.
>
> Apparently my demo case of the problem was not appropriate, but my
> real problem is still there.
>
> I have 2 ModelForms that I want to receive data at a single form
> submission.
>
> item_form is required only if 'item' field of the entry_form is
> empty.
>
> So I build the logic in my view that handles the form as follows:
>
> def form(request):
> ...
>if request.method == 'POST':
>item_form = ItemForm(request.POST, instance=item)
>entry_form = EntryForm(request.POST, instance=entry)
>if entry_form.is_valid():
>e = entry_form.save(commit=False)
>e.user = request.user
>if not form.cleaned_data['item']:
>if item_form.is_valid():
>e.item = item_form.save()
>else:
>return render_to_response(...)
>e.save()
>return HttpResponseRedirect(...)
>else:
>return render_to_response('blog/form.html',
>  {'entry_form': entry_form,
>   'item_form': item_form,
>
> context_instance=RequestContext(request))
>
>
> But when I submit an invalid entry_form (i.e. nothing related to item
> form is executed or accessed other then the initialization item_form =
> ItemForm(request.POST, instance=item)) the item_form arrives at my
> template with a filled errors dictionary.
>
> Any opinions?
>

item_form doesn't 'arrive at' your template with a filled in errors
dictionary.  Rather, rendering of item_form checks for (accesses) the errors
attribute, which triggers validation and populates the errors dictionary.
If you ever (including during rendering in the template) attempt to access
errors, errors gets populated.  So you need to change your logic so that you
do not generate a form that will get validation errors in cases where you
don't care to see those errors because of some other circumstance.  Sorry,
it isn't quite clear to me what you are trying to do exactly so it's hard
for me to be more specific as to recommendations.

Karen

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



Re: site_media paths

2008-06-27 Thread alce

> Rename the directory - mod_python uses 'media' dir from django itself.

Thank you Alex. That is not the problem though and can't seem to
find the way to fix it. I can't believe how straightforward it was to
write
and deploy basic site with Django after only 2 Python books and the
Django docs yet I've been stuck with this for 3 days. **sigh**. I
suppose
I'll just give it a rest, finish the site and worry about this when
my head is clearer.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm's error dict is filled before is_valid() is called

2008-06-27 Thread omat

Thanks for the clarification.

Apparently my demo case of the problem was not appropriate, but my
real problem is still there.

I have 2 ModelForms that I want to receive data at a single form
submission.

item_form is required only if 'item' field of the entry_form is
empty.

So I build the logic in my view that handles the form as follows:

def form(request):
...
if request.method == 'POST':
item_form = ItemForm(request.POST, instance=item)
entry_form = EntryForm(request.POST, instance=entry)
if entry_form.is_valid():
e = entry_form.save(commit=False)
e.user = request.user
if not form.cleaned_data['item']:
if item_form.is_valid():
e.item = item_form.save()
else:
return render_to_response(...)
e.save()
return HttpResponseRedirect(...)
else:
return render_to_response('blog/form.html',
  {'entry_form': entry_form,
   'item_form': item_form,
 
context_instance=RequestContext(request))


But when I submit an invalid entry_form (i.e. nothing related to item
form is executed or accessed other then the initialization item_form =
ItemForm(request.POST, instance=item)) the item_form arrives at my
template with a filled errors dictionary.

Any opinions?


--
omat



On Jun 27, 6:47 pm, Arien <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 27, 2008 at 10:39 AM, omat <[EMAIL PROTECTED]> wrote:
>
> > At the instant I initialize my form, the errors dict is filled,
> > although the documentation says, the validation happens after form
> > instance's is_valid() method is called.
>
> > [example snipped]
>
> > Is the documention or the behavior wrong?
>
> Neither. As explained in the docs "the form's data will be validated
> the first time either you call is_valid() or access errors", 
> seehttp://www.djangoproject.com/documentation/newforms/#using-forms-to-v...
>
> Arien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newforms and textareas

2008-06-27 Thread Roodie

Hello,

I have a slight problem. I am using a custom form field to do some
extra validation / filtering on a specific kind of field. The code is
very simple:

class HtmlEditorField(forms.Textarea):
def clean(self, value):
value = filter_common( value )
return super(HtmlEditorField, self).clean(value)

And I use this field to render the textareas:

class RandomEditForm( ModelForm ):
description = HtmlField()

Now the question is: where can I set the ROWS attribute for this
Textarea?

Tried to do it in my class definition:

class HtmlEditorField(forms.Textarea):
widget=forms.Texarea( attrs={'rows':20} )

It simply does nothing. In the rendered HTML code the rows are fixed
at 10, no matter where I put the attrs part. Any suggestions where
should I put the row information? I probably missed a very obvious
piece of documentation somewhere but I am trying to get it working for
more than a hour now without any success...

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



Re: i18n model - tri-lingual data

2008-06-27 Thread [EMAIL PROTECTED]

You should REALLY have a look at this:
http://code.google.com/p/transdb/

On Jun 26, 3:22 pm, pihentagy <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have a 3-lingual app, and there are some model fields translated,
> like this:
>
> class Category(models.Model)
>         name_hu = models.CharField(_(u'név (magyar)'), max_length=255,)
>         name_en = models.CharField(_(u'név (angol)'), max_length=255)
>         name_de = models.CharField(_(u'név (német)'), max_length=255)
>
> In some caces __unicode__ method is used for representing data (like
> in the admin app, and many other places).
> Is there a way I can tell the model about the request's language? Or,
> well, I know it is a violation of MVC, but how to solve this problem?
>
> thanks
> Gergo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm's error dict is filled before is_valid() is called

2008-06-27 Thread Arien

On Fri, Jun 27, 2008 at 10:39 AM, omat <[EMAIL PROTECTED]> wrote:
>
> At the instant I initialize my form, the errors dict is filled,
> although the documentation says, the validation happens after form
> instance's is_valid() method is called.
>
> [example snipped]
>
> Is the documention or the behavior wrong?

Neither. As explained in the docs "the form's data will be validated
the first time either you call is_valid() or access errors", see
http://www.djangoproject.com/documentation/newforms/#using-forms-to-validate-data


Arien

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



ModelForm's error dict is filled before is_valid() is called

2008-06-27 Thread omat

Hi,

At the instant I initialize my form, the errors dict is filled,
although the documentation says, the validation happens after form
instance's is_valid() method is called.

Here is the demonstration:

>>> from blog.forms import ItemForm
>>> from blog.models import Item
>>> form = ItemForm({}, instance=Item())
>>> form.errors
{'title': [u'This field is required.']}
>>>

The ItemForm is a ModelForm build from Item model.

Is the documention or the behavior wrong?


Thanks,
omat

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



Django Setup with apache & mod_python

2008-06-27 Thread nerdydork

Question on apache setup using mod_python, the documentation states "…
and replace mysite.settings with the Python import path to your Django
project’s settings file." <-- would this be the full path to the
settings.py file?

I tried this and all I'm getting is a blank page - for every URL I
enter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: CMD output

2008-06-27 Thread Molly

What if the exe is just clicked on though, then there wouldn't be any
writing in the cmd to write that.

Thanks for the help :)

Molly

On Jun 27, 10:35 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I created an exe app and when it is run in the CMD there is a lot of
> > output of what is going on on the site. I was wondering if there was a
> > way for words that I write to show up and not all of the output.
>
> I'm not sure whether the output is being written to stdout or to
> stderr, but if it's stdout, usually you can use
>
>c:\project\> some.exe > nul
>
> (adding "> nul") to suppress the output in a dosbox.
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Stability of trunk and 1.0 target: experience, testimonials?

2008-06-27 Thread Norman Harman

I've been using trunk for over 9mo for in production website 
http://storymash.com

During that time, there's been 2-3 times my unittests have failed after 
I've svn updated django.  Each time was a fairly quick fix.  API changes 
aren't hard bugs to track down and fix.  The advantages of all the great 
stuff that has been added to trunk far outweigh the time spent.  In 
fact, I've learned a bit about Django internals tracking down those 
failing unittests.

My current employer, uses .96 or newforms-admin/trunk for several minor 
but still business critical and public facing portions of it's websites 
statesman.com and austin360.com  with *no* problems(well no Django 
problems anyway ;).  The .96 projects started before I arrived or else 
they would probably be trunk as well.


I've been nothing but impressed with the diligence and abilities of 
Django developers and community to maintain multiple stable branches.


Compare Django release discipline and record to other major frameworks. 
  And your PHB's should be scared to use anything but Django.

-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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



Install of SVN Django on Cygwin fails on sqlite3

2008-06-27 Thread yellowbkpk

I just did a fresh install of Cygwin (and Cygwin's python version),
checked out django-trunk, and ran python setup.py install.

When I try to runserver, I get:

$ python2.5 manage.py runserver
Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/runserver.py", line 47, in inner_run
self.validate(display_num_errors=True)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 112, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 22, in get_validation_errors
from django.db import models, connection
  File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line
17, in 
backend = __import__('%s%s.base' % (_import_path,
settings.DATABASE_ENGINE), {}, {}, [''])
  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", line 22, in 
raise ImproperlyConfigured, "Error loading %s module: %s" %
(module, e)
django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
module: No module named pysqlite2

Also,
$ python2.5 --version
Python 2.5.1

Any tips on how to fix this?

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



At what point is the WSGI request or server object available?

2008-06-27 Thread Leeland (The Code Janitor)

Sorry if this seems obvious I am a new comer to Django development.

There are attributes I want to get at in the request or WSGI server
objects to test if I should set up some specialized channels in my
Django application.

Problem is neither of these seem to be available until I get to the
view method call.

Specifically what I am trying to do is figure out if the server has
been run as a mod_python, FCGI process, AJP process or by the built in
test server. Then take the appropriate actions to so that print goes
to the server's access logs, print >> sys.stderr goes to the server's
error logs. I'd also like to automatically get the python logger doing
the same.

I have found that in a given view I can do something like

if 'wsgi.errors' in request.META:
   # do setup work here

I can't seem to put this code anywhere else (like in my settings.py
file) where it can get picked up by the whole system.

I am sure I am missing something here that is probably obvious and
silly.

Thanks in advance!

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



Re: per view caching

2008-06-27 Thread Rufman

ok...I found the answer to my first question...but I'm still searching
for the second...

Stephane

On Jun 27, 1:44 pm, Rufman <[EMAIL PROTECTED]> wrote:
> I have two questions concerning per-view caching:
>
>    1. Does "per-view" caching mean that Django gets the result from
> the cache regardless of the parameters passed into the view. I.e. if i
> have a view cache_test(request, record_id) and call it a first time
> with record_id=1, caching this result and then calling it with
> record_id=2, will it show the cached result?
>    2. Is the result with applied template filters cached, or is the
> template re rendered?
>
> Thanks for the help and insight
>
> Stephane
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: views.py: Always a simple return?

2008-06-27 Thread RossGK

Thanks for the comments Norman,

The appeal of HTTP is that it is so broadly seen as benign by networks
that everyone can pretty much use it regardless of their network
environment.

The meta refresh tag is probably good for refreshes in the order of
seconds, but for a pseudo real-time streaming application I think it's
too coarse.

Yes - the ajax approach seems to be the best one so far, and I'm
progressing on that despite my weak javascript skills - man that's an
ugly syntax after working in python for a while :)

My Comet concerns were from references to iFrames - which scare me a
bit... eg:  http://www.thespanner.co.uk/2007/10/24/iframes-security-summary/

But I'll read some more to see if it might be better than repeated
requests from ajax

R.

On Jun 26, 11:48 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> RossGKwrote:
>
> > Stuff
>
> I think you don't want HTTP.
>
> In other words you are wanting (like the Comet folks) HTTP to do things
> it was not designed to do.  In other words you are avoiding its
> strengths and chasing after its weaknesses.
>
> Not sure what your real requirement is but,
>
> Look at the Meta Refresh 
> Taghttp://webdesign.about.com/od/metataglibraries/a/aa080300a.htm
>
> Which AJAX is an improvement on, which sounds like you are already using
> and I'm not sure why it doesn't work for you.  And stateless requests
> are far more elegant than open TCP connections.  There are reasons the
> HTTP Internet has exploded in a way client server never did.
>
>  From my understanding of Comet it's more or less exactly what you are
> asking for.  http://www.google.com/search?q=django%20comet
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Database Relationship Question

2008-06-27 Thread bhunter

> And this is why the Django community rocks, two examples and a full
> explaination with a link in less than 10 minutes, GW guys

Absolutely!  Thank you all so much!  In just 15 minutes I had great
answers from everyone.


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



Re: CMD output

2008-06-27 Thread Tim Chase

> I created an exe app and when it is run in the CMD there is a lot of
> output of what is going on on the site. I was wondering if there was a
> way for words that I write to show up and not all of the output.

I'm not sure whether the output is being written to stdout or to 
stderr, but if it's stdout, usually you can use

   c:\project\> some.exe > nul

(adding "> nul") to suppress the output in a dosbox.

-tim



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



Re: views.py: Always a simple return?

2008-06-27 Thread RossGK

Thanks for the thoughtful replies Scott. Client-side request
orchestration is where I see myself headed.  Your list of concerns is
resonates with my concerns about the barriers on this as well.

To be thorough I've been exploring the idea from both server side and
client side, and the client side does seem to offer the attractive
element of avoiding network-based disruption form long http sessions.
I'll have to read up more on HTTP keep-alive approaches.  I'm not sure
how consistent browsers are in their response to  and I'd like my
solution to work broadly on the obvious 3 browsers anyway.  And I
wonder about proxy servers and NAT behaviour - perhaps its
transparent, but I'll have to dig into that a bit.

Thanks though for your thoughts on a path forward.

Ross.

On Jun 26, 10:34 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Ross, I had one more thought.
>
> Are most browsers capable of using persistent HTTP for XMLHttpRequests?  If
> so, and *assuming your main motivation is simply to be more efficient by
> using a single HTTP connection* for your traffic, then I think you might be
> able to implicitly exploit persistent HTTP to get what you want.  If you use
> a pull model rather than a push model, and have the client make its requests
> frequently enough that most browsers' timeouts don't tear down the
> persistent HTTP connection, and if you ensure that your responses are
> suitable for use with persistent HTTP (i.e., they contain a valid
> Content-Length header), then I think you may satisfy your goal.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Models in multiple files and django command extensions

2008-06-27 Thread Vidja

Hi all

Thanks to the help of Magus on IRC i have been able to setup my models
and their functions as separate files.
This works great for maintenance (the models.py file is created
automatically through a (ehm, perl) script)
But unfortunately it breaks Django command extensions.
This is the structure I have (between <> means directory):


  
  views.py
  __init__.py
  
  __init__.py
  modelfile1.py
  modelfile2.py
  modelfile3.py


in my __init__.py in  i'm importing modelfile1.py etc.

I can use the models and methods in my views using 'from
project.app.models import classname'
So far so good, works like a charm exept that the django command
extensions does not SEE the models using  shell_plus or graph_models.
I guess it has something to do with app_label not set but I don't know
how to.

Could someone help me getting this kind of setup working with the
command extensions?



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



default user authentication, and session timeout

2008-06-27 Thread hyde

How to control the session timeout value if using Django's default
user authentication?

Thanks,

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



Re: Anyone got a backend for MS SQL Server working?

2008-06-27 Thread gordyt

Ulf I haven't played with this second solution, but I did just check
out a copy of the django-pyodbc project.  You should be OK following
the author's instructions.  He said to add the django-pydobc directory
(where ever you choose to put it) to your PYTHONPATH.  The name of the
module(s) that get imported do not have a "-" in them... they are
entities like contrib.admin.models and db.mssql.  By adding  django-
pydobc to your PYTHONPATH you are just giving Python another place to
look when importing stuff.

--gordon


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



CMD output

2008-06-27 Thread Molly

I created an exe app and when it is run in the CMD there is a lot of
output of what is going on on the site. I was wondering if there was a
way for words that I write to show up and not all of the output.

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



Re: intial form field values using session variables

2008-06-27 Thread Arien

On Fri, Jun 27, 2008 at 8:42 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> i'm trying to use session variables as initial values for certain form
> fields as such:
>
>AccountNum = forms.CharField
> (initial=request.session["AccountNum"],max_length=20, required=True,
> label = "Account #")
>
> i'm getting this:
>
> NameError: name 'request' is not defined
>
>
> how do i use a session variable for initial data?

You can pass in an "initial" argument when you instantiate your Form,
as explained here:
http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values


Arien

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



intial form field values using session variables

2008-06-27 Thread Bobby Roberts

i'm trying to use session variables as initial values for certain form
fields as such:

AccountNum = forms.CharField
(initial=request.session["AccountNum"],max_length=20, required=True,
label = "Account #")

i'm getting this:

NameError: name 'request' is not defined


how do i use a session variable for initial data?


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



Re: User Filtering

2008-06-27 Thread M.Ganesh



TiNo wrote:
> Maybe even nicer, a selectbox containing all users, and an input that
> pops up on focus to filter. That way the form degrades nicely when js
> is turned off. Makes a big selectbox though...
>
>   
Hi TiNo

I am also looking for a similar solution. Can you please point me to a 
tutorial, walk-through or something

Regards Ganesh


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



Re: The Lost Fingers

2008-06-27 Thread Etienne Robillard

On Fri, 27 Jun 2008 11:47:35 +0100
"Emily Rodgers" <[EMAIL PROTECTED]> wrote:

> 
> I am listening to Django and Stephane right now (and using Django) :)

Emilie-Claire Barlow is also a great pick for smooth jazz lovers!

She's from Canada, but I'm not sure if she's at the Montreal jazz fest,
however.. :)

Cheers,
Etienne

 
> > -Original Message-
> > From: django-users@googlegroups.com 
> > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > [EMAIL PROTECTED]
> > Sent: 27 June 2008 03:04
> > To: Django users
> > Subject: Re: The Lost Fingers
> > 
> > 
> > While definitely off-topic, I appreciate the heads up. I live 
> > in a world where the framework and the guitarist often intersect.
> > 
> > On Jun 26, 9:01 am, Dan <[EMAIL PROTECTED]> wrote:
> > > This isn't related to Django the framework but Django the 
> > musician, I 
> > > figure you'd find it interesting anyway.
> > >
> > > I saw in the newspaper this morning that a group from Quebec called 
> > > The Lost Fingers released an album called Lost in the 80's 
> > where they 
> > > play well known songs in Django Reinhardt style. The album 
> > costs $40 
> > > on Amazon but only $15 if you buy it from a Quebec Label / 
> > Discstore 
> > :http://www.archambault.ca/store/product.asp?sku=002106354&typ
> > e=1&lang...
> > >
> > > Or just use bittorrent :)
> > > 
> > 
> 
> 
> 
> > 

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



Re: Problems retrieving array from POST

2008-06-27 Thread elspiko

Thanks for your comments.

@Alex
How would I use 'print post_text'? I'd have to do it in the
interactive shell, in which case, how would I replicate
request.POST...?

@Daniel
If I use $.post("/post_test/",{'data':data});, in firebug the post
data shows as undefined.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Filtering

2008-06-27 Thread TiNo

You could have the autocomplete opperate on a dummy_seat input, and
have the js fill in the correct user id in a hidden 'seat' field on
blur.

Maybe even nicer, a selectbox containing all users, and an input that
pops up on focus to filter. That way the form degrades nicely when js
is turned off. Makes a big selectbox though...

just my 2p



On Jun 26, 8:40 pm, Greg Taylor <[EMAIL PROTECTED]> wrote:
> I've got a model that represents a boat of rowers which has eight
> seats (order is important). The easiest way to handle this was a model
> with eight foreign keys:
>
> class Boat(models.Model):
>   seat_1 = models.ForeignKey(User)
>   [...]
>   seat_8 = models.ForeignKey(User)
>
> Which is fine and great, but now in the user-space boat editing page,
> we have to go through a large list of usernames for each seat to find
> the person we're looking for. The site refers to everyone by their
> full names, usernames are only used for logging in, so we need to be
> able to filter or auto-complete based on first/last name (which is not
> a problem).
>
> Does anyone know of a good way to let them quickly search by name and
> set these seats without having to navigate away from the page? Any
> AJAX utilities to recommend? I looked at YUI auto-complete, but that
> might get tricky since ForeignKey expects an integer in this case
> (id=int). It's very easy to set up auto-complete, but I'm not sure of
> the best way to have it set the Int.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Validation Problem with ModelChoiceField

2008-06-27 Thread TiNo

Looking at the source, ModelChoiceField validates the given id against
the initial queryset, where you provided an empty one.
"models.Gallery.objects.none()"
So no id's validate. I think changing none() to all() should make it
work.

TiNo

On Jun 26, 9:01 pm, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a serious validation problem with a form using a
> ModelSchoiceField.
>
> Forms:
>
> class MyModelChoiceField(forms.ModelChoiceField):
>     def label_from_instance(self, obj):
>         return "%s" % obj.name
>
> class PictureForm(forms.Form):
>     image          = forms.ImageField(label='Picture')
>     gallery        = MyModelChoiceField(models.Gallery.objects.none(),
> empty_label=None)
> __
>
> View:
> picture_form = forms.PictureForm()
> picture_form.fields['gallery'].queryset = Gallery.objects.filter(...)
>
> It displays all fine, my ModelchoiceField has all Gallery-Entries I
> pass.
> But when it comes to validation an ValidationError is raised.
>
> I cannot understand this at all. Everthing is properly passed to the
> server.
> request.POST['gallery']  is the right Gallery-id, everthing seems fine
> but it does not work.
>
> Please help me, these ModelChoiceField drive me crazy!
>
> Thanks, Toni
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django newcomer needs help on concept of views

2008-06-27 Thread bruno desthuilliers

On 27 juin, 09:47, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I just started learning about python and django. For the past months I
> was working on a project using a PHP framework (I guess, the name
> would not be important right now :).  For my initial experiment, I
> would like to port my last project that I used with PHP to django.
> The project contains 10 tables, and most of them have relationships
> between one another.  So, I think this is considered as one
> application.
>
> Anyway, I am used to having separate files to facilitate different
> controllers (I think it's called views in django).

Yeps.

> On the other hand,
> django uses one views.py for one application.

That's the default convention, but you can organize your views as you
like. And you can even follow the convention while having you
functions in different modules - you just have to turn your views
module into a package that exposes the functions in it's submodules.
You'll find relevant doc here:

http://docs.python.org/tut/node8.html
and more specifically here:
http://docs.python.org/tut/node8.html#SECTION00840

>  Is there anyway I can
> have a views/parts.py or parts_views.py that interacts with part
> model,

It goes the same wrt/ models.


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



Kwippy - microblogging using django

2008-06-27 Thread Dipankar Sarkar

Hey guys

I and a coupla more django developers recently released a micro-
blogging platform called kwippy (http://kwippy.com) ... currently it
is in beta and invite only (obv mail me to get an instant invite)

We need to get more people to use the service and help us test our
infrastructure. We aim to use django and better RoR by miles (twitter
is on RoR)

Feel free to add your email to our beta invites if you visit the site.

Dipankar Sarkar
dipankar [at] kwippy.com
http://kwippy.com/dipankar

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



Re: Encoding issue. Weird characters showing up.

2008-06-27 Thread jwpeddle

I should also note that no, I did not accidently use __str__ instead
of __unicode__
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Encoding issue. Weird characters showing up.

2008-06-27 Thread jwpeddle

I'm using latest svn with postgres. My db is UTF-8. Django is UTF-8.
My HTML is UTF-8.

When I pull a string that has é in it, it shows up as a little box (or
a little box with 0082 in it in Firefox 3). If I try to print the
value to runserver, I get:
UnicodeEncodeError at /contact/request-info/
'charmap' codec can't encode character u'\x82' in position 2:
character maps to 

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



Re: Mobile version of a site

2008-06-27 Thread Ian Lawrence

Hi,
> Is there a recommended way to go about this? Do I have to recreate all
> my views?
Mobile sites are usually just alternate templates on the same views.
So, the question is how to work out what it is that wants to 'view'
your 'views'?.  For this look at
http://code.google.com/p/minidetector/ which is an application which
adds a ".mobile" attribute to your request objects, which means the
requester is coming to you from a mobile phone (cellphone), PDA, or
other device that should be considered small screened.
Once you know this in main_site.settings:

TEMPLATE_DIRS = (
'/path/to/templates/mainsite.com/',
'/path/to/templates/default/',
)

and in mobile_site.settings:

from main_site.settings import *
TEMPLATE_DIRS = (
'/path/to/templates/mobile.mainsite.com/',
'/path/to/templates/default/'
)

The first line imports all of the settings from your main site. Then
overwrite the TEMPLATE_DIRS setting to point to the mobile version of
the templates (and fall back to default templates if there isn't a
mobile specific version). Because every app also gets a default
template you can have a complete mobile site up and running by
creating just one or two mobile base templates.

Finally in apache's vhost configuration, for the main site you do:
SetEnv DJANGO_SETTINGS_MODULE main_site.settings

and in the vhost for the mobile site, you do:
SetEnv DJANGO_SETTINGS_MODULE mobile_site.settings

HTH

Ian
-- 
http://ianlawrence.info

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



per view caching

2008-06-27 Thread Rufman

I have two questions concerning per-view caching:

   1. Does "per-view" caching mean that Django gets the result from
the cache regardless of the parameters passed into the view. I.e. if i
have a view cache_test(request, record_id) and call it a first time
with record_id=1, caching this result and then calling it with
record_id=2, will it show the cached result?
   2. Is the result with applied template filters cached, or is the
template re rendered?

Thanks for the help and insight

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



Re: I'm sure this is one of those clueless newbie mistakes

2008-06-27 Thread [EMAIL PROTECTED]

On Jun 26, 3:06 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote:
> For a start, you want your KVM model to subclass models.Model.

Actually, that was one of the big issues that I had.  If I commented
out the KVM group, I was able to get syncdb to run without erroring
out.

I really need to spend a bit more time reading up on the documentation
as I'm going.  "Shooting from the hip" doesn't always work the way
that you want it to :)

I appreciate everyone's help.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopg2

2008-06-27 Thread Will


> Erm... the database backends _are_ pluggable. Hence, the
> DATABASE_ENGINE setting.
>

Ah, sorry. Reading the Django book had led me to believe I was stuck
with psycopg:

http://www.djangobook.com/en/beta/chapter05/
>DATABASE_ENGINE tells Django which database engine to use. If you’re using a 
>database with Django, DATABASE_ENGINE must be set to one of the following 
>>strings:
>postgresql
>postgresql_psycopg2
>etc

I hadn't realised it was only 100 lines or so of code to write a new
backend.

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



Re: createsuperuser error

2008-06-27 Thread Graham Carlyle

Just wanted to check that the devs are aware that this bug is quite
significant.

If you use django-admin on trunk then syncdb breaks.

The trac tickets relating to it summarise it all (7518 being a duplicate
of 5943) and the awaiting patch seems to fix the problem.

Apologies if its all in hand, just not really sure how "accepted"
tickets are then prioritised.

cheers,
Graham


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



Mobile version of a site

2008-06-27 Thread timc3

HI there,

I want to produce a version of a site for mobile phones so I will have
to serve up different templates, perhaps on a different subdomain.

Is there a recommended way to go about this? Do I have to recreate all
my views?

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



Re: Unable to upload PNG's

2008-06-27 Thread jurian

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



RE: The Lost Fingers

2008-06-27 Thread Emily Rodgers

I am listening to Django and Stephane right now (and using Django) :)


> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: 27 June 2008 03:04
> To: Django users
> Subject: Re: The Lost Fingers
> 
> 
> While definitely off-topic, I appreciate the heads up. I live 
> in a world where the framework and the guitarist often intersect.
> 
> On Jun 26, 9:01 am, Dan <[EMAIL PROTECTED]> wrote:
> > This isn't related to Django the framework but Django the 
> musician, I 
> > figure you'd find it interesting anyway.
> >
> > I saw in the newspaper this morning that a group from Quebec called 
> > The Lost Fingers released an album called Lost in the 80's 
> where they 
> > play well known songs in Django Reinhardt style. The album 
> costs $40 
> > on Amazon but only $15 if you buy it from a Quebec Label / 
> Discstore 
> :http://www.archambault.ca/store/product.asp?sku=002106354&typ
> e=1&lang...
> >
> > Or just use bittorrent :)
> > 
> 



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



Re: i18n model - tri-lingual data

2008-06-27 Thread KONTRA, Gergely

Ok, thanks.

But that means every view should the used model's attribute.

Oh well, this action I call "push", because the view pushes the
parameter to the model, and not the model pulls from the request
(which violates MVC).

And I'm wondering if it's possible to hook up newforms-admin to show
the correct language also.

Thanks your answers BTW

On Fri, Jun 27, 2008 at 11:42 AM, Julien <[EMAIL PROTECTED]> wrote:
>
> That's what I said. The view should pull out the desired field from
> the model based on the language set in the request.
>
> def my_view(request):
>language = request.LANGUAGE_CODE
>category = Category.objects.get(pk=1)  # or whichever you like
>if language == 'en':
>name = category.name_en
>
>
> Remark: the code above is not exactly correct. You'd need to extract
> the first 2 letters of the language code, as it could be 'en-us' for
> example.
>
> On Jun 27, 7:15 pm, "KONTRA, Gergely" <[EMAIL PROTECTED]> wrote:
>> Correct me, but I don't think I can access the view from the model.
>> So how is this possible?
>>
>>
>>
>> On Fri, Jun 27, 2008 at 2:06 AM, Julien <[EMAIL PROTECTED]> wrote:
>>
>> > I reckon your view should check what the language is set in the
>> > request (request.LANGUAGE_CODE), and then pull out the right field
>> > from the model.
>>
>> > On Jun 26, 11:22 pm, pihentagy <[EMAIL PROTECTED]> wrote:
>> > > Hi!
>>
>> > > I have a 3-lingual app, and there are some model fields translated,
>> > > like this:
>>
>> > > class Category(models.Model)
>> > > name_hu = models.CharField(_(u'név (magyar)'), max_length=255,)
>> > > name_en = models.CharField(_(u'név (angol)'), max_length=255)
>> > > name_de = models.CharField(_(u'név (német)'), max_length=255)
>>
>> > > In some caces __unicode__ method is used for representing data (like
>> > > in the admin app, and many other places).
>> > > Is there a way I can tell the model about the request's language? Or,
>> > > well, I know it is a violation of MVC, but how to solve this problem?
>>
>> > > thanks
>> > > Gergo
>>
>> --
>> +-[ Gergely Kontra <[EMAIL PROTECTED]> ]--+
>> |   |
>> | Mobile:(+36 20)356 9656   |
>> |   |
>> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
> >
>



-- 
+-[ Gergely Kontra <[EMAIL PROTECTED]> ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+

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



Re: Django newcomer needs help on concept of views

2008-06-27 Thread Reza Muhammad

Oh yea, thats right.  Since, urls conf look for (for example
mysite.views), which is in mysite app, file views.py,
I should also be able to put mysite.special_views in my urls conf to
look in mysite app, file special_views.py, right?

Thanks alot :)

On Jun 27, 4:17 pm, Alaa Salman <[EMAIL PROTECTED]> wrote:
> On Jun 27, 10:47 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
>
> > Anyway, I am used to having separate files to facilitate different
> > controllers (I think it's called views in django).  On the other hand,
> > django uses one views.py for one application.  Is there anyway I can
> > have a views/parts.py or parts_views.py that interacts with part
> > model, or something like that? Because  currently, I have about 60
> > functions in my PHP's controllers that I want to port to django.  So,
> > that will mean 60 functions in views.py right? Is this the right way
> > to do it?  Or can I separate those functions into multiple views?
>
> You don't need to have them all in one file. I use two for example,
> one called views.py and the other called admin_views.py. So one is for
> the publicly accessible views, and the other is for the admin
> application customization views. You can have as many as you want, and
> in the structure that you find more comfortable. You simply call them
> differently in your urls conf file.
>
> Also, you can have a separate directory for your views and so
> on...just remember the python module part. Go over the documentation
> for views again, i believe this is covered well.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i18n model - tri-lingual data

2008-06-27 Thread Julien

That's what I said. The view should pull out the desired field from
the model based on the language set in the request.

def my_view(request):
language = request.LANGUAGE_CODE
category = Category.objects.get(pk=1)  # or whichever you like
if language == 'en':
name = category.name_en


Remark: the code above is not exactly correct. You'd need to extract
the first 2 letters of the language code, as it could be 'en-us' for
example.

On Jun 27, 7:15 pm, "KONTRA, Gergely" <[EMAIL PROTECTED]> wrote:
> Correct me, but I don't think I can access the view from the model.
> So how is this possible?
>
>
>
> On Fri, Jun 27, 2008 at 2:06 AM, Julien <[EMAIL PROTECTED]> wrote:
>
> > I reckon your view should check what the language is set in the
> > request (request.LANGUAGE_CODE), and then pull out the right field
> > from the model.
>
> > On Jun 26, 11:22 pm, pihentagy <[EMAIL PROTECTED]> wrote:
> > > Hi!
>
> > > I have a 3-lingual app, and there are some model fields translated,
> > > like this:
>
> > > class Category(models.Model)
> > >         name_hu = models.CharField(_(u'név (magyar)'), max_length=255,)
> > >         name_en = models.CharField(_(u'név (angol)'), max_length=255)
> > >         name_de = models.CharField(_(u'név (német)'), max_length=255)
>
> > > In some caces __unicode__ method is used for representing data (like
> > > in the admin app, and many other places).
> > > Is there a way I can tell the model about the request's language? Or,
> > > well, I know it is a violation of MVC, but how to solve this problem?
>
> > > thanks
> > > Gergo
>
> --
> +-[ Gergely Kontra <[EMAIL PROTECTED]> ]--+
> |                                                           |
> | Mobile:(+36 20)356 9656                                   |
> |                                                           |
> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django newcomer needs help on concept of views

2008-06-27 Thread Horst Gutmann

And if you have some functions that are used by views from both
modules, just create a new module and name it for instance utils.py.
Then you can simply import something from this new module into your
views.py::

from .utils import my_function

-- Horst

On Fri, Jun 27, 2008 at 11:17 AM, Alaa Salman <[EMAIL PROTECTED]> wrote:
> On Jun 27, 10:47 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
>> Anyway, I am used to having separate files to facilitate different
>> controllers (I think it's called views in django).  On the other hand,
>> django uses one views.py for one application.  Is there anyway I can
>> have a views/parts.py or parts_views.py that interacts with part
>> model, or something like that? Because  currently, I have about 60
>> functions in my PHP's controllers that I want to port to django.  So,
>> that will mean 60 functions in views.py right? Is this the right way
>> to do it?  Or can I separate those functions into multiple views?
>
> You don't need to have them all in one file. I use two for example,
> one called views.py and the other called admin_views.py. So one is for
> the publicly accessible views, and the other is for the admin
> application customization views. You can have as many as you want, and
> in the structure that you find more comfortable. You simply call them
> differently in your urls conf file.
>
> Also, you can have a separate directory for your views and so
> on...just remember the python module part. Go over the documentation
> for views again, i believe this is covered well.
> >
>

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



Re: Django newcomer needs help on concept of views

2008-06-27 Thread Daniel Roseman

On Jun 27, 8:47 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I just started learning about python and django. For the past months I
> was working on a project using a PHP framework (I guess, the name
> would not be important right now :).  For my initial experiment, I
> would like to port my last project that I used with PHP to django.
> The project contains 10 tables, and most of them have relationships
> between one another.  So, I think this is considered as one
> application.
>
> Anyway, I am used to having separate files to facilitate different
> controllers (I think it's called views in django).  On the other hand,
> django uses one views.py for one application.  Is there anyway I can
> have a views/parts.py or parts_views.py that interacts with part
> model, or something like that? Because  currently, I have about 60
> functions in my PHP's controllers that I want to port to django.  So,
> that will mean 60 functions in views.py right? Is this the right way
> to do it?  Or can I separate those functions into multiple views?
>
> Thanks for your help :)
> Reza Muhammad

Views are just Python functions. You can have any number of views, and
they can live in any number of separate files. You just need to
reference them properly in the urls.py file, to map a URL to the
specific view and the module it is in. The default views.py that is
created by the create_app command is just a template - in fact you can
do anything you like.

I'm not sure from your question whether you mean 60 separate views, or
whether some of the 60 functions you mention are utility functions.
Either way, you can separate them out in any way you find logical. If
they are utility functions, you can just import them at the top of
your main views.py file. If they are actual views, you can just refer
to them from urls.py.

For example, your urls.py might look like this:
...
urlpatterns = patterns('',
(r'^articles/$', 'views.index'),
(r'^articles/(\d{4})/$', 'views.year_archive'),
...
(r'^special/$', 'special_views.index'),
)

etc., where there are two files containing views - views.py and
special_views.py.

Hope this helps.

--
DR.


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



Re: Django newcomer needs help on concept of views

2008-06-27 Thread Alaa Salman


On Jun 27, 10:47 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> Anyway, I am used to having separate files to facilitate different
> controllers (I think it's called views in django).  On the other hand,
> django uses one views.py for one application.  Is there anyway I can
> have a views/parts.py or parts_views.py that interacts with part
> model, or something like that? Because  currently, I have about 60
> functions in my PHP's controllers that I want to port to django.  So,
> that will mean 60 functions in views.py right? Is this the right way
> to do it?  Or can I separate those functions into multiple views?

You don't need to have them all in one file. I use two for example,
one called views.py and the other called admin_views.py. So one is for
the publicly accessible views, and the other is for the admin
application customization views. You can have as many as you want, and
in the structure that you find more comfortable. You simply call them
differently in your urls conf file.

Also, you can have a separate directory for your views and so
on...just remember the python module part. Go over the documentation
for views again, i believe this is covered well.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Stability of trunk and 1.0 target: experience, testimonials?

2008-06-27 Thread chris vigelius

Am Donnerstag, 26. Juni 2008 18:30:12 schrieb J Meier:
> Hi folks,
>
> I'm trying to champion Django trunk/1.0 as part of a small project in
> a mid-sized city newspaper office. There is some worry about choosing
> a framework which does not currently have a stable release. I've been
> addressing these worries with examples of the stability of trunk and
> the excellent planning and engineering of the project in general.
> Never the less, it would be valuable to me to have testimonials from
> others using or targeting trunk/1.0 in their applications, especially
> from traditional businesses. I think such testimonials could also help
> others get steam behind the 1.0 effort in organizations which are wary
> of support and stability.
>
> So I'd like to request that, if you have time and inclination, such
> users would post or email testimonials explaining your use of Django,
> experience with it's stability over time, confidence in the core
> developers, and (and here's where the higher-ups are interested) the
> size and nature of your project and company.

We are currently running trunk on two production sites, the larger one getting 
about 10k hits/day (ef-magazin.de, a small newspaper in German). Never ran 
into real problems because of being on trunk, however we do have a proper 
development/test/production landscape in place, and ensure every update gets 
sufficient testing before going into production. As others have pointed out, 
API changes are documented quite well, so it is really not difficult to 
upgrade and find out what went wrong (if any, it rarely happens).

However it must be noted that since the merge of queryset-refactor, some 
things in admin do not work as expected:

 - multi-table model inheritance in admin is broken (Ticket #7349)
 - inline editing of user profiles is broken (Ticket #7370)

It is very likely these bugs won't get fixed in oldforms-admin. But OTOH, if 
you are planning to use admin extensively you'll probably want to go with 
newforms-admin branch anyway.

IMO, to maintain a stable and reliable system, it is not really important that 
the software used has a certain version number, but that there is a test plan 
and a proper test infrastructure in place, and that these tests are actually 
conducted each time before releasing changes into the wild. Whether to use 
unit testing or doctests or simple manual testing is a matter of taste, I 
personally found that often it is much faster just having a Word document 
outlining the necessary test steps, and have a good tester (which doesn't 
need to be a technical person; in fact I prefer asking end users whether they 
want to help with that, which also helps understanding their needs and usage 
patterns better) execute them.

The test system should be as similar as possible to the production system, at 
least it should have the same OS and DB as a production server, and should be 
refreshed regularly from the production DB. Make sure you have a defined and 
automated rollout procedure in place, as that lowers the chance that the 
develop->test->release cycle gets circumvented because "we have no time for 
that" and/or "it's just a small fix, so I can do it on the production machine 
directly". And, as a last tip: try to use the same db type throughout 
development, test and production, read: avoid sqlite like hell, except if you 
are using it in production too. The comfort of a local sqlite db comes for 
the price of getting all these nasty unique key constraint etc. problems in 
test, which you simply do not see in development (as sqlite doesn't support 
them).

regards,
 chris

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



Re: i18n model - tri-lingual data

2008-06-27 Thread KONTRA, Gergely

Correct me, but I don't think I can access the view from the model.
So how is this possible?

On Fri, Jun 27, 2008 at 2:06 AM, Julien <[EMAIL PROTECTED]> wrote:
>
> I reckon your view should check what the language is set in the
> request (request.LANGUAGE_CODE), and then pull out the right field
> from the model.
>
> On Jun 26, 11:22 pm, pihentagy <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > I have a 3-lingual app, and there are some model fields translated,
> > like this:
> >
> > class Category(models.Model)
> > name_hu = models.CharField(_(u'név (magyar)'), max_length=255,)
> > name_en = models.CharField(_(u'név (angol)'), max_length=255)
> > name_de = models.CharField(_(u'név (német)'), max_length=255)
> >
> > In some caces __unicode__ method is used for representing data (like
> > in the admin app, and many other places).
> > Is there a way I can tell the model about the request's language? Or,
> > well, I know it is a violation of MVC, but how to solve this problem?
> >
> > thanks
> > Gergo
> >



--
+-[ Gergely Kontra <[EMAIL PROTECTED]> ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+

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



Re: manage.py dumpdata and swap

2008-06-27 Thread Russell Keith-Magee

On Fri, Jun 27, 2008 at 10:57 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello
>
> I have a small server, just 5 users and I use the django for data
> entry. My server have only 512MB of RAM but it is enough and it work
> really well. But whenever I run "manage.py dumpdata xml" --format=xml"
> for backup purposes it uses all my RAM and start filling the swap
> space on my server. Is it some kind of memory leak in that routine?
> And it is really the dumpdata data that fills the memory, I've run my
> server for more than 3 month without using the swap space and the
> first time I execute manage.py dumpdata it fill up the RAM

This has been reported previously; as best as I can work out, the
issue is that the dumped output is stored entirely in memory before
being written to disk. For small databases, this isn't an issue, but
the larger your dataset, the bigger the problem.

The issue has been finding a reliable test case. There is a patch
attached to #5423:

http://code.djangoproject.com/ticket/5423

If you can verify that this helps (or doesn't), it would be most helpful.

Yours
Russ Magee %-)

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



Re: Collecting referrers data

2008-06-27 Thread Arien

On Fri, Jun 27, 2008 at 3:45 AM, Alessandro <[EMAIL PROTECTED]> wrote:
> So, it's possible to make a shortcut before my urls and generic views
> to record referrers data?

You could write some middleware to do just that.


Arien

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



Collecting referrers data

2008-06-27 Thread Alessandro
I want to collect referrers data on my django website. Now I have
google analytics code, but I want to make a visible list of my 10 best
referrers (to give them a prize) on my pages.

So, it's possible to make a shortcut before my urls and generic views
to record referrers data?

Or it's possible to put Google analytics data in pages without cut&
paste manually?

Thanks in advance, best regards.
-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Re: Polls app not showing in Admin > Django Tutorial

2008-06-27 Thread Moodie

Thanks Julien!

I'm new to Python, so the indentation is throwing me a bit, but that
sorted out the problem.

Thanks again!


On Jun 27, 5:16 pm, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> In the example you give I see some identeation problems. It should
> rather be:
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def __unicode__(self):
>         return self.question
>     def was_published_today(self):
>         return self.pub_date.date() == datetime.date.today()
>     class Admin:
>         pass
>
> 'class Admin' should be at the same indentation level as your class
> attribute, e.g. 'question' or 'pub_date'.
>
> On Jun 27, 4:54 pm, Moodie <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I've been going over this, but for some reason the Polls app is not
> > showing up in the admin after adding 'class Admin: pass' to the poll
> > model. I've searched through this user group, and have tried all the
> > things suggested, but am still not having much luck. My models.py page
> > looks like this:
>
> > from django.db import models
> > import datetime
>
> > class Poll(models.Model):
> >     question = models.CharField(max_length=200)
> >     pub_date = models.DateTimeField('date published')
> >     def __unicode__(self):
> >         return self.question
> >         def was_published_today(self):
> >             return self.pub_date.date() == datetime.date.today()
> >             class Admin:
> >                 pass
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(max_length=200)
> >     votes = models.IntegerField()
> >     def __unicode__(self):
> >         return self.choice
>
> > Any help would be great.
> > (ps running the latest trunk)

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



Django newcomer needs help on concept of views

2008-06-27 Thread Reza Muhammad

Hi guys,

I just started learning about python and django. For the past months I
was working on a project using a PHP framework (I guess, the name
would not be important right now :).  For my initial experiment, I
would like to port my last project that I used with PHP to django.
The project contains 10 tables, and most of them have relationships
between one another.  So, I think this is considered as one
application.

Anyway, I am used to having separate files to facilitate different
controllers (I think it's called views in django).  On the other hand,
django uses one views.py for one application.  Is there anyway I can
have a views/parts.py or parts_views.py that interacts with part
model, or something like that? Because  currently, I have about 60
functions in my PHP's controllers that I want to port to django.  So,
that will mean 60 functions in views.py right? Is this the right way
to do it?  Or can I separate those functions into multiple views?

Thanks for your help :)
Reza Muhammad

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



Re: Polls app not showing in Admin > Django Tutorial

2008-06-27 Thread Moodie

Thanks Julien!

I'm new to python, so the indentation is throwing me a little, but
that fixed the issue.

Thanks again!

On Jun 27, 5:16 pm, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> In the example you give I see some identeation problems. It should
> rather be:
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def __unicode__(self):
>         return self.question
>     def was_published_today(self):
>         return self.pub_date.date() == datetime.date.today()
>     class Admin:
>         pass
>
> 'class Admin' should be at the same indentation level as your class
> attribute, e.g. 'question' or 'pub_date'.
>
> On Jun 27, 4:54 pm, Moodie <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I've been going over this, but for some reason the Polls app is not
> > showing up in the admin after adding 'class Admin: pass' to the poll
> > model. I've searched through this user group, and have tried all the
> > things suggested, but am still not having much luck. My models.py page
> > looks like this:
>
> > from django.db import models
> > import datetime
>
> > class Poll(models.Model):
> >     question = models.CharField(max_length=200)
> >     pub_date = models.DateTimeField('date published')
> >     def __unicode__(self):
> >         return self.question
> >         def was_published_today(self):
> >             return self.pub_date.date() == datetime.date.today()
> >             class Admin:
> >                 pass
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(max_length=200)
> >     votes = models.IntegerField()
> >     def __unicode__(self):
> >         return self.choice
>
> > Any help would be great.
> > (ps running the latest trunk)

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



Strange display of date

2008-06-27 Thread gumbah

Hi all,

does anyone know what i am doing wrong when i see a date looking like
this in the "change history" part of the admin app:

FriAMCDTE_261CDT02_CDT1JunE_June1218655750TrueTrue

I see this throughout the admin app (change history of users, of
groups etc.)

BTW: Just getting into Django and loving it!!

Kind regards,
J


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



Re: list_filter with select

2008-06-27 Thread Julien

Hi,

To do that you need to override the admin/filter.html template. Have a
look at the one that's already provided in the admin and you should be
able to write some HTML code that suits you better.

Julien

On Jun 27, 6:20 pm, OliverMarchand <[EMAIL PROTECTED]> wrote:
> Hello,
>
> When a field that is contained in the admin list_filter has a lot of
> different
> values, the list may become too long to be used.
> Has anyone ever written a modification of the admin change_list.html
> to
> enable dropdown select widgets for the filter values instead of all
> values
> written out?
>
> thanks for any hint!
>    Oliver
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems retrieving array from POST

2008-06-27 Thread Daniel Roseman

On Jun 26, 11:36 pm, elspiko <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've fairly new to django but i'm loving it!
>
> I've got some draggable panels on a site and want to save their
> positions so when a user logs back in, the panels are in the same
> place when they last hit the save button. What I'm doing is (using
> jQuery) retrieving the id's of the panels, putting them into an array,
> and using ajax to pass the array to the server:
>
>             var data = []
>             $('#left > div').each(function() {
>                 data.push($(this).attr('id'));
>             });
>             var Left = 'Left';
>             for(x in data)
>             {
>                 Left += data[x] + " in pos " + x + "";
>             }
>             Left += "";
>             $('#var_test').html(Left);
>
>             $.post("/post_test/",{'data[]': data });
>
> Using firebug, I can see that the data is being posted correctly.
>
> Below is the view (abridged):
>
> def post_handler(request):
>     post_text = request.POST.getlist('data')
>     user = User.objects.get(id=2) # for debugging purposes
>     for x in range( len(post_text)-1 ):
>         name = post_text[x]
>         panel =
> user.panels_set.get(name__istartswith=name,side="left")
>         panel.order = x
>         panel.save()
>
> The problem is its not saving to the database, I'm assuming it to do
> with the way I'm accessing the POST data, but I can't work it out.
> I've tried post_text = request.POST['data'], but that didn't work
> either,
>
> I really am at a loose end with this...please help!!

You are POSTing the data with the dictionary key 'data[]'. But your
view is expecting the value 'data'.
Your jQuery post line should just be :
$.post("/post_test/",{'data': data });

I suspect this is a habit picked up from PHP, but you don't need it
here.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



list_filter with select

2008-06-27 Thread OliverMarchand

Hello,

When a field that is contained in the admin list_filter has a lot of
different
values, the list may become too long to be used.
Has anyone ever written a modification of the admin change_list.html
to
enable dropdown select widgets for the filter values instead of all
values
written out?

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



Re: psycopg2

2008-06-27 Thread James Bennett

On Fri, Jun 27, 2008 at 3:06 AM, Will <[EMAIL PROTECTED]> wrote:
> Would I have to write an entire new backend for postgres, just to use
> a different driver?

You'd need a module that implements the interface of a Django database
adapter while using another driver. A few months ago I saw an article
by someone who'd been working on a module to use pygresql -- another
Python module that can talk to Postgres -- in place of psycopg and who
apparently got it partially working before going back to psycopg:

http://www.dougblog.com/articles/2008/apr/16/exploring-a-pygresql-backend/

If you're adamantly against using psycopg (I'm not an expert on the
comparison, but most Python folks seem to prefer psycopg for its
flexibility in allowing customized mappings between Python data types
and Postgres data types), you might get in touch with him and see if
he still has/is willing to share the code as a starting point for an
alternative adapter.


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

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



Re: psycopg2

2008-06-27 Thread Will


On Jun 26, 11:38 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:

> Erm... the database backends _are_ pluggable. Hence, the
> DATABASE_ENGINE setting.
>

I undersand that, but I'm stuck with psycopg or psycopg2 if I'm to use
postgres, aren't I?

Would I have to write an entire new backend for postgres, just to use
a different driver?

Cheers

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



Re: Polls app not showing in Admin > Django Tutorial

2008-06-27 Thread Julien

Hi,

In the example you give I see some identeation problems. It should
rather be:

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
class Admin:
pass

'class Admin' should be at the same indentation level as your class
attribute, e.g. 'question' or 'pub_date'.

On Jun 27, 4:54 pm, Moodie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been going over this, but for some reason the Polls app is not
> showing up in the admin after adding 'class Admin: pass' to the poll
> model. I've searched through this user group, and have tried all the
> things suggested, but am still not having much luck. My models.py page
> looks like this:
>
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def __unicode__(self):
>         return self.question
>         def was_published_today(self):
>             return self.pub_date.date() == datetime.date.today()
>             class Admin:
>                 pass
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>     def __unicode__(self):
>         return self.choice
>
> Any help would be great.
> (ps running the latest trunk)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---