Skip to content

Instantly share code, notes, and snippets.

View claudep's full-sized avatar

Claude Paroz claudep

View GitHub Profile
@claudep
claudep / 27895.diff
Created March 7, 2017 16:14
Test for #27895
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index c9dffdb..0233786 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -1200,6 +1200,21 @@ class RequestMethodStringDataTests(SimpleTestCase):
response = self.client.get('/json_response/')
self.assertEqual(response.json(), {'key': 'value'})
+ def test_json_non_ascii(self):
+ """Test with both escaped and non-escaped UTF-8 content."""
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 48b5737..145adf5 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2483,6 +2483,19 @@ class ToFieldTests(TestCase):
[node1]
)
+ def test_isnull_query(self):
+ apple = Food.objects.create(name="apple")
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 87c3adf..49bdb32 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -144,9 +144,8 @@ class UserManager(BaseUserManager):
"""
if not username:
raise ValueError('The given username must be set')
- email = self.normalize_email(email)
- username = self.normalize_username(username)
@claudep
claudep / 21523.diff
Last active April 18, 2016 08:19
Django issue #21523
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index a4018dd..5acf520 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -1286,14 +1286,14 @@ class DateField(DateTimeCheckMixin, Field):
def to_python(self, value):
if value is None:
return value
- if isinstance(value, datetime.datetime):
+ if hasattr(value, 'tzinfo') and hasattr(value, 'date'):
@claudep
claudep / gist:aa1edac079866a482510
Created September 25, 2015 18:21
Patch for #19631
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index c2c4d84..bdce73b 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
import copy
import operator
from collections import OrderedDict
@claudep
claudep / gist:455819983e3eb63649ca
Created August 17, 2015 18:09
Removed some imports
diff --git a/translate/storage/placeables/__init__.py b/translate/storage/placeables/__init__.py
index fd062c5..094e513 100644
--- a/translate/storage/placeables/__init__.py
+++ b/translate/storage/placeables/__init__.py
@@ -45,16 +45,6 @@ The placeables model follows the XLIFF standard's list of placeables.
Please refer to the XLIFF specification to get a better understanding.
"""
-from . import base
-from . import interfaces
@claudep
claudep / save_restore_dependencies.sql
Last active February 23, 2024 06:09 — forked from mateuszwenus/save_restore_dependencies.sql
Replaced quotes by quote_ident
create table if not exists deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
deps_view_name varchar(255),
deps_ddl_to_run text
);
create or replace function deps_save_and_drop_dependencies(p_view_schema varchar, p_view_name varchar) returns void as
$$
class BDNMiddleware(object):
def process_exception(self, request, exception):
"""include authenticated user email in request.META"""
if request.user.is_authenticated():
request.META['USER_EMAIL'] = request.user.email
diff --git a/django/db/models/base.py b/django/db/models/base.py
index c2f711e..dedfbee 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1659,6 +1659,8 @@ def model_unpickle(model_id, attrs, factory):
Used to unpickle Model subclasses with deferred fields.
"""
if isinstance(model_id, tuple):
+ if not apps.ready:
+ apps.populate(settings.INSTALLED_APPS)
WSGIDaemonProcess localehelper python-path=/var/www/localehelper:/var/www/virtualenvs/localehelper/lib/python2.7/site-packages display-name=%{GROUP}
WSGIProcessGroup localehelper
WSGIScriptAlias / /var/www/localehelper/common/wsgi.py