1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

newforms: Implemented formfield() for database ManyToManyField class and added unit tests

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4246 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2006-12-27 05:15:22 +00:00
parent 99723ac65a
commit d853278253
2 changed files with 17 additions and 0 deletions

View File

@@ -2,10 +2,12 @@ from django.db import backend, transaction
from django.db.models import signals, get_model
from django.db.models.fields import AutoField, Field, IntegerField, get_ul_class
from django.db.models.related import RelatedObject
from django.utils.text import capfirst
from django.utils.translation import gettext_lazy, string_concat, ngettext
from django.utils.functional import curry
from django.core import validators
from django import oldforms
from django import newforms as forms
from django.dispatch import dispatcher
# For Python 2.3
@@ -713,6 +715,9 @@ class ManyToManyField(RelatedField, Field):
def set_attributes_from_rel(self):
pass
def formfield(self):
return forms.MultipleChoiceField(choices=self.get_choices_default(), required=not self.blank, label=capfirst(self.verbose_name))
class ManyToOneRel(object):
def __init__(self, to, field_name, num_in_admin=3, min_num_in_admin=None,
max_num_in_admin=None, num_extra_on_change=1, edit_inline=False,