Fixed #7741: django.newforms is now django.forms. This is obviously a backwards-incompatible change. There's a warning upon import of django.newforms itself, but deeper imports will raise errors.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2008-07-19 01:22:26 +00:00
parent 39af2738fd
commit 46786b4193
60 changed files with 133 additions and 128 deletions

View File

@ -1,8 +1,8 @@
from django import oldforms, template
from django import newforms as forms
from django.newforms.formsets import all_valid
from django.newforms.models import modelform_factory, inlineformset_factory
from django.newforms.models import BaseInlineFormset
from django import forms
from django.forms.formsets import all_valid
from django.forms.models import modelform_factory, inlineformset_factory
from django.forms.models import BaseInlineFormset
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin import widgets
from django.contrib.admin.util import quote, unquote, get_deleted_objects
@ -775,11 +775,11 @@ class InlineAdminForm(AdminForm):
return AdminField(self.form, self.formset._pk_field_name, False)
def deletion_field(self):
from django.newforms.formsets import DELETION_FIELD_NAME
from django.forms.formsets import DELETION_FIELD_NAME
return AdminField(self.form, DELETION_FIELD_NAME, False)
def ordering_field(self):
from django.newforms.formsets import ORDERING_FIELD_NAME
from django.forms.formsets import ORDERING_FIELD_NAME
return AdminField(self.form, ORDERING_FIELD_NAME, False)
class AdminErrorList(forms.util.ErrorList):

View File

@ -1,7 +1,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.newforms.models import BaseModelForm, BaseModelFormSet, fields_for_model
from django.forms.models import BaseModelForm, BaseModelFormSet, fields_for_model
from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin
from django.contrib.admin.options import HORIZONTAL, VERTICAL

View File

@ -4,9 +4,9 @@ Form Widget classes specific to the Django admin site.
import copy
from django import newforms as forms
from django.newforms.widgets import RadioFieldRenderer
from django.newforms.util import flatatt
from django import forms
from django.forms.widgets import RadioFieldRenderer
from django.forms.util import flatatt
from django.utils.datastructures import MultiValueDict
from django.utils.text import capfirst, truncate_words
from django.utils.translation import ugettext as _

View File

@ -3,7 +3,7 @@ from django.contrib.auth import authenticate
from django.contrib.sites.models import Site
from django.template import Context, loader
from django.core import validators
from django import newforms as forms
from django import forms
from django.utils.translation import ugettext_lazy as _
class UserCreationForm(forms.ModelForm):

View File

@ -1,4 +1,4 @@
from django import newforms as forms
from django import forms
from django.contrib.formtools import preview
from django import http
from django.conf import settings

View File

@ -4,7 +4,7 @@ step and storing the form's state as HTML hidden fields so that no state is
stored on the server side.
"""
from django import newforms as forms
from django import forms
from django.conf import settings
from django.http import Http404
from django.shortcuts import render_to_response

View File

@ -3,8 +3,8 @@
AR-specific Form helpers.
"""
from django.newforms import ValidationError
from django.newforms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _

View File

@ -2,9 +2,9 @@
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.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms.util import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -3,8 +3,8 @@
BR-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, CharField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, CharField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -2,9 +2,9 @@
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.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms.util import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -2,8 +2,8 @@
Swiss-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -2,8 +2,8 @@
Chile specific form helpers.
"""
from django.newforms import ValidationError
from django.newforms.fields import RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode

View File

@ -2,8 +2,8 @@
DE-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -3,8 +3,8 @@
Spanish-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -3,8 +3,8 @@ FI-specific Form helpers
"""
import re
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
class FIZipCodeField(RegexField):

View File

@ -2,8 +2,8 @@
FR-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -1,4 +1,4 @@
from django import newforms as forms
from django import forms
DEFAULT_DATE_INPUT_FORMATS = (
'%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06'

View File

@ -2,8 +2,8 @@
India-specific Form helpers.
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import gettext
import re

View File

@ -2,9 +2,9 @@
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.forms import ValidationError
from django.forms.fields import RegexField, EMPTY_VALUES
from django.forms.widgets import Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode

View File

@ -2,8 +2,8 @@
IT-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
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

View File

@ -3,9 +3,9 @@ JP-specific Form helpers
"""
from django.core import validators
from django.newforms import ValidationError
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.newforms.fields import RegexField, Select
from django.forms.fields import RegexField, Select
class JPPostalCodeField(RegexField):
"""

View File

@ -2,7 +2,7 @@
Mexican-specific form helpers.
"""
from django.newforms.fields import Select
from django.forms.fields import Select
class MXStateSelect(Select):
"""

View File

@ -4,8 +4,8 @@ NL-specific Form helpers
import re
from django.newforms import ValidationError
from django.newforms.fields import Field, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode

View File

@ -3,8 +3,8 @@ Norwegian-specific Form helpers
"""
import re, datetime
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
class NOZipCodeField(RegexField):

View File

@ -3,8 +3,8 @@
PE-specific Form helpers.
"""
from django.newforms import ValidationError
from django.newforms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, CharField, Select, EMPTY_VALUES
from django.utils.translation import ugettext_lazy as _
class PEDepartmentSelect(Select):

View File

@ -4,8 +4,8 @@ Polish-specific form helpers
import re
from django.newforms import ValidationError
from django.newforms.fields import Select, RegexField
from django.forms import ValidationError
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
class PLVoivodeshipSelect(Select):

View File

@ -2,7 +2,7 @@
Slovak-specific form helpers
"""
from django.newforms.fields import Select, RegexField
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
class SKRegionSelect(Select):

View File

@ -4,8 +4,8 @@ UK-specific Form helpers
import re
from django.newforms.fields import CharField, Select
from django.newforms import ValidationError
from django.forms.fields import CharField, Select
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
class UKPostcodeField(CharField):

View File

@ -2,8 +2,8 @@
USA-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re

View File

@ -2,8 +2,8 @@
South Africa-specific Form helpers
"""
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, EMPTY_VALUES
from django.utils.checksums import luhn
from django.utils.translation import gettext as _
import re

View File

@ -14,7 +14,7 @@ from django.dispatch import dispatcher
from django.conf import settings
from django.core import validators
from django import oldforms
from django import newforms as forms
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.utils.datastructures import DictWrapper
from django.utils.functional import curry
@ -411,7 +411,7 @@ class Field(object):
setattr(instance, self.name, data)
def formfield(self, form_class=forms.CharField, **kwargs):
"Returns a django.newforms.Field instance for this database Field."
"Returns a django.forms.Field instance for this database Field."
defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
if self.choices:
defaults['widget'] = forms.Select(choices=self.get_choices(include_blank=self.blank or not (self.has_default() or 'initial' in kwargs)))

View File

@ -9,7 +9,7 @@ from django.utils.functional import curry
from django.utils.encoding import smart_unicode
from django.core import validators
from django import oldforms
from django import newforms as forms
from django import forms
from django.dispatch import dispatcher
try:

View File

@ -1 +1,17 @@
from django.oldforms import *
"""
Django validation and HTML form handling.
TODO:
Default value for field
Field labels
Nestable Forms
FatalValidationError -- short-circuits all other validators on a form
ValidationWarning
"This form field requires foo.js" and form.js_includes()
"""
from util import ValidationError
from widgets import *
from fields import *
from forms import *
from models import *

View File

@ -5,7 +5,7 @@ Extra HTML Widget classes
import datetime
import re
from django.newforms.widgets import Widget, Select
from django.forms.widgets import Widget, Select
from django.utils.dates import MONTHS
from django.utils.safestring import mark_safe

View File

@ -1,18 +1,7 @@
"""
Django validation and HTML form handling.
TODO:
Default value for field
Field labels
Nestable Forms
FatalValidationError -- short-circuits all other validators on a form
ValidationWarning
"This form field requires foo.js" and form.js_includes()
"""
from util import ValidationError
from widgets import *
from fields import *
from forms import *
from models import *
from formsets import *
import warnings
warnings.warn(
category = DeprecationWarning,
message = "django.newforms is no longer new. Import django.forms instead.",
stacklevel = 2
)
from django.forms import *

View File

@ -1,4 +1,4 @@
from django.newforms.models import ModelFormMetaclass, ModelForm
from django.forms.models import ModelFormMetaclass, ModelForm
from django.template import RequestContext, loader
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.core.xheaders import populate_xheaders

View File

@ -155,7 +155,7 @@ False
[<Article: John's second story>, <Article: This is a test>]
# And should work fine with the unicode that comes out of
# newforms.Form.cleaned_data
# forms.Form.cleaned_data
>>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_reporter.last_name='%s'" % u'Smith'])
[<Article: John's second story>, <Article: This is a test>]

View File

@ -79,8 +79,8 @@ class ImageFile(models.Model):
return self.description
__test__ = {'API_TESTS': """
>>> from django import newforms as forms
>>> from django.newforms.models import ModelForm
>>> from django import forms
>>> from django.forms.models import ModelForm
>>> from django.core.files.uploadedfile import SimpleUploadedFile
The bare bones, absolutely nothing custom, basic case.
@ -113,7 +113,7 @@ Replacing a field.
... model = Category
>>> CategoryForm.base_fields['url'].__class__
<class 'django.newforms.fields.BooleanField'>
<class 'django.forms.fields.BooleanField'>
Using 'fields'.
@ -211,7 +211,7 @@ We can also subclass the Meta inner class to change the fields list.
# Old form_for_x tests #######################################################
>>> from django.newforms import ModelForm, CharField
>>> from django.forms import ModelForm, CharField
>>> import datetime
>>> Category.objects.all()
@ -605,7 +605,7 @@ the data in the database when the form is instantiated.
# ModelChoiceField ############################################################
>>> from django.newforms import ModelChoiceField, ModelMultipleChoiceField
>>> from django.forms import ModelChoiceField, ModelMultipleChoiceField
>>> f = ModelChoiceField(Category.objects.all())
>>> list(f.choices)

View File

@ -26,7 +26,7 @@ __test__ = {'API_TESTS': """
>>> from datetime import date
>>> from django.newforms.models import modelformset_factory
>>> from django.forms.models import modelformset_factory
>>> qs = Author.objects.all()
>>> AuthorFormSet = modelformset_factory(Author, extra=3)
@ -227,7 +227,7 @@ used.
We can also create a formset that is tied to a parent model. This is how the
admin system's edit inline functionality works.
>>> from django.newforms.models import inlineformset_factory
>>> from django.forms.models import inlineformset_factory
>>> AuthorBooksFormSet = inlineformset_factory(Author, Book, can_delete=False, extra=3)
>>> author = Author.objects.get(name='Charles Baudelaire')

View File

@ -4,8 +4,8 @@ from django.core.mail import EmailMessage, SMTPConnection
from django.template import Context, Template
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.contrib.auth.decorators import login_required, permission_required
from django.newforms.forms import Form
from django.newforms import fields
from django.forms.forms import Form
from django.forms import fields
from django.shortcuts import render_to_response
def get_view(request):

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
tests = r"""
>>> from django.newforms import *
>>> from django.forms import *
>>> from django.core.files.uploadedfile import SimpleUploadedFile
# CharField ###################################################################

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
tests = r"""
>>> from django.newforms import *
>>> from django.forms import *
>>> from django.utils.encoding import force_unicode
>>> import datetime
>>> import time
@ -14,12 +14,12 @@ tests = r"""
# Extra stuff #
###############
The newforms library comes with some extra, higher-level Field and Widget
The forms library comes with some extra, higher-level Field and Widget
classes that demonstrate some of the library's abilities.
# SelectDateWidget ############################################################
>>> from django.newforms.extras import SelectDateWidget
>>> from django.forms.extras import SelectDateWidget
>>> w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'))
>>> print w.render('mydate', '')
<select name="mydate_month" id="id_mydate_month">
@ -424,7 +424,7 @@ u'sirrobin'
# Test overriding ErrorList in a form #
#######################################
>>> from django.newforms.util import ErrorList
>>> from django.forms.util import ErrorList
>>> class DivErrorList(ErrorList):
... def __unicode__(self):
... return self.as_divs()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
tests = r"""
>>> from django.newforms import *
>>> from django.newforms.widgets import RadioFieldRenderer
>>> from django.forms import *
>>> from django.forms.widgets import RadioFieldRenderer
>>> from django.core.files.uploadedfile import SimpleUploadedFile
>>> import datetime
>>> import time
@ -17,7 +17,7 @@ tests = r"""
##########
Each Field class does some sort of validation. Each Field has a clean() method,
which either raises django.newforms.ValidationError or returns the "clean"
which either raises django.forms.ValidationError or returns the "clean"
data -- usually a Unicode object, but, in some rare cases, a list.
Each Field's __init__() takes at least these parameters:
@ -1153,29 +1153,29 @@ u''
... return x
...
>>> import os
>>> from django import newforms as forms
>>> from django import forms
>>> path = forms.__file__
>>> path = os.path.dirname(path) + '/'
>>> fix_os_paths(path)
'.../django/newforms/'
'.../django/forms/'
>>> f = forms.FilePathField(path=path)
>>> f.choices.sort()
>>> fix_os_paths(f.choices)
[('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/__init__.pyc', '__init__.pyc'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/fields.pyc', 'fields.pyc'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/forms.pyc', 'forms.pyc'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/models.pyc', 'models.pyc'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/util.pyc', 'util.pyc'), ('.../django/newforms/widgets.py', 'widgets.py'), ('.../django/newforms/widgets.pyc', 'widgets.pyc')]
[('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/__init__.pyc', '__init__.pyc'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/fields.pyc', 'fields.pyc'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/forms.pyc', 'forms.pyc'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/models.pyc', 'models.pyc'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/util.pyc', 'util.pyc'), ('.../django/forms/widgets.py', 'widgets.py'), ('.../django/forms/widgets.pyc', 'widgets.pyc')]
>>> f.clean('fields.py')
Traceback (most recent call last):
...
ValidationError: [u'Select a valid choice. That choice is not one of the available choices.']
>>> fix_os_paths(f.clean(path + 'fields.py'))
u'.../django/newforms/fields.py'
u'.../django/forms/fields.py'
>>> f = forms.FilePathField(path=path, match='^.*?\.py$')
>>> f.choices.sort()
>>> fix_os_paths(f.choices)
[('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')]
[('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/widgets.py', 'widgets.py')]
>>> f = forms.FilePathField(path=path, recursive=True, match='^.*?\.py$')
>>> f.choices.sort()
>>> fix_os_paths(f.choices)
[('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/extras/__init__.py', 'extras/__init__.py'), ('.../django/newforms/extras/widgets.py', 'extras/widgets.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')]
[('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/extras/__init__.py', 'extras/__init__.py'), ('.../django/forms/extras/widgets.py', 'extras/widgets.py'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/widgets.py', 'widgets.py')]
# SplitDateTimeField ##########################################################

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
tests = r"""
>>> from django.newforms import *
>>> from django.forms import *
>>> from django.core.files.uploadedfile import SimpleUploadedFile
>>> import datetime
>>> import time

View File

@ -5,8 +5,8 @@ tests = """
FormSet allows us to use multiple instance of the same form on 1 page. For now,
the best way to create a FormSet is by using the formset_factory function.
>>> from django.newforms import Form, CharField, IntegerField, ValidationError
>>> from django.newforms.formsets import formset_factory, BaseFormSet
>>> from django.forms import Form, CharField, IntegerField, ValidationError
>>> from django.forms.formsets import formset_factory, BaseFormSet
>>> class Choice(Form):
... choice = CharField()

View File

@ -2,7 +2,7 @@
# Tests for the media handling on widgets and forms
media_tests = r"""
>>> from django.newforms import TextInput, Media, TextInput, CharField, Form, MultiWidget
>>> from django.forms import TextInput, Media, TextInput, CharField, Form, MultiWidget
>>> from django.conf import settings
>>> ORIGINAL_MEDIA_URL = settings.MEDIA_URL
>>> settings.MEDIA_URL = 'http://media.example.com/media/'

View File

@ -15,7 +15,7 @@ class ChoiceModel(models.Model):
name = models.CharField(max_length=10)
__test__ = {'API_TESTS': """
>>> from django.newforms import form_for_model, form_for_instance
>>> from django.forms import form_for_model, form_for_instance
# Boundary conditions on a PostitiveIntegerField #########################
>>> BoundaryForm = form_for_model(BoundaryModel)

View File

@ -3,7 +3,7 @@
tests = r"""
It should be possible to re-use attribute dictionaries (#3810)
>>> from django.newforms import *
>>> from django.forms import *
>>> extra_attrs = {'class': 'special'}
>>> class TestForm(Form):
... f1 = CharField(max_length=10, widget=TextInput(attrs=extra_attrs))

View File

@ -1,17 +1,17 @@
# coding: utf-8
"""
Tests for newforms/util.py module.
Tests for forms/util.py module.
"""
tests = r"""
>>> from django.newforms.util import *
>>> from django.forms.util import *
>>> from django.utils.translation import ugettext_lazy
###########
# flatatt #
###########
>>> from django.newforms.util import flatatt
>>> from django.forms.util import flatatt
>>> flatatt({'id': "header"})
u' id="header"'
>>> flatatt({'class': "news", 'title': "Read this"})

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
tests = r"""
>>> from django.newforms import *
>>> from django.newforms.widgets import RadioFieldRenderer
>>> from django.forms import *
>>> from django.forms.widgets import RadioFieldRenderer
>>> from django.utils.safestring import mark_safe
>>> import datetime
>>> import time

View File

@ -15,7 +15,7 @@ class Child(models.Model):
__test__ = {'API_TESTS': """
>>> from django.newforms.models import inlineformset_factory
>>> from django.forms.models import inlineformset_factory
Child has two ForeignKeys to Parent, so if we don't specify which one to use

View File

@ -119,7 +119,7 @@ displayed because you forgot to add it to fields/fielsets
If we specify a form, it should use it allowing custom validation to work
properly. This won't, however, break any of the admin widgets or media.
>>> from django import newforms as forms
>>> from django import forms
>>> class AdminBandForm(forms.ModelForm):
... delete = forms.BooleanField()
...
@ -174,22 +174,22 @@ the choices lists have a first entry of dashes.
>>> cmafa = cma.get_form(request)
>>> type(cmafa.base_fields['main_band'].widget.widget)
<class 'django.newforms.widgets.Select'>
<class 'django.forms.widgets.Select'>
>>> list(cmafa.base_fields['main_band'].widget.choices)
[(u'', u'---------'), (1, u'The Doors')]
>>> type(cmafa.base_fields['opening_band'].widget.widget)
<class 'django.newforms.widgets.Select'>
<class 'django.forms.widgets.Select'>
>>> list(cmafa.base_fields['opening_band'].widget.choices)
[(u'', u'---------'), (1, u'The Doors')]
>>> type(cmafa.base_fields['day'].widget)
<class 'django.newforms.widgets.Select'>
<class 'django.forms.widgets.Select'>
>>> list(cmafa.base_fields['day'].widget.choices)
[('', '---------'), (1, 'Fri'), (2, 'Sat')]
>>> type(cmafa.base_fields['transport'].widget)
<class 'django.newforms.widgets.Select'>
<class 'django.forms.widgets.Select'>
>>> list(cmafa.base_fields['transport'].widget.choices)
[('', '---------'), (1, 'Plane'), (2, 'Train'), (3, 'Bus')]
@ -849,7 +849,7 @@ ImproperlyConfigured: `ValidationTestInline.max_num` should be a integer.
# formset
>>> from django.newforms.models import BaseModelFormSet
>>> from django.forms.models import BaseModelFormSet
>>> class FakeFormSet(object):
... pass

View File

@ -1,5 +1,5 @@
from django.http import HttpResponse
import django.newforms as forms
from django import forms
from django.views.generic.create_update import create_object
from models import Article