Re: Silently capturing all UnicodeDecodeError exceptions in widget rendering

2009-02-20 Thread Malcolm Tredinnick
On Fri, 2009-02-20 at 22:22 +0100, Ludvig Ericson wrote: > On Feb 20, 2009, at 20:38, Ben Gerdemann wrote: > > > > > I just spent a good part of my afternoon tracking down a bug in my > > code, that eventually turned out to be a Unicode encoding problem. The > > reason it took me so long to track

Re: Silently capturing all UnicodeDecodeError exceptions in widget rendering

2009-02-20 Thread Malcolm Tredinnick
On Fri, 2009-02-20 at 11:38 -0800, Ben Gerdemann wrote: > I just spent a good part of my afternoon tracking down a bug in my > code, that eventually turned out to be a Unicode encoding problem. The > reason it took me so long to track down the problem is this code here > in 'template/__init__.py':

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Øyvind Saltvik
I get the backwards compatibility issue, so if it cant be changed that is understandable. Also I simplified the issue about aggregate, I should have shown the actual use case, to only show galleries of with videos that has been converted. Gallery.objects.annotate(video_count=Count('videos__flv_v

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Karen Tracey
On Fri, Feb 20, 2009 at 5:18 PM, Øyvind Saltvik wrote: > > Topic of the thread says ticket #10244. > Ah, so it is, I missed that. Sorry. I'm often blind to thread titles. > > On filefield being saved in the db as '' when saved from the form, > that makes perfect sense now. > > But explicitly

Re: Silently capturing all UnicodeDecodeError exceptions in widget rendering

2009-02-20 Thread Ludvig Ericson
> On Feb 20, 2009, at 22:22, Ludvig Ericson wrote: >> logger = logging.getLogger("django.template") >> # ... >> try: >> do_whatever() >> except MyError: >> logger. > > How very clever of me to just leave a half-written example... > > logger = logging.getLogger("django.template") >

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Øyvind Saltvik
Topic of the thread says ticket #10244. On filefield being saved in the db as '' when saved from the form, that makes perfect sense now. But explicitly setting the field to None in python should store NULL in the db. On 20 Feb, 22:05, Karen Tracey wrote: > On Fri, Feb 20, 2009 at 3:21 PM, Øyvi

Re: Silently capturing all UnicodeDecodeError exceptions in widget rendering

2009-02-20 Thread Ludvig Ericson
On Feb 20, 2009, at 20:38, Ben Gerdemann wrote: > > I just spent a good part of my afternoon tracking down a bug in my > code, that eventually turned out to be a Unicode encoding problem. The > reason it took me so long to track down the problem is this code here > in 'template/__init__.py': > >

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Alex Gaynor
On Fri, Feb 20, 2009 at 4:05 PM, Karen Tracey wrote: > On Fri, Feb 20, 2009 at 3:21 PM, Øyvind Saltvik > wrote: > >> >> Attached new patch to ticket that should make the behaviour as >> expected. >> > > To what ticket? There's no reference to a ticket in this (argh, > top-posted) thread. > > >>

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Karen Tracey
On Fri, Feb 20, 2009 at 3:21 PM, Øyvind Saltvik wrote: > > Attached new patch to ticket that should make the behaviour as > expected. > To what ticket? There's no reference to a ticket in this (argh, top-posted) thread. > On 20 Feb, 20:15, Øyvind Saltvik wrote: > > The problem is, it is impos

list_select_related could more intuitive

2009-02-20 Thread jameslon...@gmail.com
First let me start by referencing another ticket already in the wild. http://code.djangoproject.com/ticket/8213 This updates list_select_related to accept a tuple which will be used for the select_related call. Jacob proposes simply overriding the queryset() method which is fine in most cases. An

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Øyvind Saltvik
Attached new patch to ticket that should make the behaviour as expected. On 20 Feb, 20:15, Øyvind Saltvik wrote: > The problem is, it is impossible to make a FileField None. > > >>> from django.db import connection > >>> from app.models import Model > >>> instance = Model.objects.all()[0] > >>>

Silently capturing all UnicodeDecodeError exceptions in widget rendering

2009-02-20 Thread Ben Gerdemann
I just spent a good part of my afternoon tracking down a bug in my code, that eventually turned out to be a Unicode encoding problem. The reason it took me so long to track down the problem is this code here in 'template/__init__.py': 794 class VariableNode(Node): ... 801 def render(s

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Øyvind Saltvik
The problem is, it is impossible to make a FileField None. >>> from django.db import connection >>> from app.models import Model >>> instance = Model.objects.all()[0] >>> instance.filefield = None >>> instance.save() >>> print connection.queries[-1] On 20 Feb, 19:06, Collin Grady wrote: > It wi

Re: #10244 FileFields can't be set to NULL in the db

2009-02-20 Thread Collin Grady
It will only store NULL if you set it to None - if you leave the field blank in a form or admin, there's still an empty string posted for most string field types, so it stores that empty string. On Fri, Feb 20, 2009 at 4:57 AM, oyvind.salt...@gmail.com wrote: > > If a FileField with null=True is

#10244 FileFields can't be set to NULL in the db

2009-02-20 Thread oyvind.salt...@gmail.com
If a FileField with null=True is set to None, the db stores '' in the db and not NULL as I would expect. Also, if a FileField has both blank=True and null=True a ModelForm without a file will save '' in the db, not sure if this is the desired behaviour. So the question is should the behaviour be