Re: DEPs: Django Enhancement Proposals

2014-04-28 Thread Matt
And DEP20 for Django philosophy :}

https://docs.djangoproject.com/en/dev/misc/design-philosophies/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5602f366-9b75-4393-9dab-382e7d6edd8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django explicit `order_by` by ForeignKey field

2014-04-28 Thread alTus
I've already started this topic in django-users (
https://groups.google.com/forum/#!topic/django-users/k9K7VsPe6aA) and got 
an advice there to ask here.
It's not a big issue and it can be solved quite easily as I can see from 
django sources. Also there're some workarounds to deal with it but I write 
here coz I thinks that it makes django behaviour inconsistent.

So we have 2 models:

class Group(models.Model):
name = models.CharField()

class Meta:
ordering = ('name',)

class Entity(models.Model):
group = models.ForeignKey(Group, null=True)

Now I want to perform a really simple query like this (to order by group_id 
field itself):
SELECT * FROM `app_entity` ORDER_BY `app_entity`.`group_id` ASC;

So we use smth like that:
Entity.objects.order_by('group')

and get (not a big surprise, it's well documented behaviour):
SELECT * FROM `app_entity`
LEFT OUTER JOIN `app_group` ON ( `app_entity`.`group_id` = `app_group`.`id` 
)
ORDER BY `app_group`.`name` ASC

The only way to get rid of JOIN is to remove ordering attribute from Group 
Meta class. But it's not a solution coz it's used in many other places.
So the inconsistency is that we have 2 different behaviours with and 
without ordering attribute in related model.
When we don't have ordering defined we can easily order by the field itself 
as well as order by any field in related model if we need to.
While when it's defined we loose the way to order by the field itself 
(still can use extra or even explicitly specify table name but it's all 
quite ugly).

Quite obvious solution is to use `order_by('group_id')` for explicit field 
ordering.
But in django<1.7 trying to order by `order_id` raises FieldError. In 1.7 
order_by('group_id') became identical to order_by('group').
So if 1.7 is released with that new behaviour it will become 
backwards-incompatible to use `order_by('group_id')` for this purpose.

Related topic: #19195 

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/59fa8a5e-7dc0-49f1-a123-6d654efb7d00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django explicit `order_by` by ForeignKey field

2014-04-28 Thread charettes
After discussion this was escalated to a release blocker in order to make 
sure we don't miss the opportunity of fixing it correctly.

I attached a patch to the ticket that makes sure that explicitly ordering 
by a relation source field (group_id in your case) produces the expected 
result.

Simon

Le lundi 28 avril 2014 07:53:02 UTC-4, alTus a écrit :
>
> I've already started this topic in django-users (
> https://groups.google.com/forum/#!topic/django-users/k9K7VsPe6aA) and got 
> an advice there to ask here.
> It's not a big issue and it can be solved quite easily as I can see from 
> django sources. Also there're some workarounds to deal with it but I write 
> here coz I thinks that it makes django behaviour inconsistent.
>
> So we have 2 models:
>
> class Group(models.Model):
> name = models.CharField()
> 
> class Meta:
> ordering = ('name',)
>
> class Entity(models.Model):
> group = models.ForeignKey(Group, null=True)
>
> Now I want to perform a really simple query like this (to order by 
> group_id field itself):
> SELECT * FROM `app_entity` ORDER_BY `app_entity`.`group_id` ASC;
>
> So we use smth like that:
> Entity.objects.order_by('group')
>
> and get (not a big surprise, it's well documented behaviour):
> SELECT * FROM `app_entity`
> LEFT OUTER JOIN `app_group` ON ( `app_entity`.`group_id` = 
> `app_group`.`id` )
> ORDER BY `app_group`.`name` ASC
>
> The only way to get rid of JOIN is to remove ordering attribute from Group 
> Meta class. But it's not a solution coz it's used in many other places.
> So the inconsistency is that we have 2 different behaviours with and 
> without ordering attribute in related model.
> When we don't have ordering defined we can easily order by the field 
> itself as well as order by any field in related model if we need to.
> While when it's defined we loose the way to order by the field itself 
> (still can use extra or even explicitly specify table name but it's all 
> quite ugly).
>
> Quite obvious solution is to use `order_by('group_id')` for explicit field 
> ordering.
> But in django<1.7 trying to order by `order_id` raises FieldError. In 1.7 
> order_by('group_id') became identical to order_by('group').
> So if 1.7 is released with that new behaviour it will become 
> backwards-incompatible to use `order_by('group_id')` for this purpose.
>
> Related topic: #19195 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/63251483-aafc-4009-a921-250d16132172%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANNOUNCE] Django bugfix releases

2014-04-28 Thread James Bennett
Today we've issued releases which remedy a regression reported with last
week's security release.

Details and updated packages are available from the Django project blog:

https://www.djangoproject.com/weblog/2014/apr/28/bugfix-releases-issued/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAL13Cg8w_6b1BgEt3mCVVw4axSbd8Qx00R1F2SiDQTk9Cnq7Ew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django explicit `order_by` by ForeignKey field

2014-04-28 Thread alTus
Wow, that's cool, thanks! As I see it was quite a long running issue.

понедельник, 28 апреля 2014 г., 23:39:53 UTC+4 пользователь charettes 
написал:
>
> After discussion this was escalated to a release blocker in order to make 
> sure we don't miss the opportunity of fixing it correctly.
>
> I attached a patch to the ticket that makes sure that explicitly ordering 
> by a relation source field (group_id in your case) produces the expected 
> result.
>
> Simon
>
> Le lundi 28 avril 2014 07:53:02 UTC-4, alTus a écrit :
>>
>> I've already started this topic in django-users (
>> https://groups.google.com/forum/#!topic/django-users/k9K7VsPe6aA) and 
>> got an advice there to ask here.
>> It's not a big issue and it can be solved quite easily as I can see from 
>> django sources. Also there're some workarounds to deal with it but I write 
>> here coz I thinks that it makes django behaviour inconsistent.
>>
>> So we have 2 models:
>>
>> class Group(models.Model):
>> name = models.CharField()
>> 
>> class Meta:
>> ordering = ('name',)
>>
>> class Entity(models.Model):
>> group = models.ForeignKey(Group, null=True)
>>
>> Now I want to perform a really simple query like this (to order by 
>> group_id field itself):
>> SELECT * FROM `app_entity` ORDER_BY `app_entity`.`group_id` ASC;
>>
>> So we use smth like that:
>> Entity.objects.order_by('group')
>>
>> and get (not a big surprise, it's well documented behaviour):
>> SELECT * FROM `app_entity`
>> LEFT OUTER JOIN `app_group` ON ( `app_entity`.`group_id` = 
>> `app_group`.`id` )
>> ORDER BY `app_group`.`name` ASC
>>
>> The only way to get rid of JOIN is to remove ordering attribute from 
>> Group Meta class. But it's not a solution coz it's used in many other 
>> places.
>> So the inconsistency is that we have 2 different behaviours with and 
>> without ordering attribute in related model.
>> When we don't have ordering defined we can easily order by the field 
>> itself as well as order by any field in related model if we need to.
>> While when it's defined we loose the way to order by the field itself 
>> (still can use extra or even explicitly specify table name but it's all 
>> quite ugly).
>>
>> Quite obvious solution is to use `order_by('group_id')` for explicit 
>> field ordering.
>> But in django<1.7 trying to order by `order_id` raises FieldError. In 1.7 
>> order_by('group_id') became identical to order_by('group').
>> So if 1.7 is released with that new behaviour it will become 
>> backwards-incompatible to use `order_by('group_id')` for this purpose.
>>
>> Related topic: #19195 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c82c7b21-81e4-4c89-84f4-0b75a3ece714%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.