Re: Update on localflavor move

2012-10-12 Thread Russell Keith-Magee
On Sat, Oct 13, 2012 at 6:21 AM, Adrian Holovaty wrote: > Hi all, > > We've been talking about moving django.contrib.localflavor into > separate packages, outside of Django proper > (https://groups.google.com/d/topic/django-developers/OiyEGmXTifs/discussion). > Today I did the work of creating the

Update on localflavor move

2012-10-12 Thread Adrian Holovaty
Hi all, We've been talking about moving django.contrib.localflavor into separate packages, outside of Django proper (https://groups.google.com/d/topic/django-developers/OiyEGmXTifs/discussion). Today I did the work of creating the django-localflavor-* packages and copying code/tests/docs to them.

SQLCompiler.as_sql with_col_aliases

2012-10-12 Thread Michael Manfre
Is it safe to assume that the with_col_aliases argument of SQLCompiler.as_sql is intended to only be True when the query is a subquery? Those are the only usages I've found in the code. MSSQL only supports ordering subqueries under a limited number of circumstances. To fix the SQL in django-mss

Re: Schema Alteration update

2012-10-12 Thread Andre Terra
On Fri, Oct 12, 2012 at 4:00 AM, Andrew Godwin wrote: > especially if it's something highly custom internal to a company where you > don't have the time or team to do that stuff properly. > Thank you for highlighting this scenario. Unfortunately, this is usually the case with my one-man projects

Re: save() method could return the object

2012-10-12 Thread Alex Gaynor
On Fri, Oct 12, 2012 at 6:40 AM, Chris Wilson wrote: > On Fri, 12 Oct 2012, Marijonas Petrauskas wrote: > > There already exists create method that does exactly what you need:obj = >> SomeModel.objects.create(name=**'foo', age=42) >> > > OK, thanks, that appears to be completely undocumented. >

Re: save() method could return the object

2012-10-12 Thread Chris Wilson
On Fri, 12 Oct 2012, Marijonas Petrauskas wrote: There already exists create method that does exactly what you need:obj = SomeModel.objects.create(name='foo', age=42) OK, thanks, that appears to be completely undocumented. Cheers, Chris. -- Aptivate | http://www.aptivate.org | Phone: +44 122

Re: save() method could return the object

2012-10-12 Thread Alex Gaynor
On Fri, Oct 12, 2012 at 6:36 AM, Yo-Yo Ma wrote: > +1 > > A lot of people are overriding ``save`` and not returning anything, but > this isn't going to hurt them (ideally, they should already be returning > the result of ``super(``, but nobody does). > > > On Friday, October 12, 2012 9:25:46 AM U

Re: save() method could return the object

2012-10-12 Thread Yo-Yo Ma
+1 A lot of people are overriding ``save`` and not returning anything, but this isn't going to hurt them (ideally, they should already be returning the result of ``super(``, but nobody does). On Friday, October 12, 2012 9:25:46 AM UTC-4, Chris Wilson wrote: > > Hi all, > > If the save() method

Re: A.objects.getdefault

2012-10-12 Thread Chris Wilson
Hi all, On Thu, 11 Oct 2012, Daniel Moisset wrote: obj, = SomeModel.objects.filter(foo='bar') or [None] Daniel's solution is elegant, but far from clear or clean. I'm strongly in favour of a simple, obvious way to do the common thing, which is to return None if the object doesn't exist, ins

Re: save() method could return the object

2012-10-12 Thread Marijonas Petrauskas
There already exists create method that does exactly what you need: obj = SomeModel.objects.create(name='foo', age=42) On Fri, Oct 12, 2012 at 2:33 PM, David Winterbottom < david.winterbot...@tangentlabs.co.uk> wrote: > While such a change is initially appealing, it violates the command-query > s

Re: save() method could return the object

2012-10-12 Thread David Winterbottom
While such a change is initially appealing, it violates the command-query separation principle in that a 'command' method such as 'save' should not return anything. http://en.wikipedia.org/wiki/Command-query_separation Hence, it's not a good idea to make this change. It's more important to have c

save() method could return the object

2012-10-12 Thread Chris Wilson
Hi all, If the save() method returned the object itself, then we could chain it like this: old_status = Status(last_contact=None).save() Instead of having to do this: old_status = Status(last_contact=None) old_status.save() It's a trivial one-line change to the Model

Re: URL dispatcher slow?

2012-10-12 Thread Tom Evans
On Thu, Oct 11, 2012 at 10:58 PM, Ɓukasz Rekucki wrote: > On 11 October 2012 10:20, Russell Keith-Magee wrote: >> >> And don't just say "Why are Django's URL resolvers slow?". Do some >> profiling, and come back with an analysis of where the time is being >> spent and/or wasted. > > FWIW, here's

Re: URL dispatcher slow?

2012-10-12 Thread Moonlight
> FWIW, here's a link to a cProfile result for the mentioned > benchmark[1] on Django 1.4.1 and CPython 2.7.3. A quick look shows > that we're calling get_language() 1.5mln times (read: for every > pattern), so that's definitely going to slow down things. > Happy to see we moved it a bit for

Re: URL dispatcher slow?

2012-10-12 Thread Tom Evans
On Thu, Oct 11, 2012 at 2:53 PM, Tom Evans wrote: > On Wed, Oct 10, 2012 at 7:52 AM, Moonlight wrote: >> Here is an article comparing various URL dispatchers: >> >> http://mindref.blogspot.com/2012/10/python-web-routing-benchmark.html >> >> What cause django URL dispatcher that much... slow? >> >

Re: Schema Alteration update

2012-10-12 Thread Andrew Godwin
I certainly don't want to tread on anyone's toes - the idea will be that, like in South currently, migrations will be enabled/disabled on a per-app basis, so if you don't want them they won't muck stuff up. Alternatively, we could let the other apps override syncdb. I'm hoping, in fact, that addin