This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connection | |
class QueryCountMiddleware(object): | |
def process_response(self, request, response): | |
duration = 0 | |
for query in connection.queries: | |
duration += float(query['time']) | |
print ('%s\n' % query['sql']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If I remember well, we discussed at some point with you and charettes about | |
removing the string version (as opposed to callable) of RunPython, if we do it, | |
it may be better to do it early on in the release cycle. | |
For some reason MyModel.objects.create() returned an object with pk=None, | |
I could confirm the object was created with a call to MyModel.objects.all(). | |
I'm not totally sure if it's a bug or a side effect of the fake ORM. | |
I was bitten quite badly by the fact that custom Manager and custom save() | |
methods aren't called, https://github.com/django/django/blob/master/docs/topics/migrations.txt#L296-L297 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_tb() | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 249, in remove | |
del self.data[k] | |
print_exc() | |
Traceback (most recent call last): | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 249, in remove | |
del self.data[k] | |
KeyError: <weakref at 0x10eeeb310; dead> | |
print_tb() | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 249, in remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WeakKeyDictionary | |
Traceback (most recent call last): | |
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 260, in remove | |
del self.data[k] | |
KeyError: <weakref at 0x10be01a48; dead> | |
self.data: | |
{} | |
k: | |
<weakref at 0x10be01a48; dead> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example test settings file for use with the Django test suite. | |
# | |
# The 'sqlite3' backend requires only the ENGINE setting (an in- | |
# memory database will be used). All other backends will require a | |
# NAME and potentially authentication information. See the | |
# following section in the docs for more information: | |
# | |
# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ | |
# | |
# The different databases that Django supports behave differently in certain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example test settings file for use with the Django test suite. | |
# | |
# The 'sqlite3' backend requires only the ENGINE setting (an in- | |
# memory database will be used). All other backends will require a | |
# NAME and potentially authentication information. See the | |
# following section in the docs for more information: | |
# | |
# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ | |
# | |
# The different databases that Django supports behave differently in certain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example test settings file for use with the Django test suite. | |
# | |
# The 'sqlite3' backend requires only the ENGINE setting (an in- | |
# memory database will be used). All other backends will require a | |
# NAME and potentially authentication information. See the | |
# following section in the docs for more information: | |
# | |
# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ | |
# | |
# The different databases that Django supports behave differently in certain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ML thread: | |
https://groups.google.com/d/topic/django-developers/hVTLAp_jLzQ/discussion | |
2013-10-03: | |
20:15 loic84: akaariai: what's your opinion no the recent ML thread regarding custom index types? | |
20:18 akaariai: loic84: write the SQL by hand... Or, maybe you could have a VirtualField that just creates indexes for you. | |
20:20 loic84: akaariai: I've been thinking about integrating PG arrays and JSON support in my projects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/manager.py b/django/db/models/manager.py | |
index 4a080e9..fa1e870 100644 | |
--- a/django/db/models/manager.py | |
+++ b/django/db/models/manager.py | |
@@ -190,10 +190,9 @@ class BaseManager(six.with_metaclass(RenameManagerMethods)): | |
# understanding of how this comes into play. | |
return self.get_queryset() | |
-Manager = BaseManager.from_queryset(QuerySet, class_name='Manager') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/manager.py b/django/db/models/manager.py | |
index 4a080e9..24f9d95 100644 | |
--- a/django/db/models/manager.py | |
+++ b/django/db/models/manager.py | |
@@ -196,6 +196,14 @@ Manager = BaseManager.from_queryset(QuerySet, class_name='Manager') | |
Manager.__module__ = 'django.db.models.manager' | |
+class CustomQuerySet(QuerySet): | |
+ pass |