How to select objects referenced by another table ?

2007-07-17 Thread Jonathan Ballet
Hello, I want to create a QuerySet object which select objects from a table which a referenced by another table, but I can't find how to do that. Here is an example : class Article(models.Model): [...] class Photo(models.Model): article = models.ForeignKey(Article)

Re: How to select objects referenced by another table ?

2007-07-18 Thread Jonathan Ballet
On 17 juil, 20:29, Tim Chase <[EMAIL PROTECTED]> wrote: > Fortunately, Django's ORM lets you get at the underlying SQL via > a call to .extra() where you can provide your own WHERE clause. > This would look something like > >Article.objects.extra(where=""" > app_article.id in (select arti

Re: remove ^M: project moved from window to linux

2008-01-13 Thread Jonathan Ballet
Hi, Le Sat, 12 Jan 2008 20:30:25 -0800 (PST), ocgstyles <[EMAIL PROTECTED]> a écrit : > I need to do that often at work when Windows files are moved over to > AIX. I just use vi. The key sequence is: > > :%s/^M// If you want to mimic dos2unix, you should use :%s/^M$// because those

Re: django transaction system

2008-01-22 Thread Jonathan Ballet
Hi, Le Tue, 22 Jan 2008 11:07:45 -0800 (PST), "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> a écrit : > Example: > Processes P1, P2, model instance m, with m.val > > - P1 grabs the object : m = MyModel.objects.filter(get the m i want) > [0] > - P2 grabs the object : m = MyModel.objects.filter(get the

Re: InnoDB on?

2008-01-22 Thread Jonathan Ballet
Hi, Le Tue, 22 Jan 2008 11:08:41 -0800 (PST), "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> a écrit : > > I need InnoDB for MySQL to do row locking in hopes of this working > efficiently. > > Is InnoDB on by default in MySQL 5.0? > > How can I tell? Look at the "SHOW ENGINES" SQL query http://dev.

Re: django transaction system

2008-01-22 Thread Jonathan Ballet
Le Tue, 22 Jan 2008 14:18:53 -0800 (PST), Rajesh Dhawan <[EMAIL PROTECTED]> a écrit : > - Before you execute lines of code that need to be synchronized > between processes, read mylock from memcached and set it to the > current timestamp if it's null. ... and bam, another process access the lock

Re: Best practice for implementing multilingual content in template

2008-01-27 Thread Jonathan Ballet
Hi! Le Sun, 27 Jan 2008 09:03:25 -0800 (PST), Emil <[EMAIL PROTECTED]> a écrit : > Hi! > > I'm currently working on a couple of sites where basically all content > is to be available in two languages. I haven't used django- > multilingual or anything readymade, but simply created double fields

Re: converting string to list

2008-01-29 Thread Jonathan Ballet
MariusB wrote: > In the view take an URL from the query: > query = request.POST.get('q', '') > How do I turn query from a string into a list with one element > (['']) in the view? I'm not sure I understand what you mean, but if you want to transform your "query" variable into a single-el

Re: Help With Table joins pleeeaaassseee

2008-01-29 Thread Jonathan Ballet
invisiWeeble wrote: > def prods_by_channel(request, slug): > > try: > ch = Channel.objects.get(slug__iexact=slug) > ct = ch.category_set.all() > except Category.DoesNotExist: > raise Http404 > > return list_detail.object_lis

Re: run multiple django app's on server

2008-01-30 Thread Jonathan Ballet
[EMAIL PROTECTED] wrote: > That's the weird thing, > > If we restart httpd.conf the python code will be compiled in some > cases it will show one of the projects for both ports and in a other > case it will show the other for both ports without altering anything > to the code. Both are working fi

Re: Django and Caching Pages

2008-02-05 Thread Jonathan Ballet
boralyl wrote: > So when I initially visit the page, it doesn't allow me to rate the > product. So I login and it redirects me to the home page(/). The > home page prints out my user name, so I know I am logged in. However > if I visit that product page again it still won't let me rate the > pr

Re: Setting up Apache & mod_python on my development computer

2008-02-06 Thread Jonathan Ballet
Hi, Brandon Taylor wrote: > > SetHandler python-program > PythonPath "['C:/django_projects/testproject'] + sys.path" > [...] Try : PythonPath "['C:/django_projects/'] + sys.path" instead, since "testproject" is the subdirectory where you project lives in. Maybe changing the

Re: Django cannot be used by large web sites?

2008-02-11 Thread Jonathan Ballet
asj2008 wrote: > We are hitting an error that disables the entire website when we have > more than 255 web pages...this is the error we see..has anyone seen > this before? It does not seem to be in the documentation > > ImproperlyConfigured at /products/ > > Error while importing URLconf 'co

Re: Custom SQL Escaping apostrophe

2008-04-15 Thread Jonathan Ballet
AJ wrote: [...] > sql = """ > SELECT MAX(`table`.`id`) > FROM `table` > WHERE `table`.`name` LIKE '%(kw)s' > GROUP BY `table`.`original_id`;""" > > sql = sql % {'kw' : '%%' + query + '%%'} > cursor.execute(sql) [...] This is the wrong way to do this, and your problem explains why. Take a look a

Re: Custom SQL Escaping apostrophe

2008-04-15 Thread Jonathan Ballet
[ I saw you next email, but I answer to this one, because errors are here ] Le Tue, 15 Apr 2008 11:03:03 -0700 (PDT), AJ <[EMAIL PROTECTED]> a écrit : > kw = 'test' > > sql = """ > SELECT MAX(`table`.`id`) > FROM `table` > WHERE `table`.`name` LIKE %s > GROUP BY `table`.`original_id`;""" > > c

Re: "Best" way of using templates

2007-02-16 Thread Jonathan Ballet
Thanks for all your answers ! I knew there was no One True Way of doing this, but I have more point of views now. I think, we might use the __str__() method, since it seems the simplest and cleanest way of doing this (a title is a sort of presentation in fact). Or maybe, we will stick with the g

Re: "Best" way of using templates

2007-02-19 Thread Jonathan Ballet
On 18 fév, 02:34, Lachlan Cannon <[EMAIL PROTECTED]> wrote: > Jonathan Ballet wrote: > > I think, we might use the __str__() method, since it seems the > > simplest and cleanest way of doing this (a title is a sort of > > presentation in fact). Or maybe, we wi

Using VIEWs from a database

2007-10-04 Thread Jonathan Ballet
Hi everyone, I have a project which uses a PostgreSQL database with several tables, and I have created VIEWs in this database. Now, I would like to be able to use those views from my Django project. Is there any "official" way to do this ? Currently, I made a new Model class, with the same fiel

"Best" way of using templates

2007-02-14 Thread Jonathan Ballet
Hello everybody, some days ago, my co-worker did some things which keep bothering me. He has a simple model, which represents, as it's name point out, err ... houses : class House(models.Model): price = models.FloatField(max_digits=10, decimal_places=2) to_buy = models.BooleanField(defa