Removed obsolete references to form_for_instance().

This commit is contained in:
Tim Graham 2017-02-28 07:37:25 -05:00 committed by GitHub
parent 5f3a689f71
commit d6e26e5b7c
3 changed files with 0 additions and 17 deletions

View File

@ -322,13 +322,6 @@ class FileField(Field):
def formfield(self, **kwargs): def formfield(self, **kwargs):
defaults = {'form_class': forms.FileField, 'max_length': self.max_length} defaults = {'form_class': forms.FileField, 'max_length': self.max_length}
# If a file has been provided previously, then the form doesn't require
# that a new file is provided this time.
# The code to mark the form field as not required is used by
# form_for_instance, but can probably be removed once form_for_instance
# is gone. ModelForm uses a different method to check for an existing file.
if 'initial' in kwargs:
defaults['required'] = False
defaults.update(kwargs) defaults.update(kwargs)
return super().formfield(**defaults) return super().formfield(**defaults)

View File

@ -1,11 +1,3 @@
"""
XX. Generating HTML forms from models
This is mostly just a reworking of the ``form_for_model``/``form_for_instance``
tests to use ``ModelForm``. As such, the text may not make sense in all cases,
and the examples are probably a poor fit for the ``ModelForm`` syntax. In other
words, most of these tests should be rewritten.
"""
import datetime import datetime
import os import os
import tempfile import tempfile

View File

@ -1363,8 +1363,6 @@ class ModelFormBasicTests(TestCase):
'''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr> '''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>''') <tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>''')
# You can create a form over a subset of the available fields
# by specifying a 'fields' argument to form_for_instance.
class PartialArticleFormWithSlug(forms.ModelForm): class PartialArticleFormWithSlug(forms.ModelForm):
class Meta: class Meta:
model = Article model = Article