summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/__init__.py7
-rw-r--r--django/conf/global_settings.py3
-rw-r--r--django/conf/locale/nl/LC_MESSAGES/django.mobin38004 -> 38003 bytes
-rw-r--r--django/conf/locale/nl/LC_MESSAGES/django.po3
-rw-r--r--django/core/management.py13
-rw-r--r--django/db/backends/postgresql/base.py13
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py13
-rw-r--r--django/db/backends/util.py2
-rw-r--r--django/template/defaulttags.py14
-rw-r--r--django/views/debug.py12
10 files changed, 54 insertions, 26 deletions
diff --git a/django/__init__.py b/django/__init__.py
index 7a24af2b4e..17d8c519cc 100644
--- a/django/__init__.py
+++ b/django/__init__.py
@@ -1 +1,8 @@
VERSION = (0, 97, 'pre')
+
+def get_version():
+ "Returns the version as a human-format string."
+ v = '.'.join([str(i) for i in VERSION[:-1]])
+ if VERSION[-1]:
+ v += '-' + VERSION[-1]
+ return v
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 558aaaaa7a..516f9fca31 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -244,7 +244,8 @@ TRANSACTIONS_MANAGED = False
# The User-Agent string to use when checking for URL validity through the
# isExistingURL validator.
-URL_VALIDATOR_USER_AGENT = "Django/0.96pre (http://www.djangoproject.com)"
+from django import get_version
+URL_VALIDATOR_USER_AGENT = "Django/%s (http://www.djangoproject.com)" % get_version()
##############
# MIDDLEWARE #
diff --git a/django/conf/locale/nl/LC_MESSAGES/django.mo b/django/conf/locale/nl/LC_MESSAGES/django.mo
index f4be11f7c5..4c70c28ff4 100644
--- a/django/conf/locale/nl/LC_MESSAGES/django.mo
+++ b/django/conf/locale/nl/LC_MESSAGES/django.mo
Binary files differ
diff --git a/django/conf/locale/nl/LC_MESSAGES/django.po b/django/conf/locale/nl/LC_MESSAGES/django.po
index 89862155d8..9aaeef8af9 100644
--- a/django/conf/locale/nl/LC_MESSAGES/django.po
+++ b/django/conf/locale/nl/LC_MESSAGES/django.po
@@ -2202,10 +2202,11 @@ msgstr[0] "dag"
msgstr[1] "dagen"
#: utils/timesince.py:16
+# In the timesince context it is stilistically wrong to use the plural for hour in Dutch.
msgid "hour"
msgid_plural "hours"
msgstr[0] "uur"
-msgstr[1] "uren"
+msgstr[1] "uur"
#: utils/timesince.py:17
msgid "minute"
diff --git a/django/core/management.py b/django/core/management.py
index a926f683db..fec7fefde4 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -3,14 +3,17 @@
import django
from django.core.exceptions import ImproperlyConfigured
-import os, re, shutil, sys, textwrap
from optparse import OptionParser
from django.utils import termcolors
+import os, re, shutil, sys, textwrap
# For Python 2.3
if not hasattr(__builtins__, 'set'):
from sets import Set as set
+# For backwards compatibility: get_version() used to be in this module.
+get_version = django.get_version
+
MODULE_TEMPLATE = ''' {%% if perms.%(app)s.%(addperm)s or perms.%(app)s.%(changeperm)s %%}
<tr>
<th>{%% if perms.%(app)s.%(changeperm)s %%}<a href="%(app)s/%(mod)s/">{%% endif %%}%(name)s{%% if perms.%(app)s.%(changeperm)s %%}</a>{%% endif %%}</th>
@@ -93,14 +96,6 @@ def _get_sequence_list():
# field as the field to which it points.
get_rel_data_type = lambda f: (f.get_internal_type() in ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' or f.get_internal_type()
-def get_version():
- "Returns the version as a human-format string."
- from django import VERSION
- v = '.'.join([str(i) for i in VERSION[:-1]])
- if VERSION[-1]:
- v += '-' + VERSION[-1]
- return v
-
def get_sql_create(app):
"Returns a list of the CREATE TABLE SQL statements for the given app."
from django.db import get_creation_module, models
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index 912d49b493..2186fa3863 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -239,22 +239,27 @@ def get_sql_sequence_reset(style, model_list):
from django.db import models
output = []
for model in model_list:
+ # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
+ # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
+ # if there are records (as the max pk value is already in use), otherwise set it to false.
for f in model._meta.fields:
if isinstance(f, models.AutoField):
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(quote_name(model._meta.db_table))))
break # Only one AutoField is allowed per model, so don't bother continuing.
for f in model._meta.many_to_many:
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('id')),
+ style.SQL_FIELD(quote_name('id')),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(f.m2m_db_table())))
return output
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index d9a850957c..764e3a34f3 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -180,22 +180,27 @@ def get_sql_sequence_reset(style, model_list):
from django.db import models
output = []
for model in model_list:
+ # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
+ # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
+ # if there are records (as the max pk value is already in use), otherwise set it to false.
for f in model._meta.fields:
if isinstance(f, models.AutoField):
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(quote_name(model._meta.db_table))))
break # Only one AutoField is allowed per model, so don't bother continuing.
for f in model._meta.many_to_many:
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('id')),
+ style.SQL_FIELD(quote_name('id')),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(f.m2m_db_table())))
return output
diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index 9f75ff2844..fd0f6598a7 100644
--- a/django/db/backends/util.py
+++ b/django/db/backends/util.py
@@ -98,7 +98,7 @@ def typecast_boolean(s):
return str(s)[0].lower() == 't'
def typecast_decimal(s):
- if s is None:
+ if s is None or s == '':
return None
return decimal.Decimal(s)
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 3624d511fd..83ad8272d4 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -8,6 +8,14 @@ from django.utils.encoding import smart_str, smart_unicode
import sys
import re
+if not hasattr(__builtins__, 'reversed'):
+ # For Python 2.3.
+ # From http://www.python.org/doc/current/tut/node11.html
+ def reversed(data):
+ for index in xrange(len(data)-1, -1, -1):
+ yield data[index]
+
+
register = Library()
class CommentNode(Node):
@@ -104,11 +112,7 @@ class ForNode(Node):
values = list(values)
len_values = len(values)
if self.reversed:
- # From http://www.python.org/doc/current/tut/node11.html
- def reverse(data):
- for index in range(len(data)-1, -1, -1):
- yield data[index]
- values = reverse(values)
+ values = reversed(values)
unpack = len(self.loopvars) > 1
for i, item in enumerate(values):
context['forloop'] = {
diff --git a/django/views/debug.py b/django/views/debug.py
index 07a9fd9cee..d2efe76072 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -3,7 +3,7 @@ from django.template import Template, Context, TemplateDoesNotExist
from django.utils.html import escape
from django.http import HttpResponseServerError, HttpResponseNotFound
from django.utils.encoding import smart_unicode
-import os, re
+import os, re, sys
HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST')
@@ -132,6 +132,8 @@ def technical_500_response(request, exc_type, exc_value, tb):
'request': request,
'request_protocol': request.is_secure() and "https" or "http",
'settings': get_safe_settings(),
+ 'sys_executable' : sys.executable,
+ 'sys_version_info' : '%d.%d.%d' % sys.version_info[0:3],
'template_info': template_info,
'template_does_not_exist': template_does_not_exist,
'loader_debug_info': loader_debug_info,
@@ -346,6 +348,14 @@ TECHNICAL_500_TEMPLATE = """
<th>Exception Location:</th>
<td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
</tr>
+ <tr>
+ <th>Python Executable:</th>
+ <td>{{ sys_executable|escape }}</td>
+ </tr>
+ <tr>
+ <th>Python Version:</th>
+ <td>{{ sys_version_info }}</td>
+ </tr>
</table>
</div>
{% if template_does_not_exist %}