Postgres and "autocommit"

2010-01-15 Thread apramanik
I turned autocommit on for our Django project and our unittests fail unless we put "transaction.rollback" in our tearDown. Any idea why? After fixing that I also noticed that our unittests are *much* slower. Is it because they're mainly doing deletes and writes (we also load in fixtures via YAML) a

Re: Mysterious transactions wrapping views without middleware.

2010-01-11 Thread apramanik
/ticket/12565 On Jan 11, 10:20 am, Tomasz Zieliński wrote: > On 10 Sty, 02:38, apramanik wrote: > > > > > Thanks! That partially fixes my problem. I wrapped a function with > > commit_on_success and it doesn't rollback the changes if it throws an > > Int

Re: Mysterious transactions wrapping views without middleware.

2010-01-09 Thread apramanik
, the transaction is *not* rolled back. If I place "transaction.set_dirty()" before the create, the transaction is rolled back. Seems like a bug. Abhik On Jan 9, 4:57 pm, Karen Tracey wrote: > On Sat, Jan 9, 2010 at 7:06 PM, apramanik wrote: > > Hey all, > > > I am seei

Mysterious transactions wrapping views without middleware.

2010-01-09 Thread apramanik
Hey all, I am seeing transactions wrapping my views without using the 'django.middleware.transaction.TransactionMiddleware'. I don't have any @transaction decorators around my view. I also tried setting DISABLE_TRANSACTION_MANAGEMENT to True as per: http://docs.djangoproject.com/en/1.1/topics/db/t

Re: ForeignKey efficiency question

2010-01-07 Thread apramanik
Thanks! On Jan 7, 2:19 am, Daniel Roseman wrote: > On Jan 7, 5:07 am, apramanik wrote: > > > > > Oops not a join, but still a db hit :). > > > On Jan 6, 9:03 pm, apramanik wrote: > > > > Hey all, if I have a foreign key on a model (say Model B has a

Re: ForeignKey efficiency question

2010-01-06 Thread apramanik
Oops not a join, but still a db hit :). On Jan 6, 9:03 pm, apramanik wrote: > Hey all, if I have a foreign key on a model (say Model B has a foreign > key to Model A) and I do something like this: > > a = A.objects.get( pk = 1 ) > b = B.objects.get( pk = 1 ) > > if

ForeignKey efficiency question

2010-01-06 Thread apramanik
Hey all, if I have a foreign key on a model (say Model B has a foreign key to Model A) and I do something like this: a = A.objects.get( pk = 1 ) b = B.objects.get( pk = 1 ) if b.a == a : # Do something Is that inefficient, since its doing a join to pull b.a? Should I be comparing their ids?

Fixtures don't retain primary keys from 'pk'

2009-12-04 Thread apramanik
Hi all, I've created a few yaml fixtures, but they don't retain the primary key you specify via "pk:". Here's a sample: - model: locations.location pk: 1 fields: type: 2 name: 'USA' aux_data: 'US' latitude: 12 longitude: -10 The primary key seems to always be 2 for every

Re: Have var available in every context passed to a template?

2009-11-22 Thread apramanik
Great, that worked! Abhik On Nov 21, 6:52 pm, Christophe Pettus wrote: > On Nov 21, 2009, at 6:48 PM, apramanik wrote: > > > Is there a way (either via decorators or some other mechanism) to get > > an var/object (say request.user) to be in the context passed to every > >

Have var available in every context passed to a template?

2009-11-21 Thread apramanik
Hi all, Is there a way (either via decorators or some other mechanism) to get an var/object (say request.user) to be in the context passed to every template. The reason I want to do this is my base template uses "user.is_authenticated" in a branch. Thanks Abhik -- You received this message beca

Form that handles variable number of inputs.

2009-11-20 Thread apramanik
Hi all, How would I get a Form to handle a variable number of inputs (these inputs are added via javascript)? Is this possible in Django? Thanks! Abhik -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django

Re: Anything like RoR's render :partial?

2009-11-15 Thread apramanik
Awesome! Thanks for the clarification. Abhik On Nov 15, 10:48 am, Dennis Kaarsemaker wrote: > On zo, 2009-11-15 at 10:08 -0800, apramanik wrote: > > > Sure in most cases, but is there a way to fake setting the context of > > the included template? If I'm iterating ove

Re: Anything like RoR's render :partial?

2009-11-15 Thread apramanik
-15 at 09:26 -0800, apramanik wrote: > > > I'm migrating to Django from Ruby on Rails. In the template language > > for Django, I've been looking for something similar to RoR's > > render :partial but can't find anything. It allows you write a > > temp

Anything like RoR's render :partial?

2009-11-15 Thread apramanik
Hi all, I'm migrating to Django from Ruby on Rails. In the template language for Django, I've been looking for something similar to RoR's render :partial but can't find anything. It allows you write a template for a snippet of code rather than an entire page. I found it very useful when I was disp

Re: Where to put utility functions...

2009-11-05 Thread apramanik
Thanks for the replies! I ended up creating a python package in the site's directory. Abhik On Nov 5, 8:35 am, bruno desthuilliers wrote: > On 5 nov, 16:52, apramanik wrote: > > > Hey all, > > > If I have some utility functions I want to share amongst my apps, > &

Re: Django won't create foreign keys

2008-01-14 Thread apramanik
Anyone? I still haven't gotten this to work without modifying Django. Thanks! On Jan 12, 3:34 pm, apramanik <[EMAIL PROTECTED]> wrote: > It seems to be fixed if I change sql_create django/core/management/ > sql.py to > > for model in app_models: >

Re: Django won't create foreign keys

2008-01-12 Thread apramanik
s.add(model) It didn't make sense to pass in model to sql_for_pending_references. On Jan 12, 2:21 pm, apramanik <[EMAIL PROTECTED]> wrote: > Well inserting rows with invalid poll_id's works, until i enter the > ALTER TABLE by hand, so the foreign key constraints are definite

Re: Django won't create foreign keys

2008-01-12 Thread apramanik
> wrote: > Do manage.py sqlall polls instead, it will show all the sql, not just > the tables, > > On Jan 12, 3:41 pm, apramanik <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I'm trying out the Django development version and have been going > > throug

Django won't create foreign keys

2008-01-12 Thread apramanik
Hi all, I'm trying out the Django development version and have been going through the tutorial, but the models aren't creating foreign keys. When I run 'python manage.py sql polls' I get: BEGIN; CREATE TABLE `polls_poll` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `question` var