This file contains 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
def default_3way_compare(v, w): # Yes, this is how Python 2 sorted things :) | |
tv, tw = type(v), type(w) | |
if tv is tw: | |
return -1 if id(v) < id(w) else (1 if id(v) > id(w) else 0) | |
if v is None: | |
return -1 | |
if w is None: | |
return 1 | |
if isinstance(v, (int, float)): | |
vname = '' |
This file contains 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
# in my settings_local.py | |
import datetime | |
import logging | |
from django.http import HttpRequest | |
class TimingHandler(logging.Handler): | |
def __init__(self, *args, **kwargs): |
This file contains 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.conf import settings | |
from django.core.mail.backends.smtp import EmailBackend as SmtpEmailBackend | |
class CustomEmailBackend(SmtpEmailBackend): | |
def _send(self, email_message): | |
if not email_message.recipients(): | |
return False | |
message = email_message.message() | |
try: |
This file contains 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
September 2008 1.0 2.3, 2.4, 2.5, 2.6 | |
July 2009 1.1 2.3, 2.4, 2.5, 2.6 | |
May 2010 1.2 2.4, 2.5, 2.6, 2.7 | |
March 2011 1.3 2.4, 2.5, 2.6, 2.7 | |
March 2012 1.4 2.5, 2.6, 2.7 | |
Feburary 2013 1.5 2.6, 2.7 and 3.2, 3.3 (experimental) | |
November 2013 1.6 2.6, 2.7 and 3.2, 3.3 | |
September 2014 1.7 2.7 and 3.2, 3.3, 3.4 | |
April 2015? 1.8 2.7 and 3.2, 3.3, 3.4 | |
November 2015? 1.9 2.7 and 3.3, 3.4, 3.5 |
This file contains 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
def default_3way_compare(v, w): # Yes, this is how Python 2 sorted things :) | |
if type(v) is type(w): | |
return -1 if id(v) < id(w) else (1 if id(v) > id(w) else 0) | |
if v is None: | |
return -1 | |
if w is None: | |
return 1 | |
if isinstance(v, (int, float)): | |
vname = '' | |
else: |
This file contains 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
====================================================================== | |
ERROR: test_assignment_to_None (model_fields.test_imagefield.ImageFieldNoDimensionsTests) | |
---------------------------------------------------------------------- | |
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/django_sl1wna31/tmppqd5uxrp' | |
====================================================================== | |
ERROR: test_constructor (model_fields.test_imagefield.ImageFieldNoDimensionsTests) | |
---------------------------------------------------------------------- | |
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/django_sl1wna31/tmppqd5uxrp/tests/4x8.png' |
This file contains 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
>>> f = MyForm({'data': 3}) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "django/forms/forms.py", line 84, in __init__ | |
self.label_suffix = label_suffix if label_suffix is not None else _(':') | |
File "django/utils/translation/__init__.py", line 84, in ugettext | |
return _trans.ugettext(message) | |
File "django/utils/translation/__init__.py", line 56, in __getattr__ | |
if settings.USE_I18N: | |
File "django/conf/__init__.py", line 48, in __getattr__ |
This file contains 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
$ manage.py migrate contenttypes | |
Operations to perform: | |
Apply all migrations: contenttypes | |
Running migrations: | |
No migrations to apply. | |
Your models have changes that are not yet reflected in a migration, and so won't be applied. | |
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. | |
Traceback (most recent call last): | |
File "/opt/oneten/ccw/proj/comcenter/manage.py", line 15, in <module> | |
execute_from_command_line(sys.argv) |
This file contains 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
class Matches(models.Model): | |
product_one = models.ForeignKey(Product, related_name = 'product_one') | |
product_two = models.ForeignKey(Product, related_name = 'product_two') | |
class MatchedProducts(APIView): | |
def get(self, request, *args, **kwargs): | |
product_id = kwargs.get('product_id') | |
matched_ids = [] |
This file contains 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
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' | |
if __name__ == '__main__': # command line | |
from django.core.management import execute_from_command_line | |
execute_from_command_line(sys.argv) | |
else: # wsgi | |
from django.core.wsgi import get_wsgi_application | |
application = get_wsgi_application() |
NewerOlder