mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
gis: Merged revisions 6000-6020 via svnmerge from [repos:django/trunk trunk].
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6021 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2052b508eb
commit
cb64f5375c
1
AUTHORS
1
AUTHORS
@ -94,6 +94,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Alex Dedul
|
Alex Dedul
|
||||||
deric@monowerks.com
|
deric@monowerks.com
|
||||||
Max Derkachev <mderk@yandex.ru>
|
Max Derkachev <mderk@yandex.ru>
|
||||||
|
Sander Dijkhuis <sander.dijkhuis@gmail.com>
|
||||||
Jordan Dimov <s3x3y1@gmail.com>
|
Jordan Dimov <s3x3y1@gmail.com>
|
||||||
dne@mayonnaise.net
|
dne@mayonnaise.net
|
||||||
Maximillian Dornseif <md@hudora.de>
|
Maximillian Dornseif <md@hudora.de>
|
||||||
|
@ -6,7 +6,7 @@ var SelectBox = {
|
|||||||
SelectBox.cache[id] = new Array();
|
SelectBox.cache[id] = new Array();
|
||||||
var cache = SelectBox.cache[id];
|
var cache = SelectBox.cache[id];
|
||||||
for (var i = 0; (node = box.options[i]); i++) {
|
for (var i = 0; (node = box.options[i]); i++) {
|
||||||
cache.push({ value: node.value, text: node.text, displayed: 1 });
|
cache.push({value: node.value, text: node.text, displayed: 1});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
redisplay: function(id) {
|
redisplay: function(id) {
|
||||||
@ -50,7 +50,7 @@ var SelectBox = {
|
|||||||
SelectBox.cache[id].length--;
|
SelectBox.cache[id].length--;
|
||||||
},
|
},
|
||||||
add_to_cache: function(id, option) {
|
add_to_cache: function(id, option) {
|
||||||
SelectBox.cache[id].push({ value: option.value, text: option.text, displayed: 1 });
|
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
|
||||||
},
|
},
|
||||||
cache_contains: function(id, value) {
|
cache_contains: function(id, value) {
|
||||||
// Check if an item is contained in the cache
|
// Check if an item is contained in the cache
|
||||||
@ -68,7 +68,7 @@ var SelectBox = {
|
|||||||
var option;
|
var option;
|
||||||
for (var i = 0; (option = from_box.options[i]); i++) {
|
for (var i = 0; (option = from_box.options[i]); i++) {
|
||||||
if (option.selected && SelectBox.cache_contains(from, option.value)) {
|
if (option.selected && SelectBox.cache_contains(from, option.value)) {
|
||||||
SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 });
|
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
||||||
SelectBox.delete_from_cache(from, option.value);
|
SelectBox.delete_from_cache(from, option.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,8 +80,10 @@ var SelectBox = {
|
|||||||
var to_box = document.getElementById(to);
|
var to_box = document.getElementById(to);
|
||||||
var option;
|
var option;
|
||||||
for (var i = 0; (option = from_box.options[i]); i++) {
|
for (var i = 0; (option = from_box.options[i]); i++) {
|
||||||
SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 });
|
if (SelectBox.cache_contains(from, option.value)) {
|
||||||
SelectBox.delete_from_cache(from, option.value);
|
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
|
||||||
|
SelectBox.delete_from_cache(from, option.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SelectBox.redisplay(from);
|
SelectBox.redisplay(from);
|
||||||
SelectBox.redisplay(to);
|
SelectBox.redisplay(to);
|
||||||
|
@ -17,7 +17,7 @@ def login(request, template_name='registration/login.html'):
|
|||||||
errors = manipulator.get_validation_errors(request.POST)
|
errors = manipulator.get_validation_errors(request.POST)
|
||||||
if not errors:
|
if not errors:
|
||||||
# Light security check -- make sure redirect_to isn't garbage.
|
# Light security check -- make sure redirect_to isn't garbage.
|
||||||
if not redirect_to or '://' in redirect_to or ' ' in redirect_to:
|
if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
redirect_to = settings.LOGIN_REDIRECT_URL
|
redirect_to = settings.LOGIN_REDIRECT_URL
|
||||||
from django.contrib.auth import login
|
from django.contrib.auth import login
|
||||||
|
@ -51,7 +51,6 @@ class SpatialRefSysTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test03_ellipsoid(self):
|
def test03_ellipsoid(self):
|
||||||
"Testing the ellipsoid property."
|
"Testing the ellipsoid property."
|
||||||
return
|
|
||||||
for sd in test_srs:
|
for sd in test_srs:
|
||||||
# Getting the ellipsoid and precision parameters.
|
# Getting the ellipsoid and precision parameters.
|
||||||
ellps1 = sd['ellipsoid']
|
ellps1 = sd['ellipsoid']
|
||||||
|
@ -24,7 +24,7 @@ class Command(NoArgsCommand):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
sql_list = sql_flush(self.style)
|
sql_list = sql_flush(self.style, only_django=True)
|
||||||
|
|
||||||
if interactive:
|
if interactive:
|
||||||
confirm = raw_input("""You have requested a flush of the database.
|
confirm = raw_input("""You have requested a flush of the database.
|
||||||
|
@ -30,7 +30,7 @@ class Command(BaseCommand):
|
|||||||
raise CommandError("%r is not a valid port number." % port)
|
raise CommandError("%r is not a valid port number." % port)
|
||||||
|
|
||||||
use_reloader = options.get('use_reloader', True)
|
use_reloader = options.get('use_reloader', True)
|
||||||
admin_media_dir = options.get('admin_media_dir', '')
|
admin_media_path = options.get('admin_media_path', '')
|
||||||
shutdown_message = options.get('shutdown_message', '')
|
shutdown_message = options.get('shutdown_message', '')
|
||||||
quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
|
quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class Command(BaseCommand):
|
|||||||
print "Development server is running at http://%s:%s/" % (addr, port)
|
print "Development server is running at http://%s:%s/" % (addr, port)
|
||||||
print "Quit the server with %s." % quit_command
|
print "Quit the server with %s." % quit_command
|
||||||
try:
|
try:
|
||||||
path = admin_media_dir or django.__path__[0] + '/contrib/admin/media'
|
path = admin_media_path or django.__path__[0] + '/contrib/admin/media'
|
||||||
handler = AdminMediaHandler(WSGIHandler(), path)
|
handler = AdminMediaHandler(WSGIHandler(), path)
|
||||||
run(addr, int(port), handler)
|
run(addr, int(port), handler)
|
||||||
except WSGIServerException, e:
|
except WSGIServerException, e:
|
||||||
|
@ -7,4 +7,4 @@ class Command(NoArgsCommand):
|
|||||||
|
|
||||||
def handle_noargs(self, **options):
|
def handle_noargs(self, **options):
|
||||||
from django.core.management.sql import sql_flush
|
from django.core.management.sql import sql_flush
|
||||||
return '\n'.join(sql_flush(self.style))
|
return '\n'.join(sql_flush(self.style, only_django=True))
|
||||||
|
@ -13,6 +13,25 @@ def table_list():
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
return get_introspection_module().get_table_list(cursor)
|
return get_introspection_module().get_table_list(cursor)
|
||||||
|
|
||||||
|
def django_table_list(only_existing=False):
|
||||||
|
"""
|
||||||
|
Returns a list of all table names that have associated Django models and
|
||||||
|
are in INSTALLED_APPS.
|
||||||
|
|
||||||
|
If only_existing is True, the resulting list will only include the tables
|
||||||
|
that actually exist in the database.
|
||||||
|
"""
|
||||||
|
from django.db import models
|
||||||
|
tables = []
|
||||||
|
for app in models.get_apps():
|
||||||
|
for model in models.get_models(app):
|
||||||
|
tables.append(model._meta.db_table)
|
||||||
|
tables.extend([f.m2m_db_table() for f in model._meta.many_to_many])
|
||||||
|
if only_existing:
|
||||||
|
existing = table_list()
|
||||||
|
tables = [t for t in tables if t in existing]
|
||||||
|
return tables
|
||||||
|
|
||||||
def installed_models(table_list):
|
def installed_models(table_list):
|
||||||
"Returns a set of all models that are installed, given a list of existing table names."
|
"Returns a set of all models that are installed, given a list of existing table names."
|
||||||
from django.db import connection, models
|
from django.db import connection, models
|
||||||
@ -181,10 +200,19 @@ def sql_reset(app, style):
|
|||||||
"Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module."
|
"Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module."
|
||||||
return sql_delete(app, style) + sql_all(app, style)
|
return sql_delete(app, style) + sql_all(app, style)
|
||||||
|
|
||||||
def sql_flush(style):
|
def sql_flush(style, only_django=False):
|
||||||
"Returns a list of the SQL statements used to flush the database."
|
"""
|
||||||
|
Returns a list of the SQL statements used to flush the database.
|
||||||
|
|
||||||
|
If only_django is True, then only table names that have associated Django
|
||||||
|
models and are in INSTALLED_APPS will be included.
|
||||||
|
"""
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
statements = connection.ops.sql_flush(style, table_list(), sequence_list())
|
if only_django:
|
||||||
|
tables = django_table_list()
|
||||||
|
else:
|
||||||
|
tables = table_list()
|
||||||
|
statements = connection.ops.sql_flush(style, tables, sequence_list())
|
||||||
return statements
|
return statements
|
||||||
|
|
||||||
def sql_custom(app, style):
|
def sql_custom(app, style):
|
||||||
|
@ -8,6 +8,7 @@ ImproperlyConfigured.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations
|
||||||
|
|
||||||
def complain(*args, **kwargs):
|
def complain(*args, **kwargs):
|
||||||
raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet."
|
raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet."
|
||||||
@ -21,13 +22,12 @@ class DatabaseError(Exception):
|
|||||||
class IntegrityError(DatabaseError):
|
class IntegrityError(DatabaseError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ComplainOnGetattr(object):
|
class DatabaseOperations(BaseDatabaseOperations):
|
||||||
def __getattr__(self, *args, **kwargs):
|
quote_name = complain
|
||||||
complain()
|
|
||||||
|
|
||||||
class DatabaseWrapper(object):
|
class DatabaseWrapper(object):
|
||||||
features = ComplainOnGetattr()
|
features = BaseDatabaseFeatures()
|
||||||
ops = ComplainOnGetattr()
|
ops = DatabaseOperations()
|
||||||
operators = {}
|
operators = {}
|
||||||
cursor = complain
|
cursor = complain
|
||||||
_commit = complain
|
_commit = complain
|
||||||
|
@ -102,9 +102,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
|
cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
|
||||||
cursor.execute("SET client_encoding to 'UNICODE'")
|
cursor.execute("SET client_encoding to 'UNICODE'")
|
||||||
cursor = UnicodeCursorWrapper(cursor, 'utf-8')
|
cursor = UnicodeCursorWrapper(cursor, 'utf-8')
|
||||||
if self.ops.postgres_version is None:
|
|
||||||
cursor.execute("SELECT version()")
|
|
||||||
self.ops.postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
|
|
||||||
return cursor
|
return cursor
|
||||||
|
|
||||||
def typecast_string(s):
|
def typecast_string(s):
|
||||||
|
@ -4,8 +4,17 @@ from django.db.backends import BaseDatabaseOperations
|
|||||||
# used by both the 'postgresql' and 'postgresql_psycopg2' backends.
|
# used by both the 'postgresql' and 'postgresql_psycopg2' backends.
|
||||||
|
|
||||||
class DatabaseOperations(BaseDatabaseOperations):
|
class DatabaseOperations(BaseDatabaseOperations):
|
||||||
def __init__(self, postgres_version=None):
|
def __init__(self):
|
||||||
self.postgres_version = postgres_version
|
self._postgres_version = None
|
||||||
|
|
||||||
|
def _get_postgres_version(self):
|
||||||
|
if self._postgres_version is None:
|
||||||
|
from django.db import connection
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute("SELECT version()")
|
||||||
|
self._postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
|
||||||
|
return self._postgres_version
|
||||||
|
postgres_version = property(_get_postgres_version)
|
||||||
|
|
||||||
def date_extract_sql(self, lookup_type, field_name):
|
def date_extract_sql(self, lookup_type, field_name):
|
||||||
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
|
# http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
|
||||||
@ -52,28 +61,14 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||||||
for sequence_info in sequences:
|
for sequence_info in sequences:
|
||||||
table_name = sequence_info['table']
|
table_name = sequence_info['table']
|
||||||
column_name = sequence_info['column']
|
column_name = sequence_info['column']
|
||||||
if column_name and len(column_name)>0:
|
if column_name and len(column_name) > 0:
|
||||||
# sequence name in this case will be <table>_<column>_seq
|
sequence_name = '%s_%s_seq' % (table_name, column_name)
|
||||||
sql.append("%s %s %s %s %s %s;" % \
|
|
||||||
(style.SQL_KEYWORD('ALTER'),
|
|
||||||
style.SQL_KEYWORD('SEQUENCE'),
|
|
||||||
style.SQL_FIELD(self.quote_name('%s_%s_seq' % (table_name, column_name))),
|
|
||||||
style.SQL_KEYWORD('RESTART'),
|
|
||||||
style.SQL_KEYWORD('WITH'),
|
|
||||||
style.SQL_FIELD('1')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
# sequence name in this case will be <table>_id_seq
|
sequence_name = '%s_id_seq' % table_name
|
||||||
sql.append("%s %s %s %s %s %s;" % \
|
sql.append("%s setval('%s', 1, false);" % \
|
||||||
(style.SQL_KEYWORD('ALTER'),
|
(style.SQL_KEYWORD('SELECT'),
|
||||||
style.SQL_KEYWORD('SEQUENCE'),
|
style.SQL_FIELD(self.quote_name(sequence_name)))
|
||||||
style.SQL_FIELD(self.quote_name('%s_id_seq' % table_name)),
|
)
|
||||||
style.SQL_KEYWORD('RESTART'),
|
|
||||||
style.SQL_KEYWORD('WITH'),
|
|
||||||
style.SQL_FIELD('1')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return sql
|
return sql
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
@ -64,7 +64,4 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
cursor.tzinfo_factory = None
|
cursor.tzinfo_factory = None
|
||||||
if set_tz:
|
if set_tz:
|
||||||
cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
|
cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
|
||||||
if self.ops.postgres_version is None:
|
|
||||||
cursor.execute("SELECT version()")
|
|
||||||
self.ops.postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
|
|
||||||
return cursor
|
return cursor
|
||||||
|
@ -355,8 +355,8 @@ def unordered_list(value):
|
|||||||
Recursively takes a self-nested list and returns an HTML unordered list --
|
Recursively takes a self-nested list and returns an HTML unordered list --
|
||||||
WITHOUT opening and closing <ul> tags.
|
WITHOUT opening and closing <ul> tags.
|
||||||
|
|
||||||
The list is assumed to be in the proper format. For example, if ``var`` contains
|
The list is assumed to be in the proper format. For example, if ``var``
|
||||||
``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``,
|
contains: ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``,
|
||||||
then ``{{ var|unordered_list }}`` would return::
|
then ``{{ var|unordered_list }}`` would return::
|
||||||
|
|
||||||
<li>States
|
<li>States
|
||||||
@ -371,14 +371,61 @@ def unordered_list(value):
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
"""
|
"""
|
||||||
def _helper(value, tabs):
|
def convert_old_style_list(list_):
|
||||||
|
"""
|
||||||
|
Converts old style lists to the new easier to understand format.
|
||||||
|
|
||||||
|
The old list format looked like:
|
||||||
|
['Item 1', [['Item 1.1', []], ['Item 1.2', []]]
|
||||||
|
|
||||||
|
And it is converted to:
|
||||||
|
['Item 1', ['Item 1.1', 'Item 1.2]]
|
||||||
|
"""
|
||||||
|
if not isinstance(list_, (tuple, list)) or len(list_) != 2:
|
||||||
|
return list_, False
|
||||||
|
first_item, second_item = list_
|
||||||
|
if second_item == []:
|
||||||
|
return [first_item], True
|
||||||
|
old_style_list = True
|
||||||
|
new_second_item = []
|
||||||
|
for sublist in second_item:
|
||||||
|
item, old_style_list = convert_old_style_list(sublist)
|
||||||
|
if not old_style_list:
|
||||||
|
break
|
||||||
|
new_second_item.extend(item)
|
||||||
|
if old_style_list:
|
||||||
|
second_item = new_second_item
|
||||||
|
return [first_item, second_item], old_style_list
|
||||||
|
def _helper(list_, tabs=1):
|
||||||
indent = u'\t' * tabs
|
indent = u'\t' * tabs
|
||||||
if value[1]:
|
output = []
|
||||||
return u'%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, force_unicode(value[0]), indent,
|
|
||||||
u'\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent)
|
list_length = len(list_)
|
||||||
else:
|
i = 0
|
||||||
return u'%s<li>%s</li>' % (indent, force_unicode(value[0]))
|
while i < list_length:
|
||||||
return _helper(value, 1)
|
title = list_[i]
|
||||||
|
sublist = ''
|
||||||
|
sublist_item = None
|
||||||
|
if isinstance(title, (list, tuple)):
|
||||||
|
sublist_item = title
|
||||||
|
title = ''
|
||||||
|
elif i < list_length - 1:
|
||||||
|
next_item = list_[i+1]
|
||||||
|
if next_item and isinstance(next_item, (list, tuple)):
|
||||||
|
# The next item is a sub-list.
|
||||||
|
sublist_item = next_item
|
||||||
|
# We've processed the next item now too.
|
||||||
|
i += 1
|
||||||
|
if sublist_item:
|
||||||
|
sublist = _helper(sublist_item, tabs+1)
|
||||||
|
sublist = '\n%s<ul>\n%s\n%s</ul>\n%s' % (indent, sublist,
|
||||||
|
indent, indent)
|
||||||
|
output.append('%s<li>%s%s</li>' % (indent, force_unicode(title),
|
||||||
|
sublist))
|
||||||
|
i += 1
|
||||||
|
return '\n'.join(output)
|
||||||
|
value, converted = convert_old_style_list(value)
|
||||||
|
return _helper(value)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# INTEGERS #
|
# INTEGERS #
|
||||||
|
@ -207,14 +207,23 @@ the database until you explicitly call ``save()``.
|
|||||||
|
|
||||||
The ``save()`` method has no return value.
|
The ``save()`` method has no return value.
|
||||||
|
|
||||||
Updating ``ForeignKey`` fields works exactly the same way; simply assign an
|
Saving ForeignKey and ManyToManyField fields
|
||||||
object of the right type to the field in question::
|
--------------------------------------------
|
||||||
|
|
||||||
joe = Author.objects.create(name="Joe")
|
Updating ``ForeignKey`` fields works exactly the same way as saving a normal
|
||||||
entry.author = joe
|
field; simply assign an object of the right type to the field in question::
|
||||||
|
|
||||||
|
cheese_blog = Blog.objects.get(name="Cheddar Talk")
|
||||||
|
entry.blog = cheese_blog
|
||||||
entry.save()
|
entry.save()
|
||||||
|
|
||||||
Django will complain if you try to assign an object of the wrong type.
|
Updating a ``ManyToManyField`` works a little differently; use the ``add()``
|
||||||
|
method on the field to add a record to the relation::
|
||||||
|
|
||||||
|
joe = Author.objects.create(name="Joe")
|
||||||
|
entry.authors.add(joe)
|
||||||
|
|
||||||
|
Django will complain if you try to assign or add an object of the wrong type.
|
||||||
|
|
||||||
How Django knows to UPDATE vs. INSERT
|
How Django knows to UPDATE vs. INSERT
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
@ -124,6 +124,13 @@ executed. This means that all data will be removed from the database, any
|
|||||||
post-synchronization handlers will be re-executed, and the ``initial_data``
|
post-synchronization handlers will be re-executed, and the ``initial_data``
|
||||||
fixture will be re-installed.
|
fixture will be re-installed.
|
||||||
|
|
||||||
|
The behavior of this command has changed in the Django development version.
|
||||||
|
Previously, this command cleared *every* table in the database, including any
|
||||||
|
table that Django didn't know about (i.e., tables that didn't have associated
|
||||||
|
models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears
|
||||||
|
tables that are represented by Django models and are activated in
|
||||||
|
``INSTALLED_APPS``.
|
||||||
|
|
||||||
inspectdb
|
inspectdb
|
||||||
---------
|
---------
|
||||||
|
|
||||||
@ -240,6 +247,7 @@ Executes the equivalent of ``sqlreset`` for the given appnames.
|
|||||||
|
|
||||||
runfcgi [options]
|
runfcgi [options]
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
Starts a set of FastCGI processes suitable for use with any web server
|
Starts a set of FastCGI processes suitable for use with any web server
|
||||||
which supports the FastCGI protocol. See the `FastCGI deployment
|
which supports the FastCGI protocol. See the `FastCGI deployment
|
||||||
documentation`_ for details. Requires the Python FastCGI module from
|
documentation`_ for details. Requires the Python FastCGI module from
|
||||||
@ -337,7 +345,7 @@ Refer to the description of ``sqlcustom`` for an explanation of how to
|
|||||||
specify initial data.
|
specify initial data.
|
||||||
|
|
||||||
sqlclear [appname appname ...]
|
sqlclear [appname appname ...]
|
||||||
--------------------------------------
|
------------------------------
|
||||||
|
|
||||||
Prints the DROP TABLE SQL statements for the given appnames.
|
Prints the DROP TABLE SQL statements for the given appnames.
|
||||||
|
|
||||||
@ -360,18 +368,23 @@ table modifications, or insert any SQL functions into the database.
|
|||||||
|
|
||||||
Note that the order in which the SQL files are processed is undefined.
|
Note that the order in which the SQL files are processed is undefined.
|
||||||
|
|
||||||
|
sqlflush
|
||||||
|
--------
|
||||||
|
|
||||||
|
Prints the SQL statements that would be executed for the `flush`_ command.
|
||||||
|
|
||||||
sqlindexes [appname appname ...]
|
sqlindexes [appname appname ...]
|
||||||
----------------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Prints the CREATE INDEX SQL statements for the given appnames.
|
Prints the CREATE INDEX SQL statements for the given appnames.
|
||||||
|
|
||||||
sqlreset [appname appname ...]
|
sqlreset [appname appname ...]
|
||||||
--------------------------------------
|
------------------------------
|
||||||
|
|
||||||
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames.
|
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames.
|
||||||
|
|
||||||
sqlsequencereset [appname appname ...]
|
sqlsequencereset [appname appname ...]
|
||||||
----------------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
Prints the SQL statements for resetting sequences for the given
|
Prints the SQL statements for resetting sequences for the given
|
||||||
appnames.
|
appnames.
|
||||||
@ -466,6 +479,9 @@ This is useful in a number of ways:
|
|||||||
Note that this server can only run on the default port on localhost; it does
|
Note that this server can only run on the default port on localhost; it does
|
||||||
not yet accept a ``host`` or ``port`` parameter.
|
not yet accept a ``host`` or ``port`` parameter.
|
||||||
|
|
||||||
|
Also note that it does *not* automatically detect changes to your Python source
|
||||||
|
code (as ``runserver`` does). It does, however, detect changes to templates.
|
||||||
|
|
||||||
.. _unit tests: ../testing/
|
.. _unit tests: ../testing/
|
||||||
|
|
||||||
validate
|
validate
|
||||||
|
@ -204,10 +204,6 @@ out a few points, we want to make sure they reflect the final state of things
|
|||||||
at Django 1.0, not some intermediary step. In other words, we don't want to
|
at Django 1.0, not some intermediary step. In other words, we don't want to
|
||||||
spend a lot of energy creating screencasts yet, because Django APIs will shift.
|
spend a lot of energy creating screencasts yet, because Django APIs will shift.
|
||||||
|
|
||||||
In the meantime, though, check out this `unofficial Django screencast`_.
|
|
||||||
|
|
||||||
.. _unofficial Django screencast: http://www.throwingbeans.org/django_screencasts.html
|
|
||||||
|
|
||||||
Is Django a content-management-system (CMS)?
|
Is Django a content-management-system (CMS)?
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ development version. See the `Django 0.96 documentation`_ for the old behavior.
|
|||||||
``ImageField``
|
``ImageField``
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Like ``FileField``, but validates that the uploaded object is a valid
|
Like `FileField`_, but validates that the uploaded object is a valid
|
||||||
image. Has two extra optional arguments, ``height_field`` and
|
image. Has two extra optional arguments, ``height_field`` and
|
||||||
``width_field``, which, if set, will be auto-populated with the height and
|
``width_field``, which, if set, will be auto-populated with the height and
|
||||||
width of the image each time a model instance is saved.
|
width of the image each time a model instance is saved.
|
||||||
|
@ -1554,7 +1554,7 @@ as a custom extension to the ``TextInput`` widget::
|
|||||||
class CommentWidget(forms.TextInput):
|
class CommentWidget(forms.TextInput):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault('attrs',{}).update({'size': '40'})
|
kwargs.setdefault('attrs',{}).update({'size': '40'})
|
||||||
super(forms.TextInput, self).__init__(*args, **kwargs)
|
super(CommentWidget, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
Then you can use this widget in your forms::
|
Then you can use this widget in your forms::
|
||||||
|
|
||||||
|
@ -1101,10 +1101,11 @@ To disable this behavior, just remove all entries from the ``ADMINS`` setting.
|
|||||||
404 errors
|
404 errors
|
||||||
----------
|
----------
|
||||||
|
|
||||||
When ``DEBUG`` is ``False`` and your ``MIDDLEWARE_CLASSES`` setting includes
|
When ``DEBUG`` is ``False``, ``SEND_BROKEN_LINK_EMAILS`` is ``True`` and your
|
||||||
``CommonMiddleware``, Django will e-mail the users listed in the ``MANAGERS``
|
``MIDDLEWARE_CLASSES`` setting includes ``CommonMiddleware``, Django will
|
||||||
setting whenever your code raises a 404 and the request has a referer.
|
e-mail the users listed in the ``MANAGERS`` setting whenever your code raises
|
||||||
(It doesn't bother to e-mail for 404s that don't have a referer.)
|
a 404 and the request has a referer. (It doesn't bother to e-mail for 404s
|
||||||
|
that don't have a referer.)
|
||||||
|
|
||||||
You can tell Django to stop reporting particular 404s by tweaking the
|
You can tell Django to stop reporting particular 404s by tweaking the
|
||||||
``IGNORABLE_404_ENDS`` and ``IGNORABLE_404_STARTS`` settings. Both should be a
|
``IGNORABLE_404_ENDS`` and ``IGNORABLE_404_STARTS`` settings. Both should be a
|
||||||
|
@ -1301,9 +1301,14 @@ unordered_list
|
|||||||
Recursively takes a self-nested list and returns an HTML unordered list --
|
Recursively takes a self-nested list and returns an HTML unordered list --
|
||||||
WITHOUT opening and closing <ul> tags.
|
WITHOUT opening and closing <ul> tags.
|
||||||
|
|
||||||
|
**Changed in Django development version**
|
||||||
|
|
||||||
|
The format accepted by ``unordered_list`` has changed to an easier to
|
||||||
|
understand format.
|
||||||
|
|
||||||
The list is assumed to be in the proper format. For example, if ``var`` contains
|
The list is assumed to be in the proper format. For example, if ``var`` contains
|
||||||
``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``,
|
``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
|
||||||
then ``{{ var|unordered_list }}`` would return::
|
``{{ var|unordered_list }}`` would return::
|
||||||
|
|
||||||
<li>States
|
<li>States
|
||||||
<ul>
|
<ul>
|
||||||
@ -1317,6 +1322,9 @@ then ``{{ var|unordered_list }}`` would return::
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
Note: the previous more restrictive and verbose format is still supported:
|
||||||
|
``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``,
|
||||||
|
|
||||||
upper
|
upper
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
|
@ -259,6 +259,22 @@ These concepts are represented by simple Python classes. Edit the
|
|||||||
choice = models.CharField(max_length=200)
|
choice = models.CharField(max_length=200)
|
||||||
votes = models.IntegerField()
|
votes = models.IntegerField()
|
||||||
|
|
||||||
|
.. admonition:: Errors about ``max_length``
|
||||||
|
|
||||||
|
If Django gives you an error message saying that ``max_length`` is
|
||||||
|
not a valid argument, you're most likely using an old version of
|
||||||
|
Django. (This version of the tutorial is written for the latest
|
||||||
|
development version of Django.) If you're using a Subversion checkout
|
||||||
|
of Django's development version (see `the installation docs`_ for
|
||||||
|
more information), you shouldn't have any problems.
|
||||||
|
|
||||||
|
If you want to stick with an older version of Django, you'll want to
|
||||||
|
switch to `the Django 0.96 tutorial`_, because this tutorial covers
|
||||||
|
several features that only exist in the Django development version.
|
||||||
|
|
||||||
|
.. _the installation docs: ../install/
|
||||||
|
.. _the Django 0.96 tutorial: ../0.96/tutorial01/
|
||||||
|
|
||||||
The code is straightforward. Each model is represented by a class that
|
The code is straightforward. Each model is represented by a class that
|
||||||
subclasses ``django.db.models.Model``. Each model has a number of class
|
subclasses ``django.db.models.Model``. Each model has a number of class
|
||||||
variables, each of which represents a database field in the model.
|
variables, each of which represents a database field in the model.
|
||||||
@ -487,6 +503,23 @@ the ``polls/models.py`` file) and adding a ``__unicode__()`` method to both
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.choice
|
return self.choice
|
||||||
|
|
||||||
|
.. admonition:: If ``__unicode__()`` doesn't seem to work
|
||||||
|
|
||||||
|
If you add the ``__unicode__()`` method to your models and don't
|
||||||
|
see any change in how they're represented, you're most likely using
|
||||||
|
an old version of Django. (This version of the tutorial is written
|
||||||
|
for the latest development version of Django.) If you're using a
|
||||||
|
Subversion checkout of of Django's development version (see `the
|
||||||
|
installation docs`_ for more information), you shouldn't have any
|
||||||
|
problems.
|
||||||
|
|
||||||
|
If you want to stick with an older version of Django, you'll want to
|
||||||
|
switch to `the Django 0.96 tutorial`_, because this tutorial covers
|
||||||
|
several features that only exist in the Django development version.
|
||||||
|
|
||||||
|
.. _the installation docs: ../install/
|
||||||
|
.. _the Django 0.96 tutorial: ../0.96/tutorial01/
|
||||||
|
|
||||||
It's important to add ``__unicode__()`` methods to your models, not only for
|
It's important to add ``__unicode__()`` methods to your models, not only for
|
||||||
your own sanity when dealing with the interactive prompt, but also because
|
your own sanity when dealing with the interactive prompt, but also because
|
||||||
objects' representations are used throughout Django's automatically-generated
|
objects' representations are used throughout Django's automatically-generated
|
||||||
|
@ -266,6 +266,22 @@ u'bc'
|
|||||||
>>> slice_(u'abcdefg', u'0::2')
|
>>> slice_(u'abcdefg', u'0::2')
|
||||||
u'aceg'
|
u'aceg'
|
||||||
|
|
||||||
|
>>> unordered_list([u'item 1', u'item 2'])
|
||||||
|
u'\t<li>item 1</li>\n\t<li>item 2</li>'
|
||||||
|
|
||||||
|
>>> unordered_list([u'item 1', [u'item 1.1']])
|
||||||
|
u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>'
|
||||||
|
|
||||||
|
>>> unordered_list([u'item 1', [u'item 1.1', u'item1.2'], u'item 2'])
|
||||||
|
u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item1.2</li>\n\t</ul>\n\t</li>\n\t<li>item 2</li>'
|
||||||
|
|
||||||
|
>>> unordered_list([u'item 1', [u'item 1.1', [u'item 1.1.1', [u'item 1.1.1.1']]]])
|
||||||
|
u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1\n\t\t<ul>\n\t\t\t<li>item 1.1.1\n\t\t\t<ul>\n\t\t\t\t<li>item 1.1.1.1</li>\n\t\t\t</ul>\n\t\t\t</li>\n\t\t</ul>\n\t\t</li>\n\t</ul>\n\t</li>'
|
||||||
|
|
||||||
|
>>> unordered_list(['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']])
|
||||||
|
u'\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>'
|
||||||
|
|
||||||
|
# Old format for unordered lists should still work
|
||||||
>>> unordered_list([u'item 1', []])
|
>>> unordered_list([u'item 1', []])
|
||||||
u'\t<li>item 1</li>'
|
u'\t<li>item 1</li>'
|
||||||
|
|
||||||
@ -275,6 +291,9 @@ u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>'
|
|||||||
>>> unordered_list([u'item 1', [[u'item 1.1', []], [u'item 1.2', []]]])
|
>>> unordered_list([u'item 1', [[u'item 1.1', []], [u'item 1.2', []]]])
|
||||||
u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>'
|
u'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>'
|
||||||
|
|
||||||
|
>>> unordered_list(['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]])
|
||||||
|
u'\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>'
|
||||||
|
|
||||||
>>> add(u'1', u'2')
|
>>> add(u'1', u'2')
|
||||||
3
|
3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user