[Django] #23672: Add “instances” argument to BaseModelFomset.__init__()

25 views
Skip to first unread message

Django

unread,
Oct 17, 2014, 8:42:37 AM10/17/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomset.__init__()
-----------------------------+------------------------------
Reporter: aki33524 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Keywords: BaseModelFormset
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------
There are two reasons.

First, as you know, ModelForm can accept instance as keyword arguments.
I think that BaseModelFormSet should follow this. Current BaseModelFormSet
support save(commit=False), which returns “instances”. But now, we cannot
use it without saving in DataBase.

Second, Current BaseModelFormSet accepts “queryset” as keyword argument.
“queryset” can convert to “instances”, but “instances” cannot convert to
“queryset”. I think that BaseModelFormSet should accept not “queryset” but
“instances”.

For downward compatible, it would be difficult that “instances” replace
with “queryset”. So I suggest adding “instances” argument to
BaseModelFormSet __init__.

--
Ticket URL: <https://code.djangoproject.com/ticket/23672>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 17, 2014, 8:46:04 AM10/17/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------

Reporter: aki33524 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Resolution:

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by aki33524):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:1>

Django

unread,
Oct 17, 2014, 11:14:14 AM10/17/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------

Reporter: aki33524 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Resolution:

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Description changed by aki33524:

Old description:

> There are two reasons.
>
> First, as you know, ModelForm can accept instance as keyword arguments.
> I think that BaseModelFormSet should follow this. Current
> BaseModelFormSet support save(commit=False), which returns “instances”.
> But now, we cannot use it without saving in DataBase.
>
> Second, Current BaseModelFormSet accepts “queryset” as keyword argument.
> “queryset” can convert to “instances”, but “instances” cannot convert to
> “queryset”. I think that BaseModelFormSet should accept not “queryset”
> but “instances”.
>
> For downward compatible, it would be difficult that “instances” replace
> with “queryset”. So I suggest adding “instances” argument to
> BaseModelFormSet __init__.

New description:

There are two reasons.

First, as you know, ModelForm can accept instance as keyword arguments.
I think that BaseModelFormSet should follow this. Current BaseModelFormSet
support save(commit=False), which returns “instances”. But now, we cannot

use it without INSERT in DataBase..

Second, Current BaseModelFormSet accepts “queryset” as keyword argument.
“queryset” can convert to “instances”, but “instances” cannot convert to
“queryset”. I think that BaseModelFormSet should accept not “queryset” but
“instances”.

For downward compatible, it would be difficult that “instances” replace
with “queryset”. So I suggest adding “instances” argument to
BaseModelFormSet __init__.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:2>

Django

unread,
Oct 20, 2014, 9:59:03 PM10/20/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------

Reporter: aki33524 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Resolution:

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by collinanderson):

Are you just proposing a name change, or would it function different than
how `queryset` currently functions?

--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:3>

Django

unread,
Oct 21, 2014, 2:45:24 AM10/21/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------

Reporter: aki33524 | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Resolution:

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by aki33524):

Replying to [comment:3 collinanderson]:


> Are you just proposing a name change, or would it function different
than how `queryset` currently functions?

A 'QuerySet' represents a collection of objects from your database.
{{{
AuthorFormSet = modelformset_factory(Author, max_num=1)
formset =
AuthorFormSet(queryset=Author.objects.filter(name__startswith='O'))
}}}

On the other hand, 'instances' which I propose, DON'T NEED to be INSERTed
in database.
{{{
AuthorFormSet = modelformset_factory(Author, max_num=1)
instances = [Author() for i in range(10)]
formset = AuthorFormSet(instances=instances)
}}}

It follows ModelForm.
{{{
a = Author()
f = AuthorForm(request.POST, instance=a)
}}}

For example, I tryed to store 'instances', which is returned by
formset.save(commit=False), in session. In other words, instances don't be
INSERTed. Then I want to INSERT these instances in database at last.This
application can modify these instances, current BaseModelFormSet cannot do
it.

--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:4>

Django

unread,
Oct 23, 2014, 3:12:38 PM10/23/14
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------
Reporter: aki33524 | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 1.7
Severity: Normal | Resolution: wontfix

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => wontfix


Comment:

I think your use case could be solved by using
[https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#providing-
initial-values initial data] and
[https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-
the-queryset an empty QuerySet]. I don't think adding more complexity to
formsets is the answer, but if I've missing something please reopen with
more details. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:5>

Django

unread,
Feb 23, 2016, 1:49:10 AM2/23/16
to django-...@googlegroups.com
#23672: Add “instances” argument to BaseModelFomSet.__init__()
----------------------------------+--------------------------------------
Reporter: aki33524 | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 1.7
Severity: Normal | Resolution: wontfix

Keywords: BaseModelFormset | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by TZanke):

* cc: tzanke@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23672#comment:6>

Reply all
Reply to author
Forward
0 new messages