Re: Cooki Problem

2007-02-13 Thread samira

Thanks Dear ScottB, I reviewed that link you mentioned. As I know now,
we can have two ways to store data in cookie: Session for permanent
and cookie for temporary. Am I right? I used "response.setcookie" but
my problem not solve yet :( can you tell me how create httpResponse
object? Maybe I create it in wrong way. Thanks a lot

On Feb 12, 5:08 pm, "ScottB" <[EMAIL PROTECTED]> wrote:
> On Feb 12, 8:06 am, "samira" <[EMAIL PROTECTED]> wrote:
>
> > I want to have two
> > kind ofcookie: permanent and temporary. Temporarycookieshould be
> > deleted when browser close. I don't want to use
> > "SESSION_EXPIRE_AT_BROWSER_CLOSE" because that will delete all part of
> > cookies but I want to temporary part to delete. Can you know how I
> > shall do that?
>
> You could leave the main sessioncookieso it doesn't get deleted, but
> add your own temporarycookieto the HttpResponse object returned by
> one of your views.  Just call set_cookie on the HttpResponse object;
> if you don't specify an age, thecookieyou set will expire when the
> browser window is closed.  You can read thecookieback in your views
> using request.cookies.
>
> http://www.djangoproject.com/documentation/request_response/
>
> Scott


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



Re: Dreamhost Statistics + Django

2007-02-13 Thread chasfs

Eugene,

Thanks for the quick reply!  That solved the problem.

Is this a great group or what?

Thanks,
-chasfs

On Feb 14, 12:05 am, Eugene Lazutkin <[EMAIL PROTECTED]>
wrote:
> No need to do it in Dkango --- you should add more rewrite rules in
> .htaccess (seehttp://wiki.dreamhost.com/index.php/Djangofor details):
>
> RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
> RewriteCond %{REQUEST_URI} ^/failed_auth.html$
> RewriteRule ^.*$ - [L]
>
> It will take care of /stats URL. If you use some additional stat package
> like Advanced Web Statistics, you can add it too (assuming it is
> installed in /aw66):
>
> RewriteRule ^(aw66/[a-zA-Z\-]+/.*)$ - [L]
>
> Thanks,
>
> Eugene
>
> chasfs wrote:
> > I've brought up Django on my Dreamhost account to run a survey
> > application (http://surveys.zdecisions.com).  The problem is that
> > Dreamhost has a statistics package that shows up in domain/stats,
> > (e.g. surveys.zdecisions.com/stats) but Django gets all of the urls
> > and doesn't know what to do with stats. Has anyone run into this?  Is
> > there anyway to configure Django to redirect a url to an off-Django
> > url from the urls.py file?  Or do I need to create a view to do this?
> > Thanks!
> > -chasfs


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

2007-02-13 Thread Eugene Lazutkin

No need to do it in Dkango --- you should add more rewrite rules in
.htaccess (see http://wiki.dreamhost.com/index.php/Django for details):

RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]

It will take care of /stats URL. If you use some additional stat package
like Advanced Web Statistics, you can add it too (assuming it is
installed in /aw66):

RewriteRule ^(aw66/[a-zA-Z\-]+/.*)$ - [L]

Thanks,

Eugene

chasfs wrote:
> I've brought up Django on my Dreamhost account to run a survey
> application (http://surveys.zdecisions.com).  The problem is that
> Dreamhost has a statistics package that shows up in domain/stats,
> (e.g. surveys.zdecisions.com/stats) but Django gets all of the urls
> and doesn't know what to do with stats. Has anyone run into this?  Is
> there anyway to configure Django to redirect a url to an off-Django
> url from the urls.py file?  Or do I need to create a view to do this?
> Thanks!
> -chasfs
> 
> 
> > 
> 


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



Dreamhost Statistics + Django

2007-02-13 Thread chasfs

I've brought up Django on my Dreamhost account to run a survey
application (http://surveys.zdecisions.com).  The problem is that
Dreamhost has a statistics package that shows up in domain/stats,
(e.g. surveys.zdecisions.com/stats) but Django gets all of the urls
and doesn't know what to do with stats. Has anyone run into this?  Is
there anyway to configure Django to redirect a url to an off-Django
url from the urls.py file?  Or do I need to create a view to do this?
Thanks!
-chasfs


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

2007-02-13 Thread mulc

This is what SCGI reports ( apache 2.2.4, mod_scgi 1.12, with the
default main() invocation of scgi/scgi_server.py  ).

In this implementation at least, REQUEST_URI does not include the
proctal or hostname.
Essentially:

REQUEST_URI == SCRIPT_NAME + PATH_INFO + QUERY_STRING

HTTP_REFERER: 'http://www.example.com/SCGI/admin/auth/user/?
is_staff__exact=0_superuser__exact=1'
SERVER_SOFTWARE: 'Apache'
SCRIPT_NAME: '/SCGI'
HTTP_IF_MODIFIED_SINCE: 'Tue, 13 Feb 2007 21:09:34 GMT'
REQUEST_METHOD: 'GET'
PATH_INFO: '/admin/auth/user/'
SERVER_PROTOCOL: 'HTTP/1.1'
QUERY_STRING: 'is_staff__exact=0_superuser__exact=0'
CONTENT_LENGTH: '0'
HTTP_ACCEPT_CHARSET: 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_USER_AGENT: 'Mozilla/5.0 (X11; U; OpenBSD i386; en-US; rv:
1.8.0.8) Gecko/20061110 Firefox/1.5.0.8'
HTTP_CONNECTION: 'keep-alive'
HTTP_COOKIE: 'sessionid=1716ddd961911ebc116289e96ee5154c'
SERVER_NAME: 'www.example.com'
REMOTE_ADDR: '24.91.6.59'
HTTP_IF_NONE_MATCH: '3a3005e07c1e77d8a32e489df7fb5b71'
SERVER_PORT: '80'
SERVER_ADDR: '63.67.205.253'
DOCUMENT_ROOT: '/web/root'
SERVER_ADMIN: 'admin.example.com'
HTTP_HOST: 'www.example.com'
HTTP_CACHE_CONTROL: 'max-age=0'
REQUEST_URI: '/SCGI/admin/auth/user/?
is_staff__exact=0_superuser__exact=0'
HTTP_ACCEPT: 'text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
REMOTE_PORT: '54317'
HTTP_ACCEPT_LANGUAGE: 'en-us,en;q=0.5'
SCGI: '1'
HTTP_ACCEPT_ENCODING: 'gzip,deflate'
UNIQUE_ID: 'HB8AWz9Dzf0AABBGAX0D'
HTTP_KEEP_ALIVE: '300'


On Feb 13, 7:24 pm, "Waylan Limberg" <[EMAIL PROTECTED]> wrote:
> On Tue, 13 Feb 2007 17:41:16 -0500, mulc <[EMAIL PROTECTED]> wrote:
>
> > OK.
>
> > I hacked django/core/handlers/wsgi.py. ( line #56 )
>
> > In the __init__ function of  WSGIRequest I changed:
>
> >   self.path = environ['PATH_INFO']
>
> >   to
>
> >   self.path = environ['REQUEST_URI']
>
> >   I then changed up my urls.py
>
> >  (r'^admin/', include('django.contrib.admin.urls')),
>
> > becomes
>
> >  (r'/admin/?', include('django.contrib.admin.urls')),
>
> > This appears to do what I want.
>
> > No obvious breakage yet, but I haven't really done anything other than
> > tool through the admin interface at /SCGI/admin
>
> Well, that would also match the following urls (which you wouldn't want):
>
> /foo/admin/
> /foo/bar/admin/
> /foo/admin/bar/
>
> Sure, it's not likely that you'll have 'admin' in a lot of urls, but I
> think that illustrates the problem. You need to be able to match from the
> front of the url. If I recall correctly, 'REQUEST_URI' includes the
> proctal and domain and I wouldn't want to include that in every regex
> expression.
>
> --
> Waylan Limberg
> [EMAIL PROTECTED]


You are right.  The regex I posted is, overly broad, but that is not a
show-stopper I do not think.

My goal is not to have to modify any part of django, other than the
WSGI handler.   My concern is that modifying the path attribute of the
WSGIRequest object ( so as  to facilitate classic quixote-style scgi
usage:  setting path = SCRIPT_NAME+PATH_INFO, instead of PATH_INFO  )
that I am borking something in the WSGI domain that will break the
nesting of WSGI Apps.

I will need to get all of WSGI into my head before I am sure I am not
screwing something up.   I very much want to be able to mount multiple
WSGI apps under various points of an existing "filesystem."


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

2007-02-13 Thread kbochert



On Feb 13, 7:41 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 2/13/07, kbochert <[EMAIL PROTECTED]> wrote:
> ...> > If you -must- serve media with django, use the static media server
> > > that's built-in.  But you're really better off not doing that.
> ...
> > Will that handle media correctly when in production with DEBUG off?
>
> Looks like it,
>
> > Why am I better off not doing this?
>
> You're using a hammer to swat flies. :)
>
> http://www.djangoproject.com/documentation/static_file

As long as I'm not generating a site which will be impossible to
deploy ;-)

My intention in this is to use a WYSIWYG editor to generate my
templates.
The editor generates pretty pages to which I add Django markup. The
editor can later easily change the entire theme of my site. Not  well
structured and very ugly html, but just the thing for a part-time
amateur like me. Seems to work beautifully.

Thanks for your help.


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



Re: SCGIMount != '/'

2007-02-13 Thread mulc


This borks query-string handling.  ['REQUEST_URI'] includes the query
string.

instead:

self.path = environ['SCRIPT_NAME'] + environ['PATH_INFO']


On Feb 13, 5:41 pm, "mulc" <[EMAIL PROTECTED]> wrote:
> OK.
>
> I hacked django/core/handlers/wsgi.py. ( line #56 )
>
> In the __init__ function of  WSGIRequest I changed:
>
>   self.path = environ['PATH_INFO']
>
>   to
>
>   self.path = environ['REQUEST_URI']
>
>   I then changed up my urls.py
>
>  (r'^admin/', include('django.contrib.admin.urls')),
>
> becomes
>
>  (r'/admin/?', include('django.contrib.admin.urls')),
>
> This appears to do what I want.
>
> No obvious breakage yet, but I haven't really done anything other than
> tool through the admin interface at /SCGI/admin


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



Selecting MySQL engine (InnoDB/MyISAM) when creating models

2007-02-13 Thread yary

There's a thread from June 28 '06 on this list about changing MySQL's
storage engine from InnoDB to MyISAM for a particular table/model.

Now, an InnoDB table respects foreign keys, and a MyISAM table ignores
them. An "ALTER TABLE ... ENGINE = MyISAM" statement will fail if the
table has any foreign keys defined.

On the other hand, a "CREATE TABLE ... ENGINE = MyISAM" statement with
foriegn key definitions works, silently ignoring the foreign keys.
Subsequent "ALTER TABLE ... ADD CONSTRSAINT ... FOREIGN KEY..." are
also silently ignored.

So it seems here's a case where some extension to let the django app
writer modify the "CREATE" sql would be very handy. I don't suppose
anyone has a patch ready for it?http://code.djangoproject.com/ticket/
347 implies such a thing would be frowned upon, but I'd rather have an
unsupported patch then have to abandon "manage.py test" due to SQL
errors... if not, I believe the shortest path would be a
"pre_db_table" signal, which I should be able to whip up quickly.

I suppose one could drop the foreign key constraints before altering
the table, but it looks like they're named with some random characters
in it. So one would have to look at the metadata, get the FK
constraint name, and use that in generating the SQL: ugly, and more a
job for Python, not the SQL that gets run by syncdb...

What to do... (and I can't set the default storage type, since the
app's deployed to a remote host, where we don't have access to the
MySQL setup)


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

2007-02-13 Thread Jeremy Dunck

On 2/13/07, kbochert <[EMAIL PROTECTED]> wrote:
...
> > If you -must- serve media with django, use the static media server
> > that's built-in.  But you're really better off not doing that.
...
> Will that handle media correctly when in production with DEBUG off?
Looks like it,

> Why am I better off not doing this?
You're using a hammer to swat flies. :)

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sending an extra query to a generic view, what is the django way?

2007-02-13 Thread hotani

Thanks, that example for extending the generic view is what I was
looking for; I'll try it out tomorrow.

As for request.user not being available, that was when I was trying to
use it in urls.py. I have never had a problem accessing it from views.


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

2007-02-13 Thread kbochert



On Feb 13, 5:52 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:

>
> Ah!  I was stumped before.  Not now.
>
> render_to_response expects a template and, I'm sure, opens the file as
> text.  You're giving it a binary.  Don't do that.  It'll be served as
> html mime type and line endings will get munged.
>
> If you -must- serve media with django, use the static media server
> that's built-in.  But you're really better off not doing that.

  ! Hey it works !

So my urls.py looks something like---

from django.conf.urls.defaults import *
from django.conf import settings

urlpatterns = patterns('',
)

if settings.DEBUG:
urlpatterns += patterns('',
# Anything from nav subdirectory is media
(r'^polls/nav/(?P.+)$', 'django.views.static.serve',
{'document_root': 'templates/polls/nav'}),
)

urlpatterns += patterns('',
#
#Anything from polls not already caught is served by default view
(r'^polls/(?P.+)$', 'Mysite.polls.views.default'),
)

Will that handle media correctly when in production with DEBUG off?
Why am I better off not doing this?


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



Re: GIF won't render properly

2007-02-13 Thread Jeremy Dunck

On 2/13/07, kbochert <[EMAIL PROTECTED]> wrote:
...
> def static(request, name):
> return render_to_response('polls/%s' % name ,{})

Ah!  I was stumped before.  Not now.

render_to_response expects a template and, I'm sure, opens the file as
text.  You're giving it a binary.  Don't do that.  It'll be served as
html mime type and line endings will get munged.

If you -must- serve media with django, use the static media server
that's built-in.  But you're really better off not doing that.

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



GIF won't render properly

2007-02-13 Thread kbochert


-urls.py:
from django.conf.urls.defaults import *

urlpatterns = patterns('',

(r'^polls/(?P.+)$', 'Mysite.polls.views.static'),
# (r'^polls/(?Pnews\.html)$', 'Mysite.polls.views.static'),
)


--views.py:
# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404

def static(request, name):
return render_to_response('polls/%s' % name ,{})



---news.html:


Then http://127.0.0.1:8000/polls/news.html  produces a screen with the
top half of the .gif file in low resolution (big fuzzy dots)
Displaying news.html in either FF or IE displays a full image in full
resolution.

runserver shows:
"GET /polls/news.html HTTP/1.1" 200 105
"GET /polls/nav/nav_1_news_bhb.gif HTTP/1.1" 200 1196

Please -- what am I 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: SCGIMount != '/'

2007-02-13 Thread Waylan Limberg

On Tue, 13 Feb 2007 17:41:16 -0500, mulc <[EMAIL PROTECTED]> wrote:

>
>
> OK.
>
> I hacked django/core/handlers/wsgi.py. ( line #56 )
>
> In the __init__ function of  WSGIRequest I changed:
>
>   self.path = environ['PATH_INFO']
>
>   to
>
>   self.path = environ['REQUEST_URI']
>
>   I then changed up my urls.py
>
>  (r'^admin/', include('django.contrib.admin.urls')),
>
> becomes
>
>  (r'/admin/?', include('django.contrib.admin.urls')),
>
> This appears to do what I want.
>
> No obvious breakage yet, but I haven't really done anything other than
> tool through the admin interface at /SCGI/admin
>
Well, that would also match the following urls (which you wouldn't want):

/foo/admin/
/foo/bar/admin/
/foo/admin/bar/

Sure, it's not likely that you'll have 'admin' in a lot of urls, but I  
think that illustrates the problem. You need to be able to match from the  
front of the url. If I recall correctly, 'REQUEST_URI' includes the  
proctal and domain and I wouldn't want to include that in every regex  
expression.



-- 
Waylan Limberg
[EMAIL PROTECTED]

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



Listing users

2007-02-13 Thread [EMAIL PROTECTED]

Hi,

I have a site with users and an additional user_profile to store extra
information like a signature, avatar, etc.

I cannot figure out how to use a single query to get a list of users
and at the same time join in their user_profile information.

Currently I have this:

users = User.objects.all().order_by('id')[offset:limit]

But I can't figure out how to get their profiles joined to that query.
Any ideas?

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: Django Cheat Sheet

2007-02-13 Thread Honza Král
On 2/13/07, Matt <[EMAIL PROTECTED]> wrote:
>
> Cheers for all the feedback guys.

Well, cheers to you in the first place... ;)

Here's a reply to your questions so
> far.
>
> As Malcolm Tredinnick pointed out in a private reply (and James Bennet
> here), Django doesn't mind whether you pass it a tuple or a lists; one
> can be substituted for the other.  I think I'll remove this
> distinction in the next issue.
>
> For reasons of space I left out details on foreign keys, many-to-many
> relationships and, because they're undergoing change, one-to-one
> relationships.  They seem to be popular enough that I'll look at
> adding a second page to include them.

there still is some confusion (judging by the questions in
django-users) about related models lookup, so the combination of
related fields (FK, M2M and 1to1) and db_api should be very useful...

>
> I was a little naughty and included some functionality only available
> in the development version.  I followed the docs in this respect, but
> I guess for consistency I should remove this.
>
> I want to try and keep it up-to-date: when 0.96 is released I'll find
> time to issue a new version with changes from the newforms-admin
> branch et al.

great news

> Rob Hudson's right: list_per_page should be an integer, not a list.  I
> knew I'd miss something!  I'll change that in the morning.
>
> Does anyone have any requests for what to include on a second page?
> (The biggest internal request has been for an example of the fields
> options in the Admin inner class - something we're forever looking
> up.)

perhaps a list of db_api functions and field lookups? also a list of
form fields and widgets would be useful, if you want to stick with
stable features, what about generic views - including their context
and parameters.

> A loud 'Thank you!' should go to the designer, Ed, for managing to
> make all that text look presentable.  Cheers, Ed.

Thanks Ed ;)

>
> M.
>
> --
> Matt Riggott.
> Dictated but not read.
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sending an extra query to a generic view, what is the django way?

2007-02-13 Thread [EMAIL PROTECTED]

As far as I know, request.user should already be available in your
generic view. [1] is the documentation for that particular feature.
It should be available as 'user' in all templates that use
RequestContext, which by default all generic views do.

[1] http://www.djangoproject.com/documentation/authentication/
#authentication-data-in-templates

-Eric

On Feb 13, 4:58 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-02-13 at 22:19 +, hotani wrote:
>
> [...]
>
> > Is there a nice way to extend the generic view to fit this in? I
> > thought about making my own view that would act as a wrapper for the
> > generic view but was unable to make it work. If it were a standard
> > view, this would be simple--but as a generic view it is so black-boxed
> > I don't know where to start.
>
> Generic views are no more "black box" than any other view. You can just
> open up django/views/generic/*.py and look at what they are doing.
>
> For an example of how to extend a generic view with your own wrapper,
> have a look at [1]. In fact, the example in that fragment uses
> request.user to illustrate the point.
>
> [1]http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-gen...
>
> 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
-~--~~~~--~~--~--~---



Model instance identity

2007-02-13 Thread David Abrahams


I just wrote some code that used Model instances as keys in a dict,
and was surprised to find two instances in the dict that represented
the same object in the database.  Shouldn't that be impossible?  If
you can't guarantee that a given object in the database is always
represented by the same Python instance, shouldn't django.db.Model
have __hash__ and  __eq__ methods that makes equivalent instances hash
the same?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


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



Re: sending an extra query to a generic view, what is the django way?

2007-02-13 Thread Malcolm Tredinnick

On Tue, 2007-02-13 at 22:19 +, hotani wrote:
[...]
> Is there a nice way to extend the generic view to fit this in? I
> thought about making my own view that would act as a wrapper for the
> generic view but was unable to make it work. If it were a standard
> view, this would be simple--but as a generic view it is so black-boxed
> I don't know where to start.

Generic views are no more "black box" than any other view. You can just
open up django/views/generic/*.py and look at what they are doing.

For an example of how to extend a generic view with your own wrapper,
have a look at [1]. In fact, the example in that fragment uses
request.user to illustrate the point.

[1]
http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/

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: stored procedures in initial SQL ?

2007-02-13 Thread Malcolm Tredinnick

On Tue, 2007-02-13 at 16:51 +0100, Bram - Smartelectronix wrote:
> Hi,
> 
> 
> with the preprocessing that's being done on 'initial' SQL before adding 
> it to the DB I'm getting into trouble with the stored procedures I would 
> like to add to the DB (for the model in question).
> 
> The backend specific SQL gets treated the same way.
> 
> I think it's impossible to change the regular expression to take care of 
> this special case.
> 
> Any ideas?

At the moment, the only workaround is to call out to your own shell
script (or other) to do the insert. If you have a look around line 506
of django/core/management.py, you can see where Django emits a
"post-syncdb" signal after setting up the database, so you can register
a handler for that before calling the setup routines and then do your
own stuff afterwards (include an os.system() or equivalent call). See
[1] for an example of how to use this signal -- although that link isn't
responding for me right now; hopefully it's just being temperamental.

[1]
http://www.bright-green.com/blog/2006_07_12/initialising_application_data_.html


In the medium-term, I'd like to fix the initial SQL handling, but it's
as trivial as it looks because of differing quoting requirements and the
fact that not all the database shells can be used without user input
(one easy to see case is trying to make a PostgreSQL database with a
password work via psql without requiring user interaction). It might be
fixed "properly" one day, or we may just have to document its
limitations. Trying to write the be-all-and-end-all of database shell
interfaces is probably not worth the effort and maintenance for us
unless it's really easy.

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: SCGIMount != '/'

2007-02-13 Thread mulc


OK.

I hacked django/core/handlers/wsgi.py. ( line #56 )

In the __init__ function of  WSGIRequest I changed:

  self.path = environ['PATH_INFO']

  to

  self.path = environ['REQUEST_URI']

  I then changed up my urls.py

 (r'^admin/', include('django.contrib.admin.urls')),

becomes

 (r'/admin/?', include('django.contrib.admin.urls')),

This appears to do what I want.

No obvious breakage yet, but I haven't really done anything other than
tool through the admin interface at /SCGI/admin


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



sending an extra query to a generic view, what is the django way?

2007-02-13 Thread hotani

I have a generic view for an object in a basic bug tracker app. It
shows things like 'title', 'description', 'resolution', etc.. and that
is all working fine with a generic view.

However, I'm trying to send a piece of info that involves a completely
different model and not finding a pleasant way to do it. I need to use
request.user, which does not seem to be available in urls.py, as well
as the object id of the original model.

I tried for a while to get extra_context to work, but kept running
into the request.user issue. Also, I'm not sure I'll have access to
the object id that early in the process--am I wrong here?

Is there a nice way to extend the generic view to fit this in? I
thought about making my own view that would act as a wrapper for the
generic view but was unable to make it work. If it were a standard
view, this would be simple--but as a generic view it is so black-boxed
I don't know where to start.


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

2007-02-13 Thread Adrian Holovaty

On 2/13/07, voltron <[EMAIL PROTECTED]> wrote:
> I think it would be cool to be able to read the Django book in PDF
> format, it´s much more comfortable to read on the train when one has
> no access to the net, and one avoids the Script execution errors that
> always crop up from the site.
>
> Do the authors have something of the sort somewhere?

Not yet, but stay tuned.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Preliminary or draft Django Book as PDF?

2007-02-13 Thread voltron

Hi all!

I think it would be cool to be able to read the Django book in PDF
format, it´s much more comfortable to read on the train when one has
no access to the net, and one avoids the Script execution errors that
always crop up from the site.

Do the authors have something of the sort somewhere?


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: Django Cheat Sheet

2007-02-13 Thread Matt

Cheers for all the feedback guys.  Here's a reply to your questions so
far.

As Malcolm Tredinnick pointed out in a private reply (and James Bennet
here), Django doesn't mind whether you pass it a tuple or a lists; one
can be substituted for the other.  I think I'll remove this
distinction in the next issue.

For reasons of space I left out details on foreign keys, many-to-many
relationships and, because they're undergoing change, one-to-one
relationships.  They seem to be popular enough that I'll look at
adding a second page to include them.

I was a little naughty and included some functionality only available
in the development version.  I followed the docs in this respect, but
I guess for consistency I should remove this.

I want to try and keep it up-to-date: when 0.96 is released I'll find
time to issue a new version with changes from the newforms-admin
branch et al.

Rob Hudson's right: list_per_page should be an integer, not a list.  I
knew I'd miss something!  I'll change that in the morning.

Does anyone have any requests for what to include on a second page?
(The biggest internal request has been for an example of the fields
options in the Admin inner class - something we're forever looking
up.)

A loud 'Thank you!' should go to the designer, Ed, for managing to
make all that text look presentable.  Cheers, Ed.

M.

--
Matt Riggott.
Dictated but not read.


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



Extending django.contrib.auth.views.login ?

2007-02-13 Thread whiteinge

I'm pretty new to Django, so any advice would really be appreciated,
especially if I'm headed in the wrong direction.

I'm trying to "extend" django.contrib.auth.views.login in the same
fashion as a generic view. I would like to deposit points in a user's
account after a sucessful login. Here's what I've got--inspired by the
Django Book, Generic Views chapter.

def user_login(request):
response django.contrib.auth.views.login(request)
if XXX: # FIXME: how do I check that this was successful?
do database stuff...
return response


On a semi-related note, I'd probably be able to muddle through this on
my own using the Python console, but I don't know how to fake the
'request' variable in that environment; is this easy to do?

Thanks very much,
- whiteinge


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

2007-02-13 Thread ian


>
> Hola, si te refieres a una lista de django en español, si la tenemos
> la formamos hace un tiempo atras, si deseas suscribirte esta en:
[portuguese]
Opa,
seja bem vindo!!
valeu,
[]'s
Ian
[english uk]
Crikey,
you are welcome
salute's
[]'s
Ian



F U cn rd dis U mst uz Linux.



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

2007-02-13 Thread voltron

Thanks for the tip Scoot!

On Feb 12, 2:51 pm, "ScottB" <[EMAIL PROTECTED]> wrote:
> On Feb 11, 3:42 pm, "voltron" <[EMAIL PROTECTED]> wrote:
>
> > I plan on using newForms and the auth module for my site. All of the
> > examples I have seen involve extracting form data and creating a user
> > in the database immediately, how can I "shortcircuit" this process to
> > allow one to confirm ones registration per email?
>
> > What is the preferred "Djangoic" way? I was thinking along the lines
> > of creating the user-account, disabling it immediately and sending out
> > to the given email address a "hash" of the password , this hash must
> > be sent back to the server for comparism per email, I would have to
> > parse the mail for this value.
>
> There's a good article on B-List about this:
>
> http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration
>
> I've done something similar, but using newforms.  You're on the right
> track:
>
> 1 - create the user, disable the account, generate and store an
> activation token (e.g. in a UserProfile model)
> 2 - send an email to the user containing a confirmation link with the
> token
> 3 - user clicks link in email to activate account (e.g. 
> http://www.example.com/accounts/confirm/voltron/a1b2c3d4e5/)
> 4 - once confirmed, enable the account
>
> Scott


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



Re: E-mailing forms

2007-02-13 Thread [EMAIL PROTECTED]

As one might expect, mail.send_mail() sends mail. You just need to
call it when you're saving or otherwise processing the form data.

On Feb 13, 1:27 pm, "ChelleBell" <[EMAIL PROTECTED]> wrote:
> I have seen all of this before, but will this send the form directly
> to an e-mail address, or after someone has submitted the form, will I
> have to go in and e-mail the form to the person?


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



SCGIMount != '/'

2007-02-13 Thread mulc


Is there any mechanism for making Django 'aware' of it's SCGI
mountpoint?

I have been experimenting with SCGI/WSGI bridges ( both flup, and
Titus Brown's SWAP from Paste )  and I am having difficulty mounting a
django-app under an existing website a particular location.

ie:  SCGIMount  '/django'   as opposed to SCGIMount '/'.

The Form-actions and redirects issued by Django are broken because
they are omitting the path-prefix ( ie:   GET /django/admin/ works
but the rendered form action is '/admin'. )

Anyone have any pointers or success stories on mounting django in this
fashion?

Thanks,

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: ¿django-es?

2007-02-13 Thread Esteban Saavedra L.

Hola, si te refieres a una lista de django en español, si la tenemos
la formamos hace un tiempo atras, si deseas suscribirte esta en:

http://groups.google.com.bo/group/django-es/


salu2

Esteban


-- 
M.Sc. Ing. Jose Esteban Saavedra Lopez
Gerente General
BanRey Consultores
Telefono:(+591.2) 5245959
Celular: +591 72450061
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Oruro - Bolivia
_
Te Invito a Visitarme y conocer mis Areas de
Investigacion
http://esteban.profesionales.org
Si quieres chatear ICQ: 16270256
_

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

2007-02-13 Thread Rob Hudson

> Not really. Anything you can do to a tuple (which is, basically,
> iterate over it, slice it and access specific items out of it) you can
> also do to a list. A tuple is just a little bit more efficient when
> you know you're dealing with something that isn't/shouldn't be
> mutable.

Actually, I think "list_per_page" should be an integer, not a list as
it is on the cheat sheet.

If so, that means only the js option is a list.  Which means
everything that has a multiple option list is a tuple already, with
the exception of the js list.

For some reason I thought ordering took a list.

-Rob


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



Re: Constructing Breadcrumbs

2007-02-13 Thread Jeremy Dunck

On 2/13/07, primitive <[EMAIL PROTECTED]> wrote:
> I was just wondering if anyone had any suggestions around creating
> breadcrumbs in django. I know this is a vague question, but I have a
> site built from scratch in django, and I want an easy way to construct
> breadcrumbs, possibly based on the urls.

Depends.  Is the breadcrumb intended to be location within the site
(i.e. You Are Here), or is it intended to be a back-tracking tool
(i.e. You got here by following this path)?

If the former, yeah, URL structure might be a good way to go.

If the latter, story the last x urls visited in the user's session (or
signed cookie).  This has the problem that multiple requestors (say,
open windows), will end up in one click-path for the session.  If that
bothers you, it gets more complicated, and I'd recommend your own
middleware to handle custom querystring parameters or similar.

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

2007-02-13 Thread kbochert



On Feb 13, 11:13 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 2/13/07, kbochert <[EMAIL PROTECTED]> wrote:
>
> > Given the urlhttp://127.0.0.1:8000/mysite.news.htm
>
> > then in urls.py
>
> > (r'^polls/(?P[a-z.]+)', 'Mysite.polls.views.news'),
> > #displays page properly, but without the graphics
>
> ...
> I don't think so, unless something odd is going on.  How does
> mysite.news.htm match something starting with "polls" ?
>

Ooops  brain typo
The url is http://127.0.0.1:8000/polls/news.html

> ...
>
> > How can rendering find the correct .gif file and then display it ,
> > but incorrectly??
>
> What's the finished HTML for the img src look like?   Django doesn't
> know about your web browser.  :)

The news.html  banner is displayed with:





The browser is FF 2.0, (IE 6  misdisplays also but a little
differently)
The OS is Windows 2000

The top half of the banner is displayed in reduced resolution. Other
graphics are either similar or missing altogether.
I think IE also displays  graphics in reduced resolution but but
showing alternate stripes rather than fuzzy pixels.


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

2007-02-13 Thread Ramiro Morales

[english version below]

Hola,

Conversando hace un tiempo con Ra (otra usuaria de Django que es muy
posible que algunos de los programadores Python argentinos conozcan)
surgió la idea de enviar este [1]e-mail para averiguar si existirá una masa
crítica de usuarios como para intentar armar un Grupo de usuarios de
Django .

Sé que en las listas de Django hay varios usuarios hispanoparlantes de
diferentes países (Argentina, Colombia, España, México, Perú,
Uruguay,...) así que ¿por qué no soñar con dar forma a algo en nuestro
idioma?. De allí el scope variable del párrafo de mas arriba.

Leyendo las listas de correo de Django uno se entera de que están
surgiendo grupos de este tipo en distintos lugares del planeta. También
hay movidas (algunas de ellas bastante avanzadas) para traducir la
documentación al japonés, al alemán, al italiano, al portugués de Brasil
e incluso han habido mensajes en django-i18n manifestando la
intención de arrancar con la tarea en nuestro idioma y preguntando si ya
existe un equipo de traducción.

Ra comentaba acerca de que tambien sería bueno pensar en
espacios de soporte y ayuda en español: una lista de correo, y
porqué no también, un canal de irc, que junto con documentación en
nuestro idioma ayudarían a bajar la barrera del idioma a la hora de
buscar ideas y solucionar problemas. En otras palabras, ser una
comunidad.

Si nos animamos incluso podríamos en algún momento tratar de
contribuir a Django armando sprints (virtuales?) para atacar
bugs generales o que afecten especialmente a su uso en nuestro
entorno. Se está gestando lo que va a ser el release de 1.0 de Django
con todo lo que ello conlleva asi es que se viven momentos de mucha
actividad en la comunidad de desarrollo.

Por ahora son todas ideas más o menos sueltas de cosas que
podríamos emprender. ¿Qué les parece?.

Atentamente,

1. Una versión similar de este mensaje se envió a la lista de correo
del Grupo de usuarios argentinos de Python

[English version]

Hi,

While talking with Ra (another Django user that argentinean Python
programmers may already know because she was one of the organizers
of the GrULiC Python day 2006) a couple of months ago, we thought
about sending this message to see if there is a critical mass of users
to create a "local" Django users group.

I know there are Spanish-speaking users in the Django mailing lists
from different countries (Argentina, Colombia, España, México, Perú,
Uruguay, ...), so why not dream about giving birth to something
in our language?.

Reading the Django lists shows there are already other
similar groups around the world. Also, efforts exist (some
of them well underway) to translate the documentation to Japanese,
German, Italian and Brazilian Portuguese languages. Even there have
been messages to the django-i18n list stating the intention of starting
the Spanish translation and asking about the existence of a
translation team.

Ra also mentioned it would be nice to think about support spaces
in Spanish: a mailing list, and even a IRC channel. Together with
the translated documentation this could be of help to lower the
entry barrier when it comes to start using Django or simply when
trying to solve a specific problem for existing users. In other words,
being a community.

If we feel brave enough we could even think about contributing
to Django by organizing (virtual?) sprints attacking general bugs
or simply bugs that are related to its use in our enviromnent.
Right now developers are hacking away what will become the 1.0
release of Django so the development community is living some
exciting times.

Well, that was a bunch of loose ideas of things we could start.
What do you think?.

Regards,

1. A similar version of this message was sent the Argentinean
Python Users mailing list.

-- 
 Ramiro Morales

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

2007-02-13 Thread ChelleBell

I have seen all of this before, but will this send the form directly
to an e-mail address, or after someone has submitted the form, will I
have to go in and e-mail the form to the person?


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

2007-02-13 Thread James Bennett

On 2/13/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
> I agree with another poster, adding FK and M2M and their options would
> be a nice addition if there is room.

Might be worth doing up multiple sheets, kind of like YUI does with
their components.

> Is there any reasoning to when an admin class option is a list and
> when it is a tuple?  I tend to default to tuple since I don't want to
> have to go look it up every time.  Can admin options be standardized
> to tuples across the board to make it easy?

Not really. Anything you can do to a tuple (which is, basically,
iterate over it, slice it and access specific items out of it) you can
also do to a list. A tuple is just a little bit more efficient when
you know you're dealing with something that isn't/shouldn't be
mutable.

-- 
"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: Django Cheat Sheet

2007-02-13 Thread Rob Hudson

Very cool.

I agree with another poster, adding FK and M2M and their options would
be a nice addition if there is room.

Minor nit... It says for version 0.95 yet there is a single template
filter with footnote "In development version only."  It seems like you
might as well remove that.

This also reminds me of a question I've been meaning to ask...

Is there any reasoning to when an admin class option is a list and
when it is a tuple?  I tend to default to tuple since I don't want to
have to go look it up every time.  Can admin options be standardized
to tuples across the board to make it easy?


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



Constructing Breadcrumbs

2007-02-13 Thread primitive

Good day,

I was just wondering if anyone had any suggestions around creating
breadcrumbs in django. I know this is a vague question, but I have a
site built from scratch in django, and I want an easy way to construct
breadcrumbs, possibly based on the urls.

Any suggestions or example implementations would be appreciated.

Regards.


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



Regex

2007-02-13 Thread kbochert


Given the url http://127.0.0.1:8000/mysite.news.htm

then in urls.py

(r'^polls/(?P[a-z.]+)', 'Mysite.polls.views.news'),
#displays page properly, but without the graphics


(r'^polls/(?P.+)', 'Mysite.polls.views.news'),
#displays page with some of the graphics, some of which are badly
rendered

(r'^polls/(?P.+m)', 'Mysite.polls.views.news'),
# displays page properly, but without graphics


I can accept that I have not yet found the correct path for graphics
in the template file, but how can different regex's find the correct
view, but render differently??

How can rendering find the correct .gif file and then display it ,
but incorrectly??


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

2007-02-13 Thread Tim Chase

> a Django cheat sheet:
> 
> 
> 
> We've spent a fair bit of time on it and would really appreciate the 
> following:
> 
> 1. That you download it; try it out and enjoy it!

Good stuff.  Had to squish it from A4 to 8.5x11 (rolls eyes at 
the silly American paper metric when A4 is so much more asthetic) 
but it came out legibly.

> 2. Give us feedback, we know it's not going to be perfect first time,
> so let us know: [EMAIL PROTECTED]

I noticed that ForeignKey, OneToOne, and ManyToMany field types 
were missing...I don't know if there's too much detail required 
for those to smash them into what little space you have left, but 
they're certainly hairier corners that it would be helpful to 
have on a cheat-sheet.  I remember hearing rumors that OneToOne 
may be deprecated, but I can't find any evidence to back that up.

Perhaps if you need the space, a 2nd page could contain FK and 
M2M (and perhaps O2O) as well as the date/time formatting codes 
that the sheet currently only references.  The whole thing could 
then be printed 2-sided and laminated to prevent food & beverage 
damage ;)

Just my ponderings.  Still helpful even without the above 
changes/additions.

-tkc







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

2007-02-13 Thread [EMAIL PROTECTED]

On Jan 2, 3:30 pm, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> * Like last year, I'll be sticking around for the four days after the
> conference to lead a Djangosprint.  Any and all are invited to attend; we'll
> have a huge amount of fun and get a whole lot done.

I'm really looking forward to this...any new news on the sprint?
Anything we can be doing now to get ready?

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: Django Cheat Sheet

2007-02-13 Thread Picio

Many many thanks, It helped me find the "js" admin feature !
I've not seen It before !
Useful!
Picio

2007/2/13, Benedict Verheyen <[EMAIL PROTECTED]>:
>
> John Sutherland schreef:
> > Hi all,
> >
> > Firstly, sorry for the cross-post.
> >
> > My employer, Mercurytide [1], as some of you may have seen in the
> > past, publishes white-papers on a monthly basis. This month it's
> > another Django themed one: a Django cheat sheet:
>
> Super John, very useful !
>
> Thanks,
> Benedict
>
>
> >
>

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



admin interface: insert/update

2007-02-13 Thread Antonio

hi all,

I've create a class whith a ForeignKey() who is visualized as  in
admin interface ... when I select a option from the menu and save, the
option selected change its state ('confermata') and must NOT appear in
the subsequents INSERT ... 

class Conferma(models.Model):
fk_prev = models.ForeignKey(Previsione, verbose_name="previsione",
limit_choices_to=models.Q(confermata=False))
pilota = models.CharField(maxlength=30, db_index=True)
h_chiamata = models.TimeField("ora chiamata pilota", help_text="hh:mm")
vadolig = models.BooleanField("vado ligure")
...

the problem is that when I go to update, the option loaded with the
ForeignKey NOT appear into the select menu, because it's 'confermata' ...

how can I tell to the "admin" that in UPDATE ONLY the option 'confermata'
with the Conferma() must show into the select menu ??

tanks in advance and sorry for the english !!

-- 
#include 
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}

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



Generating form file

2007-02-13 Thread Sebastien Armand [Pink]
I already know about the form form_for_model() function but I don't find it
very useful when you have to customize the form. If I need to customize each
field, I'll need to re-write the name of each field so using
form_for_model() becomes quite useless and it's not very DRY I think.
Is there a command from the django shell or from manage.py that can generate
the form for a given model in a file so that it would be easier to
personnalize?

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



Re: How do you pass a variable to a template tag?

2007-02-13 Thread [EMAIL PROTECTED]

Thank you Aidas. As it turns out, I already had a foreignkey
relationship with my user, so I didn't need a template tag at all.
Good to know how to do it, though.


On Feb 13, 10:27 am, "Aidas Bendoraitis" <[EMAIL PROTECTED]>
wrote:
> Hello Baxter!
>
> Take a look at my approach. It might help you. The following template
> tag "load_obj" loads any object by id and saves passes it to the
> template context variable:
>
> #  code starts here 
> from django.db.models import get_model
> from django import template
>
> register = template.Library()
>
> def do_load_obj(parser, token):
> try:
> # split_contents() knows not to split quoted strings.
> tag_name, appmodel, object_id, str_as, var_name = 
> token.split_contents()
> except ValueError:
> raise template.TemplateSyntaxError, "%r tag requires a
> following syntax: {%% %r app.model  as  %%}" %
> (token.contents[0], token.contents[0])
> try:
> appname, modelname = appmodel.split(".")
> except ValueError:
> raise template.TemplateSyntaxError, "%r tag requires
> application name and model name separated by a dot" %
> (token.contents[0], token.contents[0])
> from django.conf import settings
> model = get_model(appname, modelname)
> return LoadObjNode(model, object_id, var_name)
>
> class LoadObjNode(template.Node):
> """ {% load_obj app.name  as  %} """
> def __init__(self, model, object_id, var_name):
> self.model = model
> self.object_id = object_id
> self.var_name = var_name
> def render(self, context):
> try:
> object_id = template.resolve_variable(self.object_id, context)
> obj = self.model.objects.get(pk=object_id)
> except ValueError:
> obj = None
>
> context[self.var_name] = obj
> return ''
>
> register.tag('load_obj', do_load_obj)
>
> #  code ends here 
>
> I think, this is a good example of both -- reading a value of a
> variable in a template tag and also setting a value to the context
> variable.
>
> Regards,
> Aidas Bendoraitis aka Archatas
>
> On 2/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > I need to pass a user id to a template tag.
> > After reading this:http://groups.google.com/group/django-users/
> > browse_thread/thread/96fe34b4561415dc/b7aba25f22bdd261?
> > lnk=gst=template+tags+variable=1#b7aba25f22bdd261
>
> > I came up with:
>
> > class SongListNode(template.Node):
> > def __init__(self, artist, varname):
> > self.artist, self.varname  = artist, varname
>
> > def __repr__(self):
> > return ""
>
> > def render(self, context):
> > artist=self.artist.resolve(context)
> > context[self.varname] = Song.objects.filter(artist=artist)
> > #context[self.varname] = [self.artist]
> > return ''
>
> > class DoGetSongList:
> > """
> > {% get_song_list as song_list %}
> > """
> > def __init__(self, tag_name):
> > self.tag_name = tag_name
>
> > def __call__(self, parser, token):
> > bits = token.contents.split()
> > if len(bits) != 4:
> > raise template.TemplateSyntaxError, "'%s' tag takes three
> > arguments" % bits[0]
> > if bits[2] != "as":
> > raise template.TemplateSyntaxError, "second argument to
> > '%s' tag must be 'as'" % bits[0]
> > #return SongListNode(bits[1], bits[3])
> > return SongListNode(parser.compile_filter(bits[0]), bits[3])
> > register.tag('get_song_list', DoGetSongList('get_song_list'))
>
> > But no love. Suggestions?


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

2007-02-13 Thread Benedict Verheyen

John Sutherland schreef:
> Hi all,
> 
> Firstly, sorry for the cross-post.
> 
> My employer, Mercurytide [1], as some of you may have seen in the
> past, publishes white-papers on a monthly basis. This month it's
> another Django themed one: a Django cheat sheet:

Super John, very useful !

Thanks,
Benedict


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

2007-02-13 Thread Benedict Verheyen

ScottB schreef:
> I think you need to pass the actual values (i.e. the rooms), rather
> than a function that returns them.  Also 'id_in' needs two
> underscores.  So maybe:
> 
> limit_choices_to = {'id__in': get_rooms()}
> 
> Scott

Indeed, i had already found out there was an underscore short.
I tried 'id__in': get_rooms() and that won't work as it doesn't know
Patient when the function is called. That's why you have to use
get_rooms instead of get_rooms. The error is "global name 'Patient' is
not defined".

So it seems like this method is not going to work after all.
Are there any other ways to get a limited list (keeping in mind i'm not
using newforms) for a ForeignKey field?

I tried using this in my view:
room_choices = [(room.id, str(room)) for room in Room.objects.filter() ]
room_choices.sort()
room_choices.insert(0,BLANK_CHOICE_DASH[0]) # [('','-')]

Since i don't want to redesign the whole form, i change the current
field entry. I first look up the index of the field:
index = 0
for field in fields:
if ( field.field_name == "room" ): break
index+=1
return index

Then i replace that index with my version:
fields[index] = forms.SelectField(field_name="room", choices = room_choices)

Which indeed gives me a limited list but when you change the data of a
patient, the room he's in isn't selected. This something i still need to
change as the query leaves out the room/bed of the currently selected
patient too.
But even when i just select all rooms, the room the patient is in isn't
selected. Any idea how you can "select" a choice in the formfield?

Or any less cumbersome method to limit the choices?

Thanks,
Benedict


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



Re: How do you pass a variable to a template tag?

2007-02-13 Thread Aidas Bendoraitis

Hello Baxter!

Take a look at my approach. It might help you. The following template
tag "load_obj" loads any object by id and saves passes it to the
template context variable:

#  code starts here 
from django.db.models import get_model
from django import template

register = template.Library()

def do_load_obj(parser, token):
try:
# split_contents() knows not to split quoted strings.
tag_name, appmodel, object_id, str_as, var_name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, "%r tag requires a
following syntax: {%% %r app.model  as  %%}" %
(token.contents[0], token.contents[0])
try:
appname, modelname = appmodel.split(".")
except ValueError:
raise template.TemplateSyntaxError, "%r tag requires
application name and model name separated by a dot" %
(token.contents[0], token.contents[0])
from django.conf import settings
model = get_model(appname, modelname)
return LoadObjNode(model, object_id, var_name)

class LoadObjNode(template.Node):
""" {% load_obj app.name  as  %} """
def __init__(self, model, object_id, var_name):
self.model = model
self.object_id = object_id
self.var_name = var_name
def render(self, context):
try:
object_id = template.resolve_variable(self.object_id, context)
obj = self.model.objects.get(pk=object_id)
except ValueError:
obj = None

context[self.var_name] = obj
return ''

register.tag('load_obj', do_load_obj)

#  code ends here 

I think, this is a good example of both -- reading a value of a
variable in a template tag and also setting a value to the context
variable.

Regards,
Aidas Bendoraitis aka Archatas


On 2/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I need to pass a user id to a template tag.
> After reading this: http://groups.google.com/group/django-users/
> browse_thread/thread/96fe34b4561415dc/b7aba25f22bdd261?
> lnk=gst=template+tags+variable=1#b7aba25f22bdd261
>
> I came up with:
>
> class SongListNode(template.Node):
> def __init__(self, artist, varname):
> self.artist, self.varname  = artist, varname
>
> def __repr__(self):
> return ""
>
> def render(self, context):
> artist=self.artist.resolve(context)
> context[self.varname] = Song.objects.filter(artist=artist)
> #context[self.varname] = [self.artist]
> return ''
>
> class DoGetSongList:
> """
> {% get_song_list as song_list %}
> """
> def __init__(self, tag_name):
> self.tag_name = tag_name
>
> def __call__(self, parser, token):
> bits = token.contents.split()
> if len(bits) != 4:
> raise template.TemplateSyntaxError, "'%s' tag takes three
> arguments" % bits[0]
> if bits[2] != "as":
> raise template.TemplateSyntaxError, "second argument to
> '%s' tag must be 'as'" % bits[0]
> #return SongListNode(bits[1], bits[3])
> return SongListNode(parser.compile_filter(bits[0]), bits[3])
> register.tag('get_song_list', DoGetSongList('get_song_list'))
>
>
> But no love. Suggestions?
>
>
> >
>

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

2007-02-13 Thread Geert Vanderkelen

Hi John,

On 13 Feb 2007, at 11:24, John Sutherland wrote:

>
> Hi all,
>
> Firstly, sorry for the cross-post.
>
> My employer, Mercurytide [1], as some of you may have seen in the
> past, publishes white-papers on a monthly basis. This month it's
> another Django themed one: a Django cheat sheet:
>
> 

Awesome! Thanks for sharing this!
If only I had that this morning while on the train! :)

Cheers!

Geert

-- 
Geert Vanderkelen
http://some-abstract-type.com




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



stored procedures in initial SQL ?

2007-02-13 Thread Bram - Smartelectronix

Hi,


with the preprocessing that's being done on 'initial' SQL before adding 
it to the DB I'm getting into trouble with the stored procedures I would 
like to add to the DB (for the model in question).

The backend specific SQL gets treated the same way.

I think it's impossible to change the regular expression to take care of 
this special case.

Any ideas?


kindest,


  - bram

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



Re: Open Book Platform demo site is up

2007-02-13 Thread Jianjun


limodou and gasolin,
thanks for the help.

On Feb 13, 1:58 am, limodou <[EMAIL PROTECTED]> wrote:
> On 2/13/07, Jianjun <[EMAIL PROTECTED]> wrote:
>
> > limodou,
> > Thanks for sharing the source code. It looks a nice.
> > I got one question: I create a book on the demo site and I couldn't
> > find how to enable the comment bar on the left side. Did I miss
> > something? All the sample books except for the very first one do NOT
> > show the comment bar on the left side. Why is that?
>
> You should use restructuredtext to write your book, and if you want a
> comment block, you should put something like [01], [02], and the site
> will auto convert [xx] into comment block.
> for example:
>
> [01]Title
> =
>
> [02]This is the first paragraph.
>
> [03]This is the second paragraph.
>
> And this project only support ,  tag. So sometime
> you put [xx] at the beginning of the line, but it may not should at
> all. At this time, I think the converted result tag may not be
> supported.
>
> --
> I like python!
> UliPad <>:http://wiki.woodpecker.org.cn/moin/UliPad
> My Blog:http://www.donews.net/limodou


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

2007-02-13 Thread Marc Fargas Esteve

wow!

On 2/13/07, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>
> John Sutherland wrote:
> > Hi all,
> >
> > Firstly, sorry for the cross-post.
> >
> > My employer, Mercurytide [1], as some of you may have seen in the
> > past, publishes white-papers on a monthly basis. This month it's
> > another Django themed one: a Django cheat sheet:
> >
> > 
> >
> > We've spent a fair bit of time on it and would really appreciate the 
> > following:
> >
> > 1. That you download it; try it out and enjoy it!
> > 2. Give us feedback, we know it's not going to be perfect first time,
> > so let us know: [EMAIL PROTECTED]
> > 3. You publicise it: it would be awesome to get it on the digg front
> > page [2]; but put it on your blog, your del.icio.us or where ever...

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

2007-02-13 Thread Lars Stavholm

John Sutherland wrote:
> Hi all,
> 
> Firstly, sorry for the cross-post.
> 
> My employer, Mercurytide [1], as some of you may have seen in the
> past, publishes white-papers on a monthly basis. This month it's
> another Django themed one: a Django cheat sheet:
> 
> 
> 
> We've spent a fair bit of time on it and would really appreciate the 
> following:
> 
> 1. That you download it; try it out and enjoy it!
> 2. Give us feedback, we know it's not going to be perfect first time,
> so let us know: [EMAIL PROTECTED]
> 3. You publicise it: it would be awesome to get it on the digg front
> page [2]; but put it on your blog, your del.icio.us or where ever...

Brilliant!
/L

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

2007-02-13 Thread Sion Morris
I do have a widget attribute set on the field in the model but it is
rendered in the template as a . In which part of the model-view-template
do I specify how the radio (or checkbox) fields are rendered?

My model looks like this:

class ParticipantAttrForm(forms.Form):
# Dynamically creates a form to search participants attributes
def __init__(self, *args, **kwargs):
super(ParticipantAttrForm, self).__init__(*args, **kwargs)

for o in Subject.objects.all():
if o.e_type == 'TextInput':
self.fields['subject_%s' % o.id] =
forms.CharField(required=False,
   
label=o.e_question)
elif o.e_type == 'RadioSelect':
self.fields['subject_%s' % o.id] =
forms.ChoiceField(required=False,
   
label=o.e_question,
   
widget=forms.RadioSelect,
   
choices=o.get_e_choices())
elif o.e_type == 'CheckboxSelectMultiple':
self.fields['subject_%s' % o.id] =
forms.MultipleChoiceField(required=False,
   
label=o.e_question,
   
widget=forms.CheckboxSelectMultiple,
   
choices=o.get_e_choices())
elif o.e_type == 'Select':
self.fields['subject_%s' % o.id] =
forms.ChoiceField(required=False,
   
label=o.p_question,
   
widget=forms.Select,
   
choices=o.get_e_choices())

The view includes these lines:

   attributes = ParticipantAttrForm()

t = loader.get_template('add_entry.html')
c = Context({
'attributes': attributes,
})
return HttpResponse(t.render(c))


And the template looks like this:


{% for attribute in attributes %}
{{ attribute.label }} {{attribute }}
{% endfor %}





> From: Rubic <[EMAIL PROTECTED]>
> Reply-To: "django-users@googlegroups.com" 
> Date: Mon, 12 Feb 2007 13:20:59 -0800
> To: Django users 
> Subject: Re: Radio and Checkbox rendering
> 
> 
> Have you looked into passing a widget attribute into your field?  You
> can either subclass a widget or create one from scratch.
> 
> --
> Jeff Bauer
> Rubicon, Inc.
> 
> 
>> I have a form that is generated dynamically and contains either radio,
>> checkbox, text field or drop down menu.
>> 
>> The following is used to render the form:
>> 
>> 
>> {% for attribute in attributes %}
>> 
>> {{ attribute.label }} {{attribute }}
>> 
>> {% endfor %}
>> 
>> 
>> This work well except when attribute is a radio or a checkbox it
>> renders the field as unordered list. This is not what I want in this
>> particular case. From the source I can see that RadioFieldRenderer
>> should be used to customize how the radio button is rendered.
>> (Couldn't find a similar renderer for a checkbox).
>> 
>> How can I take advantage of the RadioFieldRenderer in a template? And
>> can I check if attribute is a particular field type in a template?


-- 
Gall y neges e-bost hon, ac unrhyw atodiadau a anfonwyd gyda hi,
gynnwys deunydd cyfrinachol ac wedi eu bwriadu i'w defnyddio'n unig
gan y sawl y cawsant eu cyfeirio ato (atynt). Os ydych wedi derbyn y
neges e-bost hon trwy gamgymeriad, rhowch wybod i'r anfonwr ar
unwaith a dilëwch y neges. Os na fwriadwyd anfon y neges atoch chi,
rhaid i chi beidio â defnyddio, cadw neu ddatgelu unrhyw wybodaeth a
gynhwysir ynddi. Mae unrhyw farn neu safbwynt yn eiddo i'r sawl a'i
hanfonodd yn unig  ac nid yw o anghenraid yn cynrychioli barn
Prifysgol Cymru, Bangor. Nid yw Prifysgol Cymru, Bangor yn gwarantu
bod y neges e-bost hon neu unrhyw atodiadau yn rhydd rhag firysau neu
100% yn ddiogel. Oni bai fod hyn wedi ei ddatgan yn uniongyrchol yn
nhestun yr e-bost, nid bwriad y neges e-bost hon yw ffurfio contract
rhwymol - mae rhestr o lofnodwyr awdurdodedig ar gael o Swyddfa
Cyllid Prifysgol Cymru, Bangor.  www.bangor.ac.uk

This email and any attachments may contain confidential material and
is solely for the use of the intended recipient(s).  If you have
received this email in error, please notify the sender immediately
and delete this email.  If you are not the intended recipient(s), you
must not use, retain or disclose any information contained in this
email.  Any views or opinions are solely those of the sender and do
not necessarily represent those of the University of Wales, Bangor.
The University of Wales, Bangor does not guarantee that this email or
any attachments are free from viruses or 100% secure.  Unless
expressly stated in the body of the text of the email, this email is
not intended to form a binding contract - a list of authorised
signatories is available from the University of Wales, Bangor Finance
Office.  www.bangor.ac.uk


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 

Re: Using NEWFORMS to select data from the MODEL

2007-02-13 Thread Brian Rosner

On 2007-02-10 18:22:53 -0700, "johnny" <[EMAIL PROTECTED]> said:

> 
> I have to include some fields from 3 different models. How do you
> create a selection field, for selecting a category data, in category
> model, using newforms?
> 
> Thank You in advance.
> 
> 
> 
The way I managed to pull this off was to use a custom form class.

class ModelInstanceForm(forms.Form):
def __init__(self, instance, data=None):
if data == None:
data = {}
for k in self.base_fields.keys():
data['%d-%s' % (instance.id, k)] = 
getattr(instance, k)
self.instance = instance
super(ModelInstanceForm, self).__init__(data, 
prefix=instance.id)

def save(self):
clean_data = self.clean_data
for k in self.base_fields.keys():
setattr(self.instance, k, clean_data[k])
self.instance.save()

Then you override this class with a regular form class that defines the 
fields from the model you passed in.

class ProductForm(ModelInstanceForm):
display_sort = forms.IntegerField()
sku = forms.CharField(max_length=255)
name = forms.CharField(max_length=255)
is_stocked = forms.BooleanField(required=False)

So now your form object accepts an instance of a model and you can pick 
and choose which ones you want to use.  You can have multiple forms for 
each instance.  My ModelInstanceForm uses a prefix since I wrote this 
code to allow a form with data in one model and a foriegn key form like 
listing the products that belong to a product page.  So this may not 
work for you out of the box, but you can form an idea around it.

-- 
Brian Rosner
http://www.brosner.com/blog



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

2007-02-13 Thread Jacob Kaplan-Moss

On 2/13/07 4:24 AM, John Sutherland wrote:
> My employer, Mercurytide [1], as some of you may have seen in the
> past, publishes white-papers on a monthly basis. This month it's
> another Django themed one: a Django cheat sheet:

This is awesome, John -- many thanks for putting it together :)

Jacob

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



Re: Django Cheat Sheet

2007-02-13 Thread [EMAIL PROTECTED]

On Feb 13, 11:24 am, "John Sutherland" <[EMAIL PROTECTED]>
wrote:

> My employer, Mercurytide [1], as some of you may have seen in the
> past, publishes white-papers on a monthly basis. This month it's
> another Django themed one: a Django cheat sheet:

Good job John, thanks.

Lorenzo


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



Rendering problem

2007-02-13 Thread kbochert

This may just be 5:00 AM stupid but:

I have an assortment of html files generated by a WYSIWYG editor (no
django markup).

I merge these into the polls tutorial and can display the index page
at http://127.0.0.1:8000/polls/ , apparently correctly

using views.py:

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('polls/index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))

and urls.py:

(r'^polls/$', 'Mysite.polls.views.index'),


Wishing to display the other pages, I..
add to urls.py:

(r'^polls/(?P.+)$', 'Mysite.polls.views.static'),

add to views.py:

def static(request, name):
return render_to_response('polls/%s' % name ,{'id': 1})


Now http://127.0.0.1:8000/polls/about.html displays the about page,
but badly
and now http://127.0.0.1:8000/polls/  displays the index page
similarly badly.
If  I rename 'static' in EITHER views.py OR urls.py then
http://127.0.0.1:8000/polls/ displays correctly again

???


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

2007-02-13 Thread ScottB

On Feb 13, 8:06 am, Benedict Verheyen <[EMAIL PROTECTED]>
wrote:
> def get_rooms():
> return Room.objects.exclude(id__in=[patient.room.id for patient in
> Patient.objects.filter(room__isnull=False)])

> I tried limit_choices_to = {'id_in': get_rooms} but this gives me:
> TypeError at /patient/aanpassen/94/
> Cannot resolve keyword 'id_in' into field
>
> limit_choices_to = {'id': get_rooms}
>
> So how can i specify my limited choices?

I think you need to pass the actual values (i.e. the rooms), rather
than a function that returns them.  Also 'id_in' needs two
underscores.  So maybe:

limit_choices_to = {'id__in': get_rooms()}

Scott


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



Re: best "right now" solution for large file uploads?

2007-02-13 Thread Bram - Smartelectronix

Nathan R. Yergler wrote:
> I recently had this problem and got nowhere with the ticket 2070
> patches.  I wanted large file upload with user feedback.  I ended up
> implementing a two-part solution: a CGI that actually handles the
> uploading (the "tramline"-like component) and a Django interface to
> it.
> 
> I've received permission from my client to write this up, but
> realistically I won't have it in shape for posting until later this
> week.  If you can wait until then, maybe it'd be useful.  Regardless
> I'll post it here when I have it put together.

I will not only would wait for it (if it takes less than 7 days that 
is), but if you are interested, I could give you some feedback on it as 
well :-)


  - bram

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



Django Cheat Sheet

2007-02-13 Thread John Sutherland

Hi all,

Firstly, sorry for the cross-post.

My employer, Mercurytide [1], as some of you may have seen in the
past, publishes white-papers on a monthly basis. This month it's
another Django themed one: a Django cheat sheet:



We've spent a fair bit of time on it and would really appreciate the following:

1. That you download it; try it out and enjoy it!
2. Give us feedback, we know it's not going to be perfect first time,
so let us know: [EMAIL PROTECTED]
3. You publicise it: it would be awesome to get it on the digg front
page [2]; but put it on your blog, your del.icio.us or where ever...

Cheers,
John.


[1] 
[2] 


-- 
[EMAIL PROTECTED]

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



Re: Image upload - self.image not defined in save method

2007-02-13 Thread Brice Carpentier

On 2/13/07, Dirk Eschler <[EMAIL PROTECTED]> wrote:
> i use ImageWithThumbnailField to upload screenhots. In the save method i want
> to set some additional model fields, like filesize and width/height of the
> uploaded image. The problem is, that self.image isn't defined at this point,
> the same entry has to be saved twice in the admin.
>
yeah, this is a problem.
As for width and height, there are width and height parameters to
ImageWithThumbnailField that you can use. (Look at the ImageField
documentation)


-- 
Brice Carpentier aka Br|ce

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



Image upload - self.image not defined in save method

2007-02-13 Thread Dirk Eschler

Hello,

i use ImageWithThumbnailField to upload screenhots. In the save method i want 
to set some additional model fields, like filesize and width/height of the 
uploaded image. The problem is, that self.image isn't defined at this point, 
the same entry has to be saved twice in the admin.

Checking for self.image (like i read in another thread) doesn't work for me. 
Is there any way to get around this problem?

# -
class Screenshot(models.Model):
image= ImageWithThumbnailField(upload_to='upload/screenshots/')
filesize = models.PositiveIntegerField(null=True, blank=True, 
editable=False)
width= models.PositiveSmallIntegerField(null=True, blank=True, 
editable=False)
height   = models.PositiveSmallIntegerField(null=True, blank=True, 
editable=False)

def get_image_path(self):
return '%s/%s' % (settings.MEDIA_ROOT, self.image)

def save(self):
super(Screenshot, self).save()
if self.image:
self.filesize = getsize(self.get_image_path())
img = Image.open(self.get_image_path())
self.width = img.size[0]
self.height = img.size[1]

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

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



Re: Is there a way for a template file to know its name?

2007-02-13 Thread limodou

On 2/13/07, Michael Lake <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Malcolm Tredinnick wrote:
>  > There isn't any way to do this built into Django. It may not always make
>  > sense, either, since a template could just be a string (hence have no
>  > name).
>  >
>  > Looking through some code I have written, I found a case where I was
>  > doing something like you are and I am just passing in a "no_display"
>  > variable in the context on the pages that shouldn't have a link like
>  > this. I test to see if no_display is false before trying to display the
>  > link (in fact, in my case, it's on a help page, too).
>
> Thats perfect, thanks.
> I now have
> {% if not no_display %}
> ... a help link in a div 
> {% else %}
> ... a blank div element ...
> {% endif %}
>
> and in my views for the just for the help function I have:
> render-to_reponse('lab/help.html', {'no_display': 1})
>
> Works a treat. Thanks.

Why not use

{% block help %}... a help link in a div {% endblock %}

in base.html, and in help.html

{% block help %}{% endblock %}

I think this will be simple.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Is there a way for a template file to know its name?

2007-02-13 Thread Russell Keith-Magee

On 2/13/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2007-02-13 at 17:29 +1100, Michael Lake wrote:
> > Hi all
> >
> There isn't any way to do this built into Django. It may not always make
> sense, either, since a template could just be a string (hence have no
> name).

Actually, there probably is a way to do this. Every Template()
instance does has a name - it defaults to "", but is
the name of the template file if the template was loaded from a file.
You can also programmatically set the template name if you are
constructing your own Template(0 from a string (which can be useful
for testing purposes).

There isn't a template tag to expose this data into the rendered
template, but I don't see any reason why one couldn't be written.

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



correct limit_choices_to syntax

2007-02-13 Thread Benedict Verheyen

Hi,

i'm trying to limit what the user sees for a certain Foreign key.
I was told to use the limited_choices_to argument and it indeed seems
to fit the bill. However, i'm doing something wrong as this is what i get:

TypeError at /patient/edit/94/
_filter_or_exclude() argument after ** must be a dictionary

This is the relevant code from my models.py
def get_rooms():
return Room.objects.exclude(id__in=[patient.room.id for patient in
Patient.objects.filter(room__isnull=False)])

class Patient(models.Model):
room = models.ForeignKey(Room, blank=True, null=True,
limit_choices_to = get_rooms )

I tried limit_choices_to = {'id_in': get_rooms} but this gives me:
TypeError at /patient/aanpassen/94/
Cannot resolve keyword 'id_in' into field

limit_choices_to = {'id': get_rooms}

So how can i specify my limited choices?

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



NEW MONEY NETWORK AGLOCO

2007-02-13 Thread efendy

Hi ...

I recently joined AGLOCO because of a friend recommended it to me. I
am now promoting it to you because I like the idea and I want you to
share in what I think will be an exciting new Internet concept.

Sign in : http://www.agloco.com/r/BBBV9253

AGLOCO's story is simple:


Do you realize how valuable you are? Advertisers, search providers and
online retailers are paying billions to reach you while you surf.  How
much of that money are you making? NONE!


AGLOCO thinks you deserve a piece of the action.


AGLOCO collects money from those companies on behalf of its members.
(For example, Google currently pays AOL 10 cents for every Google
search by an AOL user. And Google still has enough profit to pay $1.6
billion dollars for YouTube, an 18-month old site full of content that
YouTube's users did not get paid for!


AGLOCO will work to get its Members their share of this and more.


AGLOCO is building a new form of online community that they call an
Economic Network. They are not only paying Members their fair share,
but they're building a community that will generate the kind of
fortune that YouTube made. But instead of that wealth making only a
few people rich, the entire community will get its share.


What's the catch? No catch - no spyware, no pop-ups and no spam -
membership and software are free and AGLOCO is 100% member owned.
Privacy is a core value and AGLOCO never sells or rents member
information.


So do both of us a favor: Sign up for AGLOCO right now! If you use
this link to sign up, I automatically get credit for referring you and
helping to build AGLOCO.

Sign in : http://www.agloco.com/r/BBBV9253


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