1
0
mirror of https://github.com/django/django.git synced 2025-07-03 09:19:16 +00:00

newforms-admin: Merged from trunk up to [7706].

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7707 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner 2008-06-19 16:04:52 +00:00
parent 308cef4068
commit d5899f17e9
70 changed files with 4955 additions and 1329 deletions

View File

@ -65,6 +65,7 @@ answer newbie questions, and generally made Django that much better:
Mikaël Barbero <mikael.barbero nospam at nospam free.fr>
Jiri Barton
Ned Batchelder <http://www.nedbatchelder.com/>
batiste@dosimple.ch
Shannon -jj Behrens <http://jjinux.blogspot.com/>
Esdras Beleza <linux@esdrasbeleza.com>
Chris Bennett <chrisrbennett@yahoo.com>
@ -231,6 +232,7 @@ answer newbie questions, and generally made Django that much better:
Nicola Larosa <nico@teknico.net>
Rune Rønde Laursen <runerl@skjoldhoej.dk>
Eugene Lazutkin <http://lazutkin.com/blog/>
lcordier@point45.com
Jeong-Min Lee <falsetru@gmail.com>
Jannis Leidel <jl@websushi.org>
Christopher Lenz <http://www.cmlenz.net/>

View File

@ -1,4 +1,4 @@
Copyright (c) 2005, the Lawrence Journal-World
Copyright (c) Django Software Foundation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,

View File

@ -52,6 +52,7 @@ LANGUAGES = (
('el', gettext_noop('Greek')),
('en', gettext_noop('English')),
('es', gettext_noop('Spanish')),
('et', gettext_noop('Estonian')),
('es-ar', gettext_noop('Argentinean Spanish')),
('eu', gettext_noop('Basque')),
('fa', gettext_noop('Persian')),
@ -70,6 +71,7 @@ LANGUAGES = (
('km', gettext_noop('Khmer')),
('kn', gettext_noop('Kannada')),
('lv', gettext_noop('Latvian')),
('lt', gettext_noop('Lithuanian')),
('mk', gettext_noop('Macedonian')),
('nl', gettext_noop('Dutch')),
('no', gettext_noop('Norwegian')),

View File

@ -6,7 +6,7 @@ msgstr ""
"Project-Id-Version: Django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-13 16:14+0200\n"
"PO-Revision-Date: 2008-06-16 10:04+0200\n"
"PO-Revision-Date: 2008-06-18 22:45+0200\n"
"Last-Translator: Django Spanish Translation Team <django-cat@googlegroups.com>\n"
"Language-Team: Django Spanish Translation Team <django-cat@googlegroups.com>\n"
"MIME-Version: 1.0\n"
@ -16,191 +16,191 @@ msgstr ""
#: conf/global_settings.py:44
msgid "Arabic"
msgstr "Árabe"
msgstr "árabe"
#: conf/global_settings.py:45
msgid "Bengali"
msgstr "Bengalí"
msgstr "bengalí"
#: conf/global_settings.py:46
msgid "Bulgarian"
msgstr "Búlgaro"
msgstr "búlgaro"
#: conf/global_settings.py:47
msgid "Catalan"
msgstr "Catalán"
msgstr "catalán"
#: conf/global_settings.py:48
msgid "Czech"
msgstr "Checo"
msgstr "checo"
#: conf/global_settings.py:49
msgid "Welsh"
msgstr "Galés"
msgstr "galés"
#: conf/global_settings.py:50
msgid "Danish"
msgstr "Danés"
msgstr "danés"
#: conf/global_settings.py:51
msgid "German"
msgstr "Alemán"
msgstr "alemán"
#: conf/global_settings.py:52
msgid "Greek"
msgstr "Griego"
msgstr "griego"
#: conf/global_settings.py:53
msgid "English"
msgstr "Inglés"
msgstr "inglés"
#: conf/global_settings.py:54
msgid "Spanish"
msgstr "Español"
msgstr "español"
#: conf/global_settings.py:55
msgid "Argentinean Spanish"
msgstr "Español Argentino"
msgstr "español de Argentina"
#: conf/global_settings.py:56
msgid "Basque"
msgstr "Vasco"
msgstr "vasco"
#: conf/global_settings.py:57
msgid "Persian"
msgstr "Persa"
msgstr "persa"
#: conf/global_settings.py:58
msgid "Finnish"
msgstr "Finés"
msgstr "finés"
#: conf/global_settings.py:59
msgid "French"
msgstr "Francés"
msgstr "francés"
#: conf/global_settings.py:60
msgid "Irish"
msgstr "Irlandés"
msgstr "irlandés"
#: conf/global_settings.py:61
msgid "Galician"
msgstr "Gallego"
msgstr "gallego"
#: conf/global_settings.py:62
msgid "Hungarian"
msgstr "Húngaro"
msgstr "húngaro"
#: conf/global_settings.py:63
msgid "Hebrew"
msgstr "Hebreo"
msgstr "hebreo"
#: conf/global_settings.py:64
msgid "Croatian"
msgstr "Croata"
msgstr "croata"
#: conf/global_settings.py:65
msgid "Icelandic"
msgstr "Islandés"
msgstr "islandés"
#: conf/global_settings.py:66
msgid "Italian"
msgstr "Italiano"
msgstr "italiano"
#: conf/global_settings.py:67
msgid "Japanese"
msgstr "Japonés"
msgstr "japonés"
#: conf/global_settings.py:68
msgid "Georgian"
msgstr "Georgiano"
msgstr "georgiano"
#: conf/global_settings.py:69
msgid "Korean"
msgstr "Koreano"
msgstr "koreano"
#: conf/global_settings.py:70
msgid "Khmer"
msgstr "Khmer"
msgstr "khmer"
#: conf/global_settings.py:71
msgid "Kannada"
msgstr "Kannada"
msgstr "kannada"
#: conf/global_settings.py:72
msgid "Latvian"
msgstr "Letón"
msgstr "letón"
#: conf/global_settings.py:73
msgid "Macedonian"
msgstr "Macedonio"
msgstr "macedonio"
#: conf/global_settings.py:74
msgid "Dutch"
msgstr "Holandés"
msgstr "holandés"
#: conf/global_settings.py:75
msgid "Norwegian"
msgstr "Noruego"
msgstr "noruego"
#: conf/global_settings.py:76
msgid "Polish"
msgstr "Polaco"
msgstr "polaco"
#: conf/global_settings.py:77
msgid "Portugese"
msgstr "Portugués"
msgstr "portugués"
#: conf/global_settings.py:78
msgid "Brazilian Portuguese"
msgstr "Portugués Brasileño"
msgstr "portugués de Brasil"
#: conf/global_settings.py:79
msgid "Romanian"
msgstr "Rumano"
msgstr "rumano"
#: conf/global_settings.py:80
msgid "Russian"
msgstr "Ruso"
msgstr "ruso"
#: conf/global_settings.py:81
msgid "Slovak"
msgstr "Eslovaco"
msgstr "eslovaco"
#: conf/global_settings.py:82
msgid "Slovenian"
msgstr "Esloveno"
msgstr "esloveno"
#: conf/global_settings.py:83
msgid "Serbian"
msgstr "Serbio"
msgstr "serbio"
#: conf/global_settings.py:84
msgid "Swedish"
msgstr "Sueco"
msgstr "sueco"
#: conf/global_settings.py:85
msgid "Tamil"
msgstr "Tamil"
msgstr "tamil"
#: conf/global_settings.py:86
msgid "Telugu"
msgstr "Telugu"
msgstr "telugu"
#: conf/global_settings.py:87
msgid "Turkish"
msgstr "Turco"
msgstr "turco"
#: conf/global_settings.py:88
msgid "Ukrainian"
msgstr "Ucraniano"
msgstr "ucraniano"
#: conf/global_settings.py:89
msgid "Simplified Chinese"
msgstr "Chino simplificado"
msgstr "chino simplificado"
#: conf/global_settings.py:90
msgid "Traditional Chinese"
msgstr "Chino tradicional"
msgstr "chino tradicional"
#: contrib/admin/filterspecs.py:44
#, python-format
@ -4137,107 +4137,107 @@ msgstr "medio día"
#: utils/dates.py:6
msgid "Monday"
msgstr "Lunes"
msgstr "lunes"
#: utils/dates.py:6
msgid "Tuesday"
msgstr "Martes"
msgstr "martes"
#: utils/dates.py:6
msgid "Wednesday"
msgstr "Miércoles"
msgstr "miércoles"
#: utils/dates.py:6
msgid "Thursday"
msgstr "Jueves"
msgstr "jueves"
#: utils/dates.py:6
msgid "Friday"
msgstr "Viernes"
msgstr "viernes"
#: utils/dates.py:7
msgid "Saturday"
msgstr "Sábado"
msgstr "sábado"
#: utils/dates.py:7
msgid "Sunday"
msgstr "Domingo"
msgstr "domingo"
#: utils/dates.py:10
msgid "Mon"
msgstr "Lun"
msgstr "lun"
#: utils/dates.py:10
msgid "Tue"
msgstr "Mar"
msgstr "mar"
#: utils/dates.py:10
msgid "Wed"
msgstr "Mié"
msgstr "mié"
#: utils/dates.py:10
msgid "Thu"
msgstr "Jue"
msgstr "jue"
#: utils/dates.py:10
msgid "Fri"
msgstr "Vie"
msgstr "vie"
#: utils/dates.py:11
msgid "Sat"
msgstr "Sáb"
msgstr "sáb"
#: utils/dates.py:11
msgid "Sun"
msgstr "Dom"
msgstr "dom"
#: utils/dates.py:18
msgid "January"
msgstr "Enero"
msgstr "enero"
#: utils/dates.py:18
msgid "February"
msgstr "Febrero"
msgstr "febrero"
#: utils/dates.py:18 utils/dates.py:31
msgid "March"
msgstr "Marzo"
msgstr "marzo"
#: utils/dates.py:18 utils/dates.py:31
msgid "April"
msgstr "Abril"
msgstr "abril"
#: utils/dates.py:18 utils/dates.py:31
msgid "May"
msgstr "Mayo"
msgstr "mayo"
#: utils/dates.py:18 utils/dates.py:31
msgid "June"
msgstr "Junio"
msgstr "junio"
#: utils/dates.py:19 utils/dates.py:31
msgid "July"
msgstr "Julio"
msgstr "julio"
#: utils/dates.py:19
msgid "August"
msgstr "Agosto"
msgstr "agosto"
#: utils/dates.py:19
msgid "September"
msgstr "Septiembre"
msgstr "septiembre"
#: utils/dates.py:19
msgid "October"
msgstr "Octubre"
msgstr "octubre"
#: utils/dates.py:19
msgid "November"
msgstr "Noviembre"
msgstr "noviembre"
#: utils/dates.py:20
msgid "December"
msgstr "Diciembre"
msgstr "diciembre"
#: utils/dates.py:23
msgid "jan"
@ -4289,31 +4289,31 @@ msgstr "dic"
#: utils/dates.py:31
msgid "Jan."
msgstr "Ene."
msgstr "ene."
#: utils/dates.py:31
msgid "Feb."
msgstr "Feb."
msgstr "feb."
#: utils/dates.py:32
msgid "Aug."
msgstr "Ago."
msgstr "ago."
#: utils/dates.py:32
msgid "Sept."
msgstr "Sept."
msgstr "sept."
#: utils/dates.py:32
msgid "Oct."
msgstr "Oct."
msgstr "oct."
#: utils/dates.py:32
msgid "Nov."
msgstr "Nov."
msgstr "nov."
#: utils/dates.py:32
msgid "Dec."
msgstr "Dic."
msgstr "dic."
#: utils/text.py:127
msgid "or"

View File

@ -4,9 +4,9 @@
msgid ""
msgstr ""
"Project-Id-Version: Django\n"
"Report-Msgid-Bugs-To: \n"
"Report-Msgid-Bugs-To: removethis-eallik_at_gmail-com\n"
"POT-Creation-Date: 2008-06-02 19:15+0300\n"
"PO-Revision-Date: 2008-06-16 19:55+0200\n"
"PO-Revision-Date: 2008-06-17 12:29+0300\n"
"Last-Translator: Erik Allik <removethis-eallik_at_gmail-com>\n"
"Language-Team: Django-i18n <django-i18n@googlegroups.com>\n"
"MIME-Version: 1.0\n"
@ -35,7 +35,7 @@ msgstr "tšehhi"
#: conf/global_settings.py:48
msgid "Welsh"
msgstr "wales'i"
msgstr "uelsi"
#: conf/global_settings.py:49
msgid "Danish"
@ -59,7 +59,7 @@ msgstr "hispaania"
#: conf/global_settings.py:54
msgid "Argentinean Spanish"
msgstr "argentiina hispaania keel"
msgstr "argentiina hispaania"
#: conf/global_settings.py:55
msgid "Basque"
@ -151,7 +151,7 @@ msgstr "portugali"
#: conf/global_settings.py:77
msgid "Brazilian Portuguese"
msgstr "brasiilia portugali keel"
msgstr "brasiilia portugali"
#: conf/global_settings.py:78
msgid "Romanian"
@ -195,11 +195,11 @@ msgstr "ukrania"
#: conf/global_settings.py:88
msgid "Simplified Chinese"
msgstr "lihtsustatud hiina keel"
msgstr "lihtsustatud hiina"
#: conf/global_settings.py:89
msgid "Traditional Chinese"
msgstr "traditsiooniline hiina keel"
msgstr "traditsiooniline hiina"
#: contrib/admin/filterspecs.py:44
#, python-format
@ -229,11 +229,11 @@ msgstr "Viimased 7 päeva"
#: contrib/admin/filterspecs.py:119
msgid "This month"
msgstr "See kuu"
msgstr "Käesolev kuu"
#: contrib/admin/filterspecs.py:121
msgid "This year"
msgstr "See aasta"
msgstr "Käesolev aasta"
#: contrib/admin/filterspecs.py:147 newforms/widgets.py:231
#: oldforms/__init__.py:592
@ -420,7 +420,7 @@ msgstr "Jah, olen kindel"
#: contrib/admin/templates/admin/filter.html:2
#, python-format
msgid " By %(filter_title)s "
msgstr " %(filter_title)s järgi "
msgstr " %(filter_title)s "
#: contrib/admin/templates/admin/filters.html:4
msgid "Filter"
@ -446,7 +446,7 @@ msgstr "Teil ei ole õigust midagi muuta."
#: contrib/admin/templates/admin/index.html:52
msgid "Recent Actions"
msgstr "Hiljtuised Toimingud"
msgstr "Hiljutised Toimingud"
#: contrib/admin/templates/admin/index.html:53
msgid "My Actions"
@ -480,7 +480,7 @@ msgstr "Salasõna:"
#: contrib/admin/templates/admin/login.html:25
#: contrib/admin/views/decorators.py:31
msgid "Log in"
msgstr "Logi sisse"
msgstr "Sisene"
#: contrib/admin/templates/admin/object_history.html:17
msgid "Date/time"

View File

@ -3,10 +3,10 @@
# This file is distributed under the same license as the django package.
msgid ""
msgstr ""
"Project-Id-Version: Django"
"Report-Msgid-Bugs-To: \n"
"Project-Id-Version: Django\n"
"Report-Msgid-Bugs-To: <removethis-eallik_at_gmail-com>\n"
"POT-Creation-Date: 2008-06-02 19:42+0300\n"
"PO-Revision-Date: 2008-06-16 19:55+0200\n"
"PO-Revision-Date: 2008-06-17 12:29+0300\n"
"Last-Translator: Erik Allik <removethis-eallik_at_gmail-com>\n"
"Language-Team: Django-i18n <django-i18n@googlegroups.com>\n"
"MIME-Version: 1.0\n"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ msgstr ""
"Project-Id-Version: Django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-08-13 11:13+1000\n"
"PO-Revision-Date: 2008-01-05 01:45+0100\n"
"PO-Revision-Date: 2008-06-17 23:45+0100\n"
"Last-Translator: Aljosa Mohorovic <aljosa.mohorovic@gmail.com>\n"
"Language-Team: Hrvatski jezik\n"
"MIME-Version: 1.0\n"

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,116 @@
# Lithuanian translation of Django.
# Copyright (C) 2008 The Django Software Foundation
# This file is distributed under the same license as the Django package.
msgid ""
msgstr ""
"Project-Id-Version: Django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-06-15 23:03+0300\n"
"PO-Revision-Date: 2008-06-18 22:37+0200\n"
"Last-Translator: Rapolas Kaselis <rapolas@gmail.com>\n"
"Language-Team: Django-i18n <django-i18n@googlegroups.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: contrib/admin/media/js/SelectFilter2.js:33
#, perl-format
msgid "Available %s"
msgstr "Galimas %s"
#: contrib/admin/media/js/SelectFilter2.js:41
msgid "Choose all"
msgstr "Pasirinkti visus"
#: contrib/admin/media/js/SelectFilter2.js:46
msgid "Add"
msgstr "Pridėti"
#: contrib/admin/media/js/SelectFilter2.js:48
msgid "Remove"
msgstr "Pašalinti"
#: contrib/admin/media/js/SelectFilter2.js:53
#, perl-format
msgid "Chosen %s"
msgstr "Pasirinktas %s"
#: contrib/admin/media/js/SelectFilter2.js:54
msgid "Select your choice(s) and click "
msgstr "Pasirink ir paspausk"
#: contrib/admin/media/js/SelectFilter2.js:59
msgid "Clear all"
msgstr "Išvalyti visus"
#: contrib/admin/media/js/dateparse.js:32
#: contrib/admin/media/js/calendar.js:24
msgid ""
"January February March April May June July August September October November "
"December"
msgstr "Sausis Vasaris Kovas Balandis Gegužė Birželis Liepa Rugpjūtis Rugsėjis "
"Spalis Lapkritis Gruodis"
#: contrib/admin/media/js/dateparse.js:33
msgid "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
msgstr "Sekmadienis Pirmadienis Antradienis Trečiadienis Ketvirtadienis Penktadienis Šeštadienis"
#: contrib/admin/media/js/calendar.js:25
msgid "S M T W T F S"
msgstr "S P A T K P Š"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:47
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:81
msgid "Now"
msgstr "Dabar"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:51
msgid "Clock"
msgstr "Laikrodis"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:78
msgid "Choose a time"
msgstr "Pasirink laiką"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:82
msgid "Midnight"
msgstr "Vidurnaktis"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:83
msgid "6 a.m."
msgstr "6 a.m."
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:84
msgid "Noon"
msgstr "Vidurdienis"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:88
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:183
msgid "Cancel"
msgstr "Atšaukti"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:128
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:177
msgid "Today"
msgstr "Šiandien"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:132
msgid "Calendar"
msgstr "Kalendorius"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:175
msgid "Yesterday"
msgstr "Vakar"
#: contrib/admin/media/js/admin/DateTimeShortcuts.js:179
msgid "Tomorrow"
msgstr "Rytoj"
#: contrib/admin/media/js/admin/CollapsedFieldsets.js:34
#: contrib/admin/media/js/admin/CollapsedFieldsets.js:72
msgid "Show"
msgstr "Parodyti"
#: contrib/admin/media/js/admin/CollapsedFieldsets.js:63
msgid "Hide"
msgstr "Slėpti"

View File

@ -16,7 +16,7 @@ def login(request, template_name='registration/login.html', redirect_field_name=
"Displays the login form and handles the login action."
redirect_to = request.REQUEST.get(redirect_field_name, '')
if request.method == "POST":
form = AuthenticationForm(request, request.POST)
form = AuthenticationForm(data=request.POST)
if form.is_valid():
# Light security check -- make sure redirect_to isn't garbage.
if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
@ -24,7 +24,8 @@ def login(request, template_name='registration/login.html', redirect_field_name=
redirect_to = settings.LOGIN_REDIRECT_URL
from django.contrib.auth import login
login(request, form.get_user())
request.session.delete_test_cookie()
if request.session.test_cookie_worked():
request.session.delete_test_cookie()
return HttpResponseRedirect(redirect_to)
else:
form = AuthenticationForm(request)

View File

@ -23,12 +23,16 @@ class TestForm(forms.Form):
class PreviewTests(TestCase):
def setUp(self):
self._old_root_urlconf = settings.ROOT_URLCONF
settings.ROOT_URLCONF = 'django.contrib.formtools.test_urls'
# Create a FormPreview instance to share between tests
self.preview = preview.FormPreview(TestForm)
input_template = '<input type="hidden" name="%s" value="%s" />'
self.input = input_template % (self.preview.unused_name('stage'), "%d")
def tearDown(self):
settings.ROOT_URLCONF = self._old_root_urlconf
def test_unused_name(self):
"""
Verifies name mangling to get uniue field name.

View File

@ -6,7 +6,7 @@ AR-specific Form helpers.
from django.newforms import ValidationError
from django.newforms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class ARProvinceSelect(Select):
"""
@ -24,7 +24,7 @@ class ARPostalCodeField(RegexField):
See http://www.correoargentino.com.ar/consulta_cpa/home.php
"""
default_error_messages = {
'invalid': ugettext("Enter a postal code in the format NNNN or ANNNNAAA."),
'invalid': _("Enter a postal code in the format NNNN or ANNNNAAA."),
}
def __init__(self, *args, **kwargs):
@ -46,8 +46,8 @@ class ARDNIField(CharField):
A field that validates 'Documento Nacional de Identidad' (DNI) numbers.
"""
default_error_messages = {
'invalid': ugettext("This field requires only numbers."),
'max_digits': ugettext("This field requires 7 or 8 digits."),
'invalid': _("This field requires only numbers."),
'max_digits': _("This field requires 7 or 8 digits."),
}
def __init__(self, *args, **kwargs):
@ -76,8 +76,8 @@ class ARCUITField(RegexField):
CUIT is of the form XX-XXXXXXXX-V. The last digit is a check digit.
"""
default_error_messages = {
'invalid': ugettext('Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'),
'checksum': ugettext("Invalid CUIT."),
'invalid': _('Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'),
'checksum': _("Invalid CUIT."),
}
def __init__(self, *args, **kwargs):

View File

@ -5,7 +5,7 @@ Australian-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.newforms.util import smart_unicode
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
import re
PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')
@ -13,7 +13,7 @@ PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')
class AUPostCodeField(RegexField):
"""Australian post code field."""
default_error_messages = {
'invalid': ugettext('Enter a 4 digit post code.'),
'invalid': _('Enter a 4 digit post code.'),
}
def __init__(self, *args, **kwargs):

View File

@ -6,7 +6,7 @@ BR-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, CharField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
import re
try:

View File

@ -5,7 +5,7 @@ Canada-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.newforms.util import smart_unicode
from django.utils.translation import gettext, ugettext
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
@ -14,7 +14,7 @@ sin_re = re.compile(r"^(\d{3})-(\d{3})-(\d{3})$")
class CAPostalCodeField(RegexField):
"""Canadian postal code field."""
default_error_messages = {
'invalid': gettext(u'Enter a postal code in the format XXX XXX.'),
'invalid': _(u'Enter a postal code in the format XXX XXX.'),
}
def __init__(self, *args, **kwargs):
@ -85,7 +85,7 @@ class CASocialInsuranceNumberField(Field):
See: http://en.wikipedia.org/wiki/Social_Insurance_Number
"""
default_error_messages = {
'invalid': ugettext('Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'),
'invalid': _('Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'),
}
def clean(self, value):

View File

@ -5,7 +5,7 @@ Swiss-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
import re
id_re = re.compile(r"^(?P<idnumber>\w{8})(?P<pos9>(\d{1}|<))(?P<checksum>\d{1})$")
@ -13,7 +13,7 @@ phone_digits_re = re.compile(r'^0([1-9]{1})\d{8}$')
class CHZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXX.'),
'invalid': _('Enter a zip code in the format XXXX.'),
}
def __init__(self, *args, **kwargs):
@ -61,7 +61,7 @@ class CHIdentityCardNumberField(Field):
Algorithm is documented at http://adi.kousz.ch/artikel/IDCHE.htm
"""
default_error_messages = {
'invalid': ugettext('Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.'),
'invalid': _('Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.'),
}
def has_valid_checksum(self, number):

View File

@ -4,7 +4,7 @@ Chile specific form helpers.
from django.newforms import ValidationError
from django.newforms.fields import RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
@ -26,9 +26,9 @@ class CLRutField(RegexField):
https://palena.sii.cl/cvc/dte/ee_empresas_emisoras.html
"""
default_error_messages = {
'invalid': ugettext('Enter a valid Chilean RUT.'),
'strict': ugettext('Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'),
'checksum': ugettext('The Chilean RUT is not valid.'),
'invalid': _('Enter a valid Chilean RUT.'),
'strict': _('Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'),
'checksum': _('The Chilean RUT is not valid.'),
}
def __init__(self, *args, **kwargs):

View File

@ -4,14 +4,14 @@ DE-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
import re
id_re = re.compile(r"^(?P<residence>\d{10})(?P<origin>\w{1,3})[-\ ]?(?P<birthday>\d{7})[-\ ]?(?P<validity>\d{7})[-\ ]?(?P<checksum>\d{1})$")
class DEZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXXX.'),
'invalid': _('Enter a zip code in the format XXXXX.'),
}
def __init__(self, *args, **kwargs):
super(DEZipCodeField, self).__init__(r'^\d{5}$',
@ -38,7 +38,7 @@ class DEIdentityCardNumberField(Field):
Algorithm is documented at http://de.wikipedia.org/wiki/Personalausweis
"""
default_error_messages = {
'invalid': ugettext('Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.'),
'invalid': _('Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.'),
}
def has_valid_checksum(self, number):

View File

@ -5,7 +5,7 @@ Spanish-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
import re
class ESPostalCodeField(RegexField):

View File

@ -5,11 +5,11 @@ FI-specific Form helpers
import re
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class FIZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXXX.'),
'invalid': _('Enter a zip code in the format XXXXX.'),
}
def __init__(self, *args, **kwargs):
super(FIZipCodeField, self).__init__(r'^\d{5}$',
@ -25,7 +25,7 @@ class FIMunicipalitySelect(Select):
class FISocialSecurityNumber(Field):
default_error_messages = {
'invalid': ugettext('Enter a valid Finnish social security number.'),
'invalid': _('Enter a valid Finnish social security number.'),
}
def clean(self, value):

View File

@ -5,14 +5,14 @@ FR-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^0\d(\s|\.)?(\d{2}(\s|\.)?){3}\d{2}$')
class FRZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXXX.'),
'invalid': _('Enter a zip code in the format XXXXX.'),
}
def __init__(self, *args, **kwargs):

View File

@ -5,7 +5,7 @@ Iceland specific form helpers.
from django.newforms import ValidationError
from django.newforms.fields import RegexField, EMPTY_VALUES
from django.newforms.widgets import Select
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
class ISIdNumberField(RegexField):
@ -14,8 +14,8 @@ class ISIdNumberField(RegexField):
of Iceland has.
"""
default_error_messages = {
'invalid': ugettext('Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.'),
'checksum': ugettext(u'The Icelandic identification number is not valid.'),
'invalid': _('Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.'),
'checksum': _(u'The Icelandic identification number is not valid.'),
}
def __init__(self, *args, **kwargs):

View File

@ -4,14 +4,14 @@ IT-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit
import re
class ITZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a valid zip code.'),
'invalid': _('Enter a valid zip code.'),
}
def __init__(self, *args, **kwargs):
super(ITZipCodeField, self).__init__(r'^\d{5}$',
@ -40,7 +40,7 @@ class ITSocialSecurityNumberField(RegexField):
'Informazioni sulla codificazione delle persone fisiche'.
"""
default_error_messages = {
'invalid': ugettext(u'Enter a valid Social Security number.'),
'invalid': _(u'Enter a valid Social Security number.'),
}
def __init__(self, *args, **kwargs):
@ -65,7 +65,7 @@ class ITVatNumberField(Field):
A form field that validates Italian VAT numbers (partita IVA).
"""
default_error_messages = {
'invalid': ugettext(u'Enter a valid VAT number.'),
'invalid': _(u'Enter a valid VAT number.'),
}
def clean(self, value):

View File

@ -4,7 +4,7 @@ JP-specific Form helpers
from django.core import validators
from django.newforms import ValidationError
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.newforms.fields import RegexField, Select
class JPPostalCodeField(RegexField):
@ -14,7 +14,7 @@ class JPPostalCodeField(RegexField):
Accepts 7 digits, with or without a hyphen.
"""
default_error_messages = {
'invalid': ugettext('Enter a postal code in the format XXXXXXX or XXX-XXXX.'),
'invalid': _('Enter a postal code in the format XXXXXXX or XXX-XXXX.'),
}
def __init__(self, *args, **kwargs):

View File

@ -6,7 +6,7 @@ import re
from django.newforms import ValidationError
from django.newforms.fields import Field, Select, EMPTY_VALUES
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
pc_re = re.compile('^\d{4}[A-Z]{2}$')

View File

@ -5,11 +5,11 @@ Norwegian-specific Form helpers
import re, datetime
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class NOZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXX.'),
'invalid': _('Enter a zip code in the format XXXX.'),
}
def __init__(self, *args, **kwargs):
@ -30,7 +30,7 @@ class NOSocialSecurityNumber(Field):
Algorithm is documented at http://no.wikipedia.org/wiki/Personnummer
"""
default_error_messages = {
'invalid': ugettext(u'Enter a valid Norwegian social security number.'),
'invalid': _(u'Enter a valid Norwegian social security number.'),
}
def clean(self, value):

View File

@ -5,7 +5,7 @@ PE-specific Form helpers.
from django.newforms import ValidationError
from django.newforms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class PEDepartmentSelect(Select):
"""
@ -20,8 +20,8 @@ class PEDNIField(CharField):
A field that validates `Documento Nacional de IdentidadŽ (DNI) numbers.
"""
default_error_messages = {
'invalid': ugettext("This field requires only numbers."),
'max_digits': ugettext("This field requires 8 digits."),
'invalid': _("This field requires only numbers."),
'max_digits': _("This field requires 8 digits."),
}
def __init__(self, *args, **kwargs):
@ -48,8 +48,8 @@ class PERUCField(RegexField):
the form XXXXXXXXXXX.
"""
default_error_messages = {
'invalid': ugettext("This field requires only numbers."),
'max_digits': ugettext("This field requires 11 digits."),
'invalid': _("This field requires only numbers."),
'max_digits': _("This field requires 11 digits."),
}
def __init__(self, *args, **kwargs):

View File

@ -6,7 +6,7 @@ import re
from django.newforms import ValidationError
from django.newforms.fields import Select, RegexField
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
class PLVoivodeshipSelect(Select):
"""

View File

@ -3,7 +3,7 @@ Slovak-specific form helpers
"""
from django.newforms.fields import Select, RegexField
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class SKRegionSelect(Select):
"""
@ -27,7 +27,7 @@ class SKPostalCodeField(RegexField):
Valid form is XXXXX or XXX XX, where X represents integer.
"""
default_error_messages = {
'invalid': ugettext(u'Enter a postal code in the format XXXXX or XXX XX.'),
'invalid': _(u'Enter a postal code in the format XXXXX or XXX XX.'),
}
def __init__(self, *args, **kwargs):

View File

@ -6,7 +6,7 @@ import re
from django.newforms.fields import CharField, Select
from django.newforms import ValidationError
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
class UKPostcodeField(CharField):
"""
@ -18,7 +18,7 @@ class UKPostcodeField(CharField):
The value is uppercased and a space added in the correct place, if required.
"""
default_error_messages = {
'invalid': ugettext(u'Enter a valid postcode.'),
'invalid': _(u'Enter a valid postcode.'),
}
outcode_pattern = '[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|[0-9]|[ABEHMNPRVWXY]))|[0-9][A-HJKSTUW])'
incode_pattern = '[0-9][ABD-HJLNP-UW-Z]{2}'

View File

@ -5,7 +5,7 @@ Sources:
Welsh regions: http://en.wikipedia.org/wiki/Preserved_counties_of_Wales
Scottish regions: http://en.wikipedia.org/wiki/Regions_and_districts_of_Scotland
"""
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
ENGLAND_REGION_CHOICES = (
("Bedfordshire", _("Bedfordshire")),

View File

@ -5,7 +5,7 @@ USA-specific Form helpers
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
@ -13,7 +13,7 @@ ssn_re = re.compile(r"^(?P<area>\d{3})[-\ ]?(?P<group>\d{2})[-\ ]?(?P<serial>\d{
class USZipCodeField(RegexField):
default_error_messages = {
'invalid': ugettext('Enter a zip code in the format XXXXX or XXXXX-XXXX.'),
'invalid': _('Enter a zip code in the format XXXXX or XXXXX-XXXX.'),
}
def __init__(self, *args, **kwargs):
@ -51,7 +51,7 @@ class USSocialSecurityNumberField(Field):
1962 promotional number).
"""
default_error_messages = {
'invalid': ugettext('Enter a valid U.S. Social Security number in XXX-XX-XXXX format.'),
'invalid': _('Enter a valid U.S. Social Security number in XXX-XX-XXXX format.'),
}
def clean(self, value):

View File

@ -87,6 +87,25 @@ class SessionBase(object):
except:
return {}
def update(self, dict_):
self._session.update(dict_)
self.modified = True
def has_key(self, key):
return self._session.has_key(key)
def values(self):
return self._session.values()
def iterkeys(self):
return self._session.iterkeys()
def itervalues(self):
return self._session.itervalues()
def iteritems(self):
return self._session.iteritems()
def _get_new_session_key(self):
"Returns session key that isn't being used."
# The random module is seeded when this Apache child is created.

View File

@ -89,6 +89,66 @@ False
>>> s.pop('some key', 'does not exist')
'does not exist'
>>> s.get('update key', None)
# test .update()
>>> s.modified = s.accessed = False # Reset to pretend this wasn't accessed previously
>>> s.update({'update key':1})
>>> s.accessed, s.modified
(True, True)
>>> s.get('update key', None)
1
# test .has_key()
>>> s.modified = s.accessed = False # Reset to pretend this wasn't accessed previously
>>> s.has_key('update key')
True
>>> s.accessed, s.modified
(True, False)
# test .values()
>>> s = SessionBase()
>>> s.values()
[]
>>> s.accessed
True
>>> s['x'] = 1
>>> s.values()
[1]
# test .iterkeys()
>>> s.accessed = False
>>> i = s.iterkeys()
>>> hasattr(i,'__iter__')
True
>>> s.accessed
True
>>> list(i)
['x']
# test .itervalues()
>>> s.accessed = False
>>> i = s.itervalues()
>>> hasattr(i,'__iter__')
True
>>> s.accessed
True
>>> list(i)
[1]
# test .iteritems()
>>> s.accessed = False
>>> i = s.iteritems()
>>> hasattr(i,'__iter__')
True
>>> s.accessed
True
>>> list(i)
[('x', 1)]
#########################
# Custom session expiry #
#########################

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_create
return '\n'.join(sql_create(app, self.style))
return u'\n'.join(sql_create(app, self.style)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_all
return '\n'.join(sql_all(app, self.style))
return u'\n'.join(sql_all(app, self.style)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_delete
return '\n'.join(sql_delete(app, self.style))
return u'\n'.join(sql_delete(app, self.style)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_custom
return '\n'.join(sql_custom(app))
return u'\n'.join(sql_custom(app)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(NoArgsCommand):
def handle_noargs(self, **options):
from django.core.management.sql import sql_flush
return '\n'.join(sql_flush(self.style, only_django=True))
return u'\n'.join(sql_flush(self.style, only_django=True)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_indexes
return '\n'.join(sql_indexes(app, self.style))
return u'\n'.join(sql_indexes(app, self.style)).encode('utf-8')

View File

@ -7,4 +7,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.core.management.sql import sql_reset
return '\n'.join(sql_reset(app, self.style))
return u'\n'.join(sql_reset(app, self.style)).encode('utf-8')

View File

@ -6,4 +6,4 @@ class Command(AppCommand):
def handle_app(self, app, **options):
from django.db import connection, models
return '\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app)))
return u'\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app))).encode('utf-8')

View File

@ -25,6 +25,7 @@ class Command(NoArgsCommand):
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive')
show_traceback = options.get('traceback', False)
self.style = no_style()
@ -119,12 +120,17 @@ class Command(NoArgsCommand):
for sql in custom_sql:
cursor.execute(sql)
except Exception, e:
sys.stderr.write("Failed to install custom SQL for %s.%s model: %s" % \
sys.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
(app_name, model._meta.object_name, e))
if show_traceback:
import traceback
traceback.print_exc()
transaction.rollback_unless_managed()
else:
transaction.commit_unless_managed()
else:
if verbosity >= 2:
print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
# Install SQL indicies for all newly created models
for app in models.get_apps():
app_name = app.__name__.split('.')[-2]

View File

@ -157,7 +157,7 @@ class AppCache(object):
"""
for model in models:
# Store as 'name: model' pair in a dictionary
# in the _app_models dictionary
# in the app_models dictionary
model_name = model._meta.object_name.lower()
model_dict = self.app_models.setdefault(app_label, {})
if model_name in model_dict:

View File

@ -428,8 +428,12 @@ class RadioInput(StrAndUnicode):
self.index = index
def __unicode__(self):
return mark_safe(u'<label>%s %s</label>' % (self.tag(),
conditional_escape(force_unicode(self.choice_label))))
if 'id' in self.attrs:
label_for = ' for="%s_%s"' % (self.attrs['id'], self.index)
else:
label_for = ''
choice_label = conditional_escape(force_unicode(self.choice_label))
return mark_safe(u'<label%s>%s %s</label>' % (label_for, self.tag(), choice_label))
def is_checked(self):
return self.value == self.choice_value
@ -511,11 +515,15 @@ class CheckboxSelectMultiple(SelectMultiple):
# so that the checkboxes don't all have the same ID attribute.
if has_id:
final_attrs = dict(final_attrs, id='%s_%s' % (attrs['id'], i))
label_for = u' for="%s"' % final_attrs['id']
else:
label_for = ''
cb = CheckboxInput(final_attrs, check_test=lambda value: value in str_values)
option_value = force_unicode(option_value)
rendered_cb = cb.render(name, option_value)
output.append(u'<li><label>%s %s</label></li>' % (rendered_cb,
conditional_escape(force_unicode(option_label))))
option_label = conditional_escape(force_unicode(option_label))
output.append(u'<li><label%s>%s %s</label></li>' % (label_for, rendered_cb, option_label))
output.append(u'</ul>')
return mark_safe(u'\n'.join(output))

View File

@ -69,10 +69,6 @@ class ExtendsNode(Node):
def render(self, context):
compiled_parent = self.get_parent(context)
pos = 0
while isinstance(compiled_parent.nodelist[pos], TextNode):
pos += 1
parent_is_child = isinstance(compiled_parent.nodelist[pos], ExtendsNode)
parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)])
for block_node in self.nodelist.get_nodes_by_type(BlockNode):
# Check for a BlockNode with this node's name, and replace it if found.
@ -83,8 +79,16 @@ class ExtendsNode(Node):
# parent block might be defined in the parent's *parent*, so we
# add this BlockNode to the parent's ExtendsNode nodelist, so
# it'll be checked when the parent node's render() is called.
if parent_is_child:
compiled_parent.nodelist[pos].nodelist.append(block_node)
# Find out if the parent template has a parent itself
for node in compiled_parent.nodelist:
if not isinstance(node, TextNode):
# If the first non-text node is an extends, handle it.
if isinstance(node, ExtendsNode):
node.nodelist.append(block_node)
# Extends must be the first non-text node, so once you find
# the first non-text node you can stop looking.
break
else:
# Keep any existing parents and add a new one. Used by BlockNode.
parent_block.parent = block_node.parent

View File

@ -99,7 +99,7 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
lead, middle, trail = match.groups()
if safe_input:
middle = mark_safe(middle)
if middle.startswith('www.') or ('@' not in middle and not middle.startswith('http://') and \
if middle.startswith('www.') or ('@' not in middle and not (middle.startswith('http://') or middle.startswith('https://')) and \
len(middle) > 0 and middle[0] in string.ascii_letters + string.digits and \
(middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))):
middle = 'http://%s' % middle

View File

@ -756,6 +756,17 @@ variable.
Note that this option is unnecessary in ``manage.py``, because it uses
``settings.py`` from the current project by default.
--traceback
-----------
Example usage::
django-admin.py syncdb --traceback
By default, ``django-admin.py`` will show a simple error message whenever an
error occurs. If you specify ``--traceback``, ``django-admin.py`` will
output a full stack trace whenever an exception is raised.
Extra niceties
==============

View File

@ -69,12 +69,10 @@ How to use ``FormPreview``
...and add the following line to the appropriate model in your URLconf::
(r'^post/$', SomeModelFormPreview(forms.models.form_for_model(SomeModel))),
Or, if you already have a Form class defined for the model::
(r'^post/$', SomeModelFormPreview(SomeModelForm)),
where ``SomeModelForm`` is a Form or ModelForm class for the model.
4. Run the Django server and visit ``/post/`` in your browser.
.. _template loader docs: ../templates_python/#loader-types

View File

@ -1527,6 +1527,36 @@ In this way, you're tying the model's absolute URL to the view that is used
to display it, without repeating the URL information anywhere. You can still
use the ``get_absolute_url`` method in templates, as before.
In some cases, such as the use of generic views or the re-use of
custom views for multiple models, specifying the view function may
confuse the reverse URL matcher (because multiple patterns point to
the same view).
For that problem, Django has **named URL patterns**. Using a named
URL pattern, it's possible to give a name to a pattern, and then
reference the name rather than the view function. A named URL
pattern is defined by replacing the pattern tuple by a call to
the ``url`` function)::
from django.conf.urls.defaults import *
url(r'^people/(\d+)/$',
'django.views.generic.list_detail.object_detail',
name='people_view'),
and then using that name to perform the reverse URL resolution instead
of the view name::
from django.db.models import permalink
def get_absolute_url(self):
return ('people_view', [str(self.id)])
get_absolute_url = permalink(get_absolute_url)
More details on named URL patterns can be found in `URL dispatch documentation`_.
.. _URL dispatch documentation: ../url_dispatch/#naming-url-patterns
Executing custom SQL
--------------------

View File

@ -1385,6 +1385,20 @@ extra arguments:
as choices.
============== ========== ===============================================
``FloatField``
~~~~~~~~~~~~~~
* Default widget: ``TextInput``
* Empty value: ``None``
* Normalizes to: A Python float.
* Validates that the given value is an float. Leading and trailing
whitespace is allowed, as in Python's ``float()`` function.
* Error message keys: ``required``, ``invalid``, ``max_value``,
``min_value``
Takes two optional arguments for validation, ``max_value`` and ``min_value``.
These control the range of values permitted in the field.
``ImageField``
~~~~~~~~~~~~~~

View File

@ -388,8 +388,13 @@ be able to give backtraces without seeing sensitive (or offensive) settings.
Still, note that there are always going to be sections of your debug output that
are inappropriate for public consumption. File paths, configuration options, and
the like all give attackers extra information about your server. Never deploy a
site with ``DEBUG`` turned on.
the like all give attackers extra information about your server.
It is also important to remember that when running with ``DEBUG`` turned on, Django
will remember every SQL query it executes. This is useful when you are debugging,
but on a production server, it will rapidly consume memory.
Never deploy a site into production with ``DEBUG`` turned on.
DEBUG_PROPAGATE_EXCEPTIONS
--------------------------
@ -958,7 +963,10 @@ See the `template documentation`_.
TEMPLATE_LOADERS
----------------
Default: ``('django.template.loaders.filesystem.load_template_source',)``
Default::
('django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source')
A tuple of callables (as strings) that know how to import templates from
various sources. See the `template documentation`_.

View File

@ -346,7 +346,7 @@ To avoid this problem, you have two options:
* One, you can make sure to run each untrusted variable through the
``escape`` filter (documented below), which converts potentially harmful
HTML characters to unharmful ones. This was default the default solution
HTML characters to unharmful ones. This was the default solution
in Django for its first few years, but the problem is that it puts the
onus on *you*, the developer / template author, to ensure you're escaping
everything. It's easy to forget to escape data.

10
extras/django_bash_completion Normal file → Executable file
View File

@ -53,9 +53,10 @@ _django_completion()
action_shell_opts="--plain"
action_runfcgi_opts="host port socket method maxspare minspare maxchildren daemonize pidfile workdir"
if [[ # django-admin.py, ./manage, manage.py
if [[ # django-admin.py, django-admin, ./manage, manage.py
( ${COMP_CWORD} -eq 1 &&
( ${COMP_WORDS[0]} == django-admin.py ||
${COMP_WORDS[0]} == django-admin ||
${COMP_WORDS[0]} == ./manage.py ||
${COMP_WORDS[0]} == manage.py ) )
||
@ -68,6 +69,11 @@ _django_completion()
( ${COMP_CWORD} -eq 2 &&
( $( basename -- ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
( $( basename -- ${COMP_WORDS[1]} ) == django-admin.py) &&
( -r ${COMP_WORDS[1]} ) )
||
( ${COMP_CWORD} -eq 2 &&
( $( basename -- ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
( $( basename -- ${COMP_WORDS[1]} ) == django-admin) &&
( -r ${COMP_WORDS[1]} ) ) ]] ; then
case ${cur} in
@ -142,7 +148,7 @@ _django_completion()
fi
}
complete -F _django_completion django-admin.py manage.py
complete -F _django_completion django-admin.py manage.py django-admin
# Support for multiple interpreters.
unset pythons

View File

@ -51,8 +51,8 @@ setup(
name = "Django",
version = version,
url = 'http://www.djangoproject.com/',
author = 'Lawrence Journal-World',
author_email = 'holovaty@gmail.com',
author = 'Django Software Foundation',
author_email = 'foundation@djangoproject.com',
description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
packages = packages,
data_files = data_files,

View File

@ -166,6 +166,27 @@ u'<a href="http://31characteruri.com/test/" rel="nofollow">http://31characteruri
>>> urlizetrunc(uri, 2)
u'<a href="http://31characteruri.com/test/" rel="nofollow">...</a>'
# Check normal urlize
>>> urlize('http://google.com')
u'<a href="http://google.com" rel="nofollow">http://google.com</a>'
>>> urlize('http://google.com/')
u'<a href="http://google.com/" rel="nofollow">http://google.com/</a>'
>>> urlize('www.google.com')
u'<a href="http://www.google.com" rel="nofollow">http://www.google.com</a>'
>>> urlize('djangoproject.org')
u'<a href="http://djangoproject.org" rel="nofollow">http://djangoproject.org</a>'
>>> urlize('info@djangoproject.org')
u'<a href="mailto:info@djangoproject.org">info@djangoproject.org</a>'
# Check urlize with https addresses
>>> urlize('https://google.com')
u'<a href="https://google.com" rel="nofollow">https://google.com</a>'
>>> wordcount('')
0

View File

@ -443,8 +443,8 @@ zero-based index.
>>> f = FrameworkForm(auto_id='id_%s')
>>> print f['language']
<ul>
<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
<li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
</ul>
When RadioSelect is used with auto_id, and the whole form is printed using
@ -453,20 +453,20 @@ ID of the *first* radio button.
>>> print f
<tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" id="id_name" /></td></tr>
<tr><th><label for="id_language_0">Language:</label></th><td><ul>
<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
<li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
</ul></td></tr>
>>> print f.as_ul()
<li><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></li>
<li><label for="id_language_0">Language:</label> <ul>
<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
<li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
</ul></li>
>>> print f.as_p()
<p><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></p>
<p><label for="id_language_0">Language:</label> <ul>
<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
<li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
<li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
</ul></p>
MultipleChoiceField is a special case, as its data is required to be a list:
@ -535,8 +535,8 @@ zero-based index.
>>> f = SongForm(auto_id='%s_id')
>>> print f['composers']
<ul>
<li><label><input type="checkbox" name="composers" value="J" id="composers_id_0" /> John Lennon</label></li>
<li><label><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li>
<li><label for="composers_id_0"><input type="checkbox" name="composers" value="J" id="composers_id_0" /> John Lennon</label></li>
<li><label for="composers_id_1"><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li>
</ul>
Data for a MultipleChoiceField should be a list. QueryDict and MultiValueDict

View File

@ -40,7 +40,7 @@ Unicode decoding problems...
... somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect(), label=u'\xc5\xf8\xdf')
>>> f = SomeForm()
>>> f.as_p()
u'<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul>\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'
u'<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul>\n<li><label for="id_somechoice_0"><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label for="id_somechoice_1"><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label for="id_somechoice_2"><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'
Testing choice validation with UTF-8 bytestrings as input (these are the
Russian abbreviations "мес." and "шт.".
@ -56,7 +56,7 @@ Translated error messages used to be buggy.
>>> activate('ru')
>>> f = SomeForm({})
>>> f.as_p()
u'<ul class="errorlist"><li>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.</li></ul>\n<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul>\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'
u'<ul class="errorlist"><li>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.</li></ul>\n<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul>\n<li><label for="id_somechoice_0"><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label for="id_somechoice_1"><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label for="id_somechoice_2"><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'
>>> deactivate()
Deep copying translated text shouldn't raise an error

View File

@ -794,20 +794,20 @@ u'<ul>\n<li><label><input checked="checked" type="radio" name="email" value="\u0
>>> w = RadioSelect(attrs={'id':'foo'})
>>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')))
<ul>
<li><label><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li>
<li><label><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li>
<li><label><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li>
<li><label><input type="radio" id="foo_3" value="R" name="beatle" /> Ringo</label></li>
<li><label for="foo_0"><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li>
<li><label for="foo_1"><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li>
<li><label for="foo_2"><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li>
<li><label for="foo_3"><input type="radio" id="foo_3" value="R" name="beatle" /> Ringo</label></li>
</ul>
# Attributes provided at render-time are passed to the constituent inputs
>>> w = RadioSelect()
>>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id':'bar'})
<ul>
<li><label><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li>
<li><label><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li>
<li><label><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li>
<li><label><input type="radio" id="bar_3" value="R" name="beatle" /> Ringo</label></li>
<li><label for="bar_0"><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li>
<li><label for="bar_1"><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li>
<li><label for="bar_2"><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li>
<li><label for="bar_3"><input type="radio" id="bar_3" value="R" name="beatle" /> Ringo</label></li>
</ul>
# CheckboxSelectMultiple Widget ###############################################

View File

@ -704,6 +704,12 @@ class Templates(unittest.TestCase):
# Inheritance from local context with variable parent template
'inheritance25': ("{% extends context_template.1 %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': [template.Template("Wrong"), template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")]}, '1234'),
# Set up a base template to extend
'inheritance26': ("no tags", {}, 'no tags'),
# Inheritance from a template that doesn't have any blocks
'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'),
### I18N ##################################################################
# {% spaceless %} tag