Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Zhou
On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote: > I dont' know whether this make any sense . > Right now , I can't test it , but if django won't initiate the > views.py as a class , this method will make no sense. Why not write a decorator? --- David Zhou [EMAIL

Re: Usage of {% url %}

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 23:42 -0800, Roy wrote: > Hi, > > I have the following in one of my templates: > Flag > > But I'm getting a TemplateSyntaxError: > > Caught an exception while rendering: Reverse for 'mysite.comments- > flag' with arguments '(, '')' > and keyword arguments '{}' not found

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
I have found a post in here : http://davyd.livejournal.com/262859.html this is the way this author resolves this problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Usage of {% url %}

2008-11-30 Thread Roy
Hi, I have the following in one of my templates: Flag But I'm getting a TemplateSyntaxError: Caught an exception while rendering: Reverse for 'mysite.comments- flag' with arguments '(, '')' and keyword arguments '{}' not found The named url "comments-flag" comes from

Re: How can I to show a 2D dictionary in template ?

2008-11-30 Thread K*K
Oh, I got it! {% for content_id, content in contents.items %} {{ content.title }} {{ content.type }} {{ content.relative }}

How can I to show a 2D dictionary in template ?

2008-11-30 Thread K*K
Hi, I'm a newbie in Django. I got I problem looks like below: == contents.py == from testcms.contents.models import * class Contents(UserDict): def get_contents_list(self): contents = Contents.objects.all() for content in contents: author =

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
No , not in that way. Let me show you some code #a.py class A: def __init__(self): #do somthing #views.py class B(A): def index(request): #do something else #urls.py (r'^$', 'site.app.views.index'), I dont' know whether this make any sense . Right now , I can't

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 22:46 -0800, David Shieh wrote: > yeah , I will consider about middleware , and I am also thinking about > write a class that contains the functions I need , and other funcions > just inherit it , will it work ? Since functions don't inherit from classes, your question

Re: djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'

2008-11-30 Thread Russell Keith-Magee
On Mon, Dec 1, 2008 at 2:04 PM, djan <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm following along with djangobook.com, and I have a problem in > chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python > 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs > with MySQL).

Re: djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 21:04 -0800, djan wrote: > Hello, > > I'm following along with djangobook.com, and I have a problem in > chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python > 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs > with MySQL). The Django book

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
yeah , I will consider about middleware , and I am also thinking about write a class that contains the functions I need , and other funcions just inherit it , will it work ? On Dec 1, 2:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: >

djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'

2008-11-30 Thread djan
Hello, I'm following along with djangobook.com, and I have a problem in chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs with MySQL). When I run the following: $ python manage.py validate I receive: Traceback

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: > Hi , Malcolm, > > Now , I understand what you said.But using session means user must to > call a certain to set the session. I was using session as an *example*. It's something that, based on incoming request information, is run every

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
Hi , Malcolm, Now , I understand what you said.But using session means user must to call a certain to set the session.I mean , for example , I am setting up a blog , and every page want to show the categories this blog have . If I write these categories as a session value , I have to write it

Re: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat

2008-11-30 Thread Ulf Kronman
Hi again Malcolm, I've now performed some of the test you suggest here, and I would like to report my findings. > > It seems to me that when the Python renderer sees the Decimal() call, > > it goes and fetches my OS locale, which calls for Swedish decimal > > commas instead of US decimal points.

OpenId

2008-11-30 Thread Chris
I have been looking into using OpenId and I discovered that there are to 2 django libraries that handle this: django_openId and django_authopenid. Any opinions on the two? Not sure which one I should go with. --~--~-~--~~~---~--~~ You received this message because

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 21:48 -0800, David Shieh wrote: > Thanks , Malcolm , > > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread James Bennett
On Sun, Nov 30, 2008 at 11:48 PM, David Shieh <[EMAIL PROTECTED]> wrote: > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need to

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
Thanks , Malcolm , I think your solution can resolve my problem.But does it a bit complex ? In fact , what I really want is a view function that will be called by every view function. i.e. , if I wrote an auth system , I need to authenticate whether the user is logged in every view functions and

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 19:41 -0800, David Shieh wrote: [...] > I have searched for some information . I know that middleware can do > this , but what I really want is just a small function for this . A process_request() function in middleware can be as small as you like. Middleware provides the

Re: how to deploy css and images with apache

2008-11-30 Thread l0he1g
It is a very correct suggestion,Thank you! On 12月1日, 上午1时49分, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 30, 5:26 pm, l0he1g <[EMAIL PROTECTED]> wrote: > > > Hi,everyone,this is a beginner's first post,after a long,tired search > > here and there without any solution. > > I use

Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
I have used Django for several months , and it really attacts me . I love it. But when I use it more , I found a problem troubles me , that is , I can't find a way to make a function be called by every view function automatically . I used CakePHP , it have a function named beforeFilter() . It

Re: Error was: 'module' object has no attribute 'Form'

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 16:25 -0800, Andrew Arrow wrote: > Trying to get the example from > > http://docs.djangoproject.com/en/dev/topics/forms/ > > to work. I copied and pasted: > > from django import forms > > class ContactForm(forms.Form): > subject = forms.CharField(max_length=100) >

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

2008-11-30 Thread Andrew Arrow
Trying to get the example from http://docs.djangoproject.com/en/dev/topics/forms/ to work. I copied and pasted: from django import forms class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() sender = forms.EmailField() cc_myself

Re: how to deploy css and images with apache

2008-11-30 Thread l0he1g
Thank you a lot ,I think I have solved it,by add the following to httpd.conf: Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all I think the docs of django who said " would be meaningless here." is misleading a lot. On 12月1日,

Re: how to deploy css and images with apache

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 17:57 -0800, l0he1g wrote: > I am sorry adding a initial slash doesn't solve this problem,but thank > you for the same. > when I get http://localhost/static directly in browser,arise a 403 > message: > Forbidden > You don't have permission to access /static on this server.

Re: how to deploy css and images with apache

2008-11-30 Thread l0he1g
I am sorry adding a initial slash doesn't solve this problem,but thank you for the same. when I get http://localhost/static directly in browser,arise a 403 message: Forbidden You don't have permission to access /static on this server. when I get http:/localhost/,I inspect the adress of images in

Re: Sending automatic emails

2008-11-30 Thread R. Gorman
It is also possible to use a cronjob to initiate a script to send an e- mail. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com

Re: Django revision for ORM aggregation patch

2008-11-30 Thread Russell Keith-Magee
On Mon, Dec 1, 2008 at 9:13 AM, Ariel Mauricio Nunez Gomez <[EMAIL PROTECTED]> wrote: > >> I should be in a position to publish a git repository with my work in >> progress in the next day or so, which will remove the need for anyone >> to apply the patch manually. When I push the repository,

Re: Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 07:56 -0800, Log0 wrote: > Hi all, > > This string : > > data = ''.join( [ chr(i) for i in xrange(256) ] ) > > In Django 0.96, this string prints well. > In Django 1.0, this string simply disappears before going to Apache, > and the data is never transmitted to the

Re: ordering by models.ForeignKey

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 13:15 +0100, Alfredo Alessandrini wrote: > Hi, > > I've this model: > > class Player(models.Model): > user = models.ForeignKey(User, blank=True, null=True) > country = models.ForeignKey(Country) > > If I try to ordering Player by "user", don' work: > >

Re: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 01:34 -0800, Ulf Kronman wrote: > Hi Malcolm, > > > I forgot to mention this in my last reply, but you didn't actually > > answer the question that Karen asked. If you open up a Python prompt on > > your machine and do this: > > > > >>> import decimal > >

Re: Receiving xml via HTTP POST

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 01:15 -0800, Daniel Roseman wrote: [...] > No doubt someone will correct me if I'm wrong, but I don't think there > *is* any other way of receiving a file via POST except via a form. You gave an answer, so it's going to look crabby to say this, but that isn't correct. You

Re: Django revision for ORM aggregation patch

2008-11-30 Thread Ariel Mauricio Nunez Gomez
> I should be in a position to publish a git repository with my work in > progress in the next day or so, which will remove the need for anyone > to apply the patch manually. When I push the repository, I'll announce > on the ticket and on django-developers. Watch this space. That'd be great,

Re: Django revision for ORM aggregation patch

2008-11-30 Thread Russell Keith-Magee
On Mon, Dec 1, 2008 at 2:04 AM, Ariel Mauricio Nunez Gomez <[EMAIL PROTECTED]> wrote: > Does anybody know which revision of django works with the latest patch in > the ticket #3566 > http://code.djangoproject.com/ticket/3566 The patch on the ticket was constructed against a trunk revision just

Re: Admin - Auto Generate user_id on save

2008-11-30 Thread sergioh
On Nov 29, 8:26 pm, AJ <[EMAIL PROTECTED]> wrote: > James, > > Thanks for the reply, I can't tell you how many times I read over that > page in the documentation today, and didn't catch that.  I think when > this problem arose I looked over the ModelForm docs and couldn't find > a solution.  

Re: Adding new forms dynamically to the page?

2008-11-30 Thread Steve Bergman
I'm not expert at this. I've only used formsets a little, and I've never added any dynamically. But depending upon your requirements, you could define the formset with an adequate number of "extra=" forms and have the javascript hide most of them by default, displaying an additional one each

Re: Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Brian Neal
On Nov 30, 9:56 am, Log0 <[EMAIL PROTECTED]> wrote: > Hi all, > > This string : > > data = ''.join( [ chr(i) for i in xrange(256) ] ) > > In Django 0.96, this string prints well. > In Django 1.0, this string simply disappears before going to Apache, > and the data is never transmitted to the

Re: Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Jeff FW
What do you mean by "disappears"? How are you trying to output it? There's nothing special about the string that line generates, and I doubt anything would have changed between versions of Django that would stop that string from doing something it used to do. -Jeff On Nov 30, 10:56 am, Log0

Re: GeoDjango question about US zipcode lookup and spatial query

2008-11-30 Thread Aaron Lee
On Sat, Nov 29, 2008 at 12:24 PM, Justin Bronn <[EMAIL PROTECTED]> wrote: > > > I do have a few basic questions > > - on slide 37, there's a Zipcode model, how does one populate this model? > > Are we using fe_2007_us_zcta500.shp? If so, is there a program which > > converts the zipcode shape

Re: how to deploy css and images with apache

2008-11-30 Thread Daniel Roseman
On Nov 30, 5:26 pm, l0he1g <[EMAIL PROTECTED]> wrote: > Hi,everyone,this is a beginner's first post,after a long,tired search > here and there without any solution. > I use apache+mod_python on windows,The problem is the css and images > does't be imported anyway,as I did what "How to use Django

Re: Adding new forms dynamically to the page?

2008-11-30 Thread Zeroth
Thanks Steve. I've got the server-side portion done, just need to now work on the javascript. :) On Nov 30, 9:02 am, Steve Bergman <[EMAIL PROTECTED]> wrote: > When you add a form with javascript, you must also increment the > hidden field in the management form which holds the form count. >

how to deploy css and images with apache

2008-11-30 Thread l0he1g
Hi,everyone,this is a beginner's first post,after a long,tired search here and there without any solution. I use apache+mod_python on windows,The problem is the css and images does't be imported anyway,as I did what "How to use Django with Apache and mod_python" told in

Django revision for ORM aggregation patch

2008-11-30 Thread Ariel Mauricio Nunez Gomez
Does anybody know which revision of django works with the latest patch in the ticket #3566 http://code.djangoproject.com/ticket/3566 I tried unsuccesfully with django 1.0rc, 1.0 and 1.0.2, everytime different rejections, and when I try to fix them by hand I always get a 'SELECT FROM ...' invalid

Re: Adding new forms dynamically to the page?

2008-11-30 Thread Steve Bergman
When you add a form with javascript, you must also increment the hidden field in the management form which holds the form count. Actually, you'll need to read that field before you add the form to determine what the proper ids and names for the new input elements should be. Validation will then

Invalid block tag: render_comment_form

2008-11-30 Thread Florian Lindner
Hello, I use the comments framework from the newest Django SVN checkout. I have in my template: {% load comments % } [...] {% render_comment_form for object %} resulting in a Invalid block tag: 'render_comment_form' I have found the same error in one other posting but no solution. What is

Re: Implement file upload in admin interface

2008-11-30 Thread Ben Lau
hi, It is mush easier then my approach. Thanks a lot! On Fri, Nov 28, 2008 at 9:28 PM, redbaron <[EMAIL PROTECTED]> wrote: > > > My current solution is. > > 1. Define new model Batches: > > class Batches(models.Model): > batchfile = model.FileField(upload_to="noop") > > 2. In admin.py define

Re: OneToOneField blank=True null=True having an accident

2008-11-30 Thread stevedegrace
I found a solution on my own, and it's a doozy. If anyone can think of something a bit less ugly, let me know. The reason why the global variables are lists is to keep Python from trying to rebind the names as local variables inside the functions on assignment (the very behaviour that makes

Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Log0
Hi all, This string : data = ''.join( [ chr(i) for i in xrange(256) ] ) In Django 0.96, this string prints well. In Django 1.0, this string simply disappears before going to Apache, and the data is never transmitted to the client or even apache. Why? Any fix? Thanks a lot. --- Best

Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Log0
Hi all, This string : data = ''.join( [ chr(i) for i in xrange(256) ] ) In Django 0.96, this string prints well. In Django 1.0, this string simply disappears before going to Apache, and the data is never transmitted to the client or even apache. Why? Any fix? Thanks a lot. --- Best

Re: Adding new forms dynamically to the page?

2008-11-30 Thread Zeroth
So to clarify, I'd be modifying the new rows on the client side, correct? On Nov 29, 9:47 pm, "Felipe Sodré Silva" <[EMAIL PROTECTED]> wrote: > I don't see why it wouldn't. > > On Sun, Nov 30, 2008 at 3:42 AM, Zeroth <[EMAIL PROTECTED]> wrote: > > > Thanks Felipe for your quick answer. Does that

Re: Modify uploaded image

2008-11-30 Thread Eric Abrahamsen
On Nov 30, 2008, at 10:36 PM, Alex Jonsson wrote: > > Hey guys, > > I have an application where I want my users to be able to upload a > picture. The model contains a name field and a ImageField. > > My question is how the easiest way would be to modify this image > before saving it? That is,

Modify uploaded image

2008-11-30 Thread Alex Jonsson
Hey guys, I have an application where I want my users to be able to upload a picture. The model contains a name field and a ImageField. My question is how the easiest way would be to modify this image before saving it? That is, cropping it down to a certain size and renaming it to the person's

OneToOneField blank=True null=True having an accident

2008-11-30 Thread stevedegrace
Another problem! I'm using Django 1.0.2, Python 2.5.2, on Ubuntu 8.10. I have a structure of keys and keyrings arranged in a tree of arbitrary depth which I decided to implement as a bunch of models: RootKeyRing, RootKey, SubKeyRing, SubKey (rather than as XML like maybe I should have done)

Re: Templatetag: parser is choking

2008-11-30 Thread stevedegrace
Well, I got that fairly complicated recursive control structure working nicely... it resembles if/else/endif, but it loops picking up nodelists in a dictionary indexed by tag name, makes a list of the tags it finds until the endtag, and checks the list to make sure the syntax inside the bock was

Multi Table Inheritance with Mulitple Children

2008-11-30 Thread Fergus
I have an inheritance system for defining people. So there's a class Person, and sub-class User thus: class Person(models.Model): ''' A person! ''' firstname = models.CharField("first name", max_length = 128, help_text = "(required)") lastname = models.CharField("last name",

ordering by models.ForeignKey

2008-11-30 Thread Alfredo Alessandrini
Hi, I've this model: class Player(models.Model): user = models.ForeignKey(User, blank=True, null=True) country = models.ForeignKey(Country) If I try to ordering Player by "user", don' work: Player.objects.order_by("user") I want ordering Player by user.username Alfredo

Re: Django - processing flatpages problem.

2008-11-30 Thread Grzegorz Szymański
Thank you for the tip. It works well. I have problem with processing flat pages. When debug is switched to True the error appear in db with following content: Traceback (most recent call last): File "/usr/local/lib/python2.6/site-packages/django/core/handlers/base.py", line 86, in

Re: m2m relationship by intermediary model and inline editing

2008-11-30 Thread mrsource
Ok, Solved!! It wasmy fault because I have overwritten the form widget in the inline model. Now I have removed the customized form. On Nov 29, 11:16 pm, mrsource <[EMAIL PROTECTED]> wrote: > I have models and admin configuration like these:http://dpaste.com/94671/ > > when I edit the model

Re: Django debugging problem.

2008-11-30 Thread DIrk Ye
How about use this app: http://code.google.com/p/django-crashlog/ It will store error info in db. DIrk On Sun, Nov 30, 2008 at 4:36 PM, Grzegorz Szymański <[EMAIL PROTECTED]>wrote: > > On Sunday 30 of November 2008 09:31:55 Grzegorz Szymański wrote: > > Hi, > > I have no too much experience

Re: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat

2008-11-30 Thread Ulf Kronman
Hi Malcolm, > I forgot to mention this in my last reply, but you didn't actually > answer the question that Karen asked. If you open up a Python prompt on > your machine and do this: > >         >>> import decimal >         >>> decimal.Decimal('1.0') > > does it raise an exception? Sorry, I

Re: Receiving xml via HTTP POST

2008-11-30 Thread Daniel Roseman
On Nov 30, 1:25 am, chefsmart <[EMAIL PROTECTED]> wrote: > Can someone throw a few ideas at me regarding this please... I'm sure > seasoned Django-ists could have really good ideas about this... > Thanks. > > On Nov 22, 10:06 pm, chefsmart <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I am

Re: Django debugging problem.

2008-11-30 Thread Grzegorz Szymański
On Sunday 30 of November 2008 09:31:55 Grzegorz Szymański wrote: > Hi, > I have no too much experience with django and I have problem with my django > application. > When I switch DEBUG variable in settings.py to True the given url is > handled correctly and page is displayed as I expect. But

Django debugging problem.

2008-11-30 Thread Grzegorz Szymański
Hi, I have no too much experience with django and I have problem with my django application. When I switch DEBUG variable in settings.py to True the given url is handled correctly and page is displayed as I expect. But when is switch DEBUG to False then I get "Unhandled exception error" I