Making QuerySets composable

2016-01-22 Thread Patryk Zawadzki
Hi, Currently the way QuerySets work makes it hard to reuse code. Consider an example where I have template tags to render an author and a book (that in turn displays author). I don't want my template code to execute any additional queries per row displayed so I am forced to prefetch everything up

Re: Making QuerySets composable

2016-01-22 Thread charettes
Hi Patryk, > Currently we have Prefetch objects that kind of solve this problem for M2M > relations but perhaps it would be nice to also be able to use QuerySets in > select_related() or even in filter(). I don't think Prefetch objects are best > suited for that and I personally find having to in

Re: Making QuerySets composable

2016-01-22 Thread Patryk Zawadzki
pt., 22.01.2016 o 17:44 użytkownik charettes napisał: > Hi Patryk, > > > > Currently we have Prefetch objects that kind of solve this problem for > M2M > > relations but perhaps it would be nice to also be able to use QuerySets > in > > select_related() or even in filter(). I don't think Prefetch

Query on BooleanField with values other than True and False, bug or intentional?

2016-01-22 Thread Kaveh Karimi
Today I discovered I can use strings and numbers to query on BooleanFields. Let's say we have the following model: class Whatever(models.Model): name = models.CharField(max_length=200) is_active = models.BooleanField() The following queries return all instances which their `is_active` fi

Re: Query on BooleanField with values other than True and False, bug or intentional?

2016-01-22 Thread Tim Graham
It doesn't seem to me that changing the behavior at this point is worth possible backwards incompatibilities. On Friday, January 22, 2016 at 2:51:41 PM UTC-5, Kaveh wrote: > > Today I discovered I can use strings and numbers to query on BooleanFields. > > Let's say we have the following model: >

Re: SchemaEditor: Alter Default requires column definition

2016-01-22 Thread Tim Graham
What sort of comments are you looking for? On Sunday, January 17, 2016 at 12:47:00 PM UTC-5, Max Bothe wrote: > > Hi all, > > Some databases (like SAP HANA) don't support adding or removing a default > value of a column without redefining the column [1]. > In order to support custom backends for

Re: [Review Request] Added support for database delegated fields (like AutoField)

2016-01-22 Thread Tim Graham
It would be helpful if you could sketch out the proposal a bit more -- maybe write some documentation that explains and motivates the feature (and put explanation in this thread). The pull request description has some explanation but it doesn't seem suited toward someone unfamiliar with the bac

Re: Query on BooleanField with values other than True and False, bug or intentional?

2016-01-22 Thread Maxime Lorant
At least, the behaviour is predictable : it uses `bool(value)`. I believe it is not a bug but more a question about the input definition: should we allow non boolean value? I don't see any problem here accepting a string as a `True` value, it is the job of the user to ensure the value is castabl

Re: Refactor year, month, day lookups?

2016-01-22 Thread Paulo Maciel
+1 Em quarta-feira, 25 de março de 2015 01:24:44 UTC-3, Josh Smeaton escreveu: > > Hi, > > Firstly (and least importantly) opening a PR makes it a lot easier to > review code, especially when there are lots of commits. A [WIP] pull > request is common and useful. If you get a chance, you should

Re: Query on BooleanField with values other than True and False, bug or intentional?

2016-01-22 Thread sbrandt
I agree on the "it is the job of the user" thing as well as on the predictability on IntegerField, but there is at least one case where this goes horribly wrong. Imagine in the web-world we are receiving JSON and for some case, the browser sends "false" as a string. `bool('false') -> True`. One