Re: Preventing JOIN while checking if a self referencing FK is null

2012-03-22 Thread diafygi
Is there a reason why editor_id is meant to raise a field error? -Daniel On Mar 21, 12:05 pm, diafygi wrote: > >>> Blog.objects.filter(editor_id=None) > > FieldError: Cannot resolve keyword 'editor_id' into field. > > This was actually an offered answer

Re: Preventing JOIN while checking if a self referencing FK is null

2012-03-21 Thread diafygi
ERE `myapp_user`.`id` IS NULL -Daniel On Mar 21, 2:07 pm, Andre Terra wrote: > On Wed, Mar 21, 2012 at 5:41 AM, diafygi wrote: > > >>> Blog.objects.filter(editor=None) > > >>> print Blog.objects.filter(editor=None).values('id').query > > SELECT &q

Re: Preventing JOIN while checking if a self referencing FK is null

2012-03-21 Thread diafygi
>>> Blog.objects.filter(editor_id=None) FieldError: Cannot resolve keyword 'editor_id' into field. This was actually an offered answer in the previous thread, but the id version of the field still raises a field error. Daniel On Mar 21, 9:47 am, Javier Guerra Giraldez wrote: > try: > > > Blog.o

[bump] Preventing JOIN while checking if a self referencing FK is null

2012-03-21 Thread diafygi
There is an old thread that didn't end in a resolution about preventing joins in a filter(foreign_key=None) scenario. http://groups.google.com/group/django-users/browse_thread/thread/61ee2fb22deae326 I'd like to bring it up again and ask if there is now a way to prevent joins from a query. An ex

[re-open] viewing generated SQL without running the query

2012-02-21 Thread diafygi
There's a previous thread about this[1], but it was closed back in 2006 without resolution. So I'd like to check back in and see if there is a way to get a complete query string without executing the query. At first, I thought I could just use the QuerySet.query.__str__(), but that does not put qu

Way to identify affected rows from a delete in the admin

2012-01-04 Thread diafygi
In the django admin site, it lists the entries that will be deleted via cascade if you want to delete something. I'm wondering if you can do something similar in the shell to identify the rows affected by a deletion. Is there such a function in django to show the list of casade deletes like in the

Re: Format queryset return dictionary of primary keys?

2011-08-04 Thread diafygi
Right, that's what I'm currently doing. I was just wondering if there was a pre-defined way. On Aug 4, 4:06 pm, Shawn Milochik wrote: > I don't know about built-in, but you could do it in Python by iterating > through your list and creating a dictionary with a key of the id and > value of the res

Format queryset return dictionary of primary keys?

2011-08-04 Thread diafygi
Howdy all, I'm know you can create a list of dictionaries for a queryset using values(). However, I'm wondering if you can create one dictionary where the keys are the primary keys of the result. For example: class Car(models.Model): vin = models.IntegerField() >>Model.objects.all().values(

Disable debug logging for django.db.backends?

2011-05-24 Thread diafygi
Howdy all, I have DEBUG=True in my settings.py, and I have several logging entries in my project (Django 1.3) However, when I am testing, there are tons of django.db.backends debug entries that appear, and my logs gets lost in the shuffle. Is there a way to disable django.db.backends in my setti