Doing "OR" operation with Database API?

2005-11-01 Thread Armin
How can I do 'or' in Django's Database API. Something like this: select * from message where from = 'armin' OR to = 'armin' Thank you in advance for your response. You guys are great. Armin

Re: Catching IntegrityError?

2005-11-01 Thread Clint Ecker
Thanks a bunch! I rewrote my app using the manipulators and such and it cut out a ton of stuff I'd written! I guess I should read through the docs a bit more often ;) Clint On 11/1/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote: > > On 11/1/05, Clint Ecker <[EMAIL PROTECTED]> wrote: > > In my vi

Re: getting id of logged user in admin site

2005-11-01 Thread Flavio Curella
thanks Hugo. I think this is a common case: I (and peraphs many people) prefer django to other frameworks because of its admin application: half a work is already made. I think a feature like this will be very helpful to many people, so I will open a ticket on django's trac. Thanks to all, Flavi

Re: getting id of logged user in admin site

2005-11-01 Thread hugo
>What I want to do is to save the article with the id of user that is >saving the article, without the need to select an user/author from a >menu. The model code doesn't have access to the request, so you are out of luck. It's simple to do in your own applications (as you have full control over y

Re: How to integrate a search engine in a Django site?

2005-11-01 Thread hugo
>Thanx for the link!!! However, it seems like I cannot search across >different models even if they have the same attributes that I want >to search. My abstract searching stuff (Ian gave the link) does allow searching over different models - you just add multiple search definitions. The model

Re: NullBooleanField & default=Unknown & Unknown not acceptable: how to do it?

2005-11-01 Thread Emanuele
Ouch! Sorry for the confusion : maybe the forces of evil are close to my house. ;) Emanuele

Re: getting id of logged user in admin site

2005-11-01 Thread Flavio Curella
your snippet works, but it returns the id of the author of an articles already saved in the database. What I want to do is to save the article with the id of user that is saving the article, without the need to select an user/author from a menu.

Re: foreign key lookup problem

2005-11-01 Thread Adrian Holovaty
On 11/1/05, stava <[EMAIL PROTECTED]> wrote: > Another alternative I tried out in the meantime was to change the > definition of State taking out the "primary_key = True". That worked > fine as well. Yes, that would work. Just for your knowledge, the reason that would also work is that removing "

Re: foreign key lookup problem

2005-11-01 Thread stava
God you're quick, I just posted this. Just tested it and it works fine now. Another alternative I tried out in the meantime was to change the definition of State taking out the "primary_key = True". That worked fine as well. Thanks a bunch! /LarS

Re: foreign key lookup problem

2005-11-01 Thread Adrian Holovaty
On 11/1/05, stava <[EMAIL PROTECTED]> wrote: > class State(meta.Model): > state = meta.CharField(maxlength = 12, primary_key = True) > > class Item(meta.Model): > wdate = meta.DateField() > state = meta.ForeignKey(State) > > % python > >>> from django.models.ttime import * > >>> items.get_li

Re: Catching IntegrityError?

2005-11-01 Thread Adrian Holovaty
On 11/1/05, Clint Ecker <[EMAIL PROTECTED]> wrote: > In my view, I do something similar to the following (instantate a new > Person, fill in the information from a form, and try to save it). When > someone enters a forumsname that's already in the database, I'd like to > catch that, and act appro

foreign key lookup problem

2005-11-01 Thread stava
I have difficulties using field lookups on foreign keys. I'm trying to retrieve a list of items with a specific state using the following model: class State(meta.Model): state = meta.CharField(maxlength = 12, primary_key = True) class Item(meta.Model): wdate = meta.DateField() state = meta

Catching IntegrityError?

2005-11-01 Thread Clint Ecker
I've got a model that looks like the following and describes a "Person", notice that I require the forumsname to be "unique"---begin code---class Person(meta.Model):    fullname    = meta.CharField(maxlength=100,verbose_name="Full Name",blank=False)    forumsname  = meta.CharField(maxlengt

Re: post_save problem

2005-11-01 Thread stava
OK, thanks, that cleared things up.

Re: pre_save problem

2005-11-01 Thread stava
OK, thanks.

Re: post_save problem

2005-11-01 Thread Adrian Holovaty
On 11/1/05, stava <[EMAIL PROTECTED]> wrote: > In a foreign key relationship, the main objects pre_save() and > post_save() both get performed prior to the subordinate object's pre > and post save, e.g.: > > poll._pre_save() > poll._post_save() > choice._pre_save() > choice._post_save() > choice._

Re: pre_save problem

2005-11-01 Thread Adrian Holovaty
On 11/1/05, stava <[EMAIL PROTECTED]> wrote: > In a foreign key relationsship (like Polls and Choices in the > tutorial), the _pre_save() definition tries to retrieve the subordinate > ("choices") items from the database. I really would like to get hold of > the subordinate items prior to being sa

Re: Problems with Admin interface and one-to-one rels

2005-11-01 Thread Dado
Adrian Holovaty wrote: > On 10/30/05, Dado <[EMAIL PROTECTED]> wrote: > > When I added the admin interface via "class META: admin = meta.Admin()" > > to the models as described in > > I > > cannot get the Admin interface to work prop

Re: getting id of logged user in admin site

2005-11-01 Thread Joey Coleman
Try the following: On 10/27/05, Flavio Curella <[EMAIL PROTECTED]> wrote: > > hi all, I've this model: > > from django.core import meta > from django.models.auth import User > > class Article(meta.Model): > title = meta.CharField(maxlength=255) > content = meta.TextField() >

post_save problem

2005-11-01 Thread stava
In a foreign key relationship, the main objects pre_save() and post_save() both get performed prior to the subordinate object's pre and post save, e.g.: poll._pre_save() poll._post_save() choice._pre_save() choice._post_save() choice._pre_save() choice._post_save() Is this intentional? I would

pre_save problem

2005-11-01 Thread stava
In a foreign key relationsship (like Polls and Choices in the tutorial), the _pre_save() definition tries to retrieve the subordinate ("choices") items from the database. I really would like to get hold of the subordinate items prior to being saved to database (well, it's called pre_save, right?)

Re: NullBooleanField & default=Unknown & Unknown not acceptable: how to do it?

2005-11-01 Thread Adrian Holovaty
On 11/1/05, James Bennett <[EMAIL PROTECTED]> wrote: > On 11/1/05, Emanuele <[EMAIL PROTECTED]> wrote: > > Now I see. So "" means blank value. I missed it in the docs. Thank > > you again!! > > No, the example Adrian provided had the tuple ('', '---') for that > choice; '---' is what will show

[ANN] Django Page Templates & Exception Formatter

2005-11-01 Thread Stefan H. Holek
Some news for those of us using Zope3 Page Templates with Django: * DjangoPageTemplates 1.0.2 is available. This is a bugfix release to tackle a problem with TALES path expressions. If you have seen unexpected NameErrors, this release is for you.

Re: getting id of logged user in admin site

2005-11-01 Thread Grigory Fateyev
Hello Flavio Curella! On Tue, 01 Nov 2005 03:33:01 -0800 you wrote: > > > Grigory Fateyev wrote: > > Hello Flavio Curella! > > On Thu, 27 Oct 2005 20:20:23 - you wrote: > > > > > > > > hi all, I've this model: > > > > > > from django.core import meta > > > from django.models.auth import Use

Re: getting id of logged user in admin site

2005-11-01 Thread Flavio Curella
Grigory Fateyev wrote: > Hello Flavio Curella! > On Thu, 27 Oct 2005 20:20:23 - you wrote: > > > > > hi all, I've this model: > > > > from django.core import meta > > from django.models.auth import User > > > > class Article(meta.Model): > > title = meta.CharField(maxlength=255) > > c

Re: NullBooleanField & default=Unknown & Unknown not acceptable: how to do it?

2005-11-01 Thread James Bennett
On 11/1/05, Emanuele <[EMAIL PROTECTED]> wrote: > Now I see. So "" means blank value. I missed it in the docs. Thank > you again!! No, the example Adrian provided had the tuple ('', '---') for that choice; '---' is what will show up in the admin, but '' is the actual value it will try to inse

Re: NullBooleanField & default=Unknown & Unknown not acceptable: how to do it?

2005-11-01 Thread Emanuele
Now I see. So "" means blank value. I missed it in the docs. Thank you again!! Emanuele