Re: Can't make ManyToMany form fields hidden

2015-03-06 Thread Eric Abrahamsen
Collin Anderson  writes:

> https://code.djangoproject.com/ticket/24453

For posterity: I should have been using a forms.MultipleHiddenInput
widget for the ManyToManyField, rather than a plain old
forms.HiddenInput.

> On Wednesday, March 4, 2015 at 12:40:40 AM UTC-5, Eric Abrahamsen
> wrote:
>
> Hi, 
>
> I'm making some heavily customized model formsets, to encourage my
> users 
> to input data. Mostly that involves cutting down the number of
> huge 
> drop-down menus they have to go surfing through. 
>
> So I have a model like this: 
>
> class Work(models.Model): 
> authors = models.ManyToManyField
> (Author,blank=True,related_name="works") 
>
> I first present them with a pre-query form, to choose an Author,
> then 
> give them a Work modelformset with the "authors" field pre-filled
> with 
> that author. So the initial data sort of looks like: 
>
> init["authors"] = [pre_query.cleaned_data["authors"]] # must be a
> list 
>
> for i in range(0, number_of_additional_forms): 
> initial.append(init) 
>
> formset = WorkFormSet(queryset=Work.objects.none(),
> initial=initial) 
>
> Nothing unusual there. Now I want to make the "authors" field
> hidden. 
> This is both to reassure my users, and to reduce the size of the
> page -- 
> these are really long dropdowns. 
>
> Adding the hidden widget to the "authors" field, however, gives me
> this 
> validation error: 
>
> (Hidden field authors) Enter a list of values. 
>
> The form input field looks like this: 
>
>  value="[37L]" /> 
>
> Looks like a list of values to me, but maybe it's not getting read
> that 
> way. 
>
> In the meantime it's not a disaster if the monster "authors"
> dropdown is 
> visible for each of my Work forms, but it would be really nice to 
> eventually get it hidden. 
>
> In the past I did this by manually *removing* fields from the
> forms, and 
> adding the values in during the POST/save process, but that always
> felt 
> bad to me. 
>
> Thanks! 
> Eric 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87bnk58js3.fsf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't make ManyToMany form fields hidden

2015-03-06 Thread Collin Anderson
https://code.djangoproject.com/ticket/24453

On Wednesday, March 4, 2015 at 12:40:40 AM UTC-5, Eric Abrahamsen wrote:
>
> Hi, 
>
> I'm making some heavily customized model formsets, to encourage my users 
> to input data. Mostly that involves cutting down the number of huge 
> drop-down menus they have to go surfing through. 
>
> So I have a model like this: 
>
> class Work(models.Model): 
>   authors = models.ManyToManyField(Author,blank=True,related_name="works") 
>
> I first present them with a pre-query form, to choose an Author, then 
> give them a Work modelformset with the "authors" field pre-filled with 
> that author. So the initial data sort of looks like: 
>
> init["authors"] = [pre_query.cleaned_data["authors"]] # must be a list 
>
> for i in range(0, number_of_additional_forms): 
>   initial.append(init) 
>
> formset = WorkFormSet(queryset=Work.objects.none(), initial=initial) 
>
> Nothing unusual there. Now I want to make the "authors" field hidden. 
> This is both to reassure my users, and to reduce the size of the page -- 
> these are really long dropdowns. 
>
> Adding the hidden widget to the "authors" field, however, gives me this 
> validation error: 
>
> (Hidden field authors) Enter a list of values. 
>
> The form input field looks like this: 
>
>  value="[37L]" /> 
>
> Looks like a list of values to me, but maybe it's not getting read that 
> way. 
>
> In the meantime it's not a disaster if the monster "authors" dropdown is 
> visible for each of my Work forms, but it would be really nice to 
> eventually get it hidden. 
>
> In the past I did this by manually *removing* fields from the forms, and 
> adding the values in during the POST/save process, but that always felt 
> bad to me. 
>
> Thanks! 
> Eric 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53c18174-9439-462d-8a8e-34783a065bcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can't make ManyToMany form fields hidden

2015-03-03 Thread Eric Abrahamsen
Hi,

I'm making some heavily customized model formsets, to encourage my users
to input data. Mostly that involves cutting down the number of huge
drop-down menus they have to go surfing through.

So I have a model like this:

class Work(models.Model):
  authors = models.ManyToManyField(Author,blank=True,related_name="works")

I first present them with a pre-query form, to choose an Author, then
give them a Work modelformset with the "authors" field pre-filled with
that author. So the initial data sort of looks like:

init["authors"] = [pre_query.cleaned_data["authors"]] # must be a list

for i in range(0, number_of_additional_forms):
  initial.append(init)

formset = WorkFormSet(queryset=Work.objects.none(), initial=initial)

Nothing unusual there. Now I want to make the "authors" field hidden.
This is both to reassure my users, and to reduce the size of the page --
these are really long dropdowns.

Adding the hidden widget to the "authors" field, however, gives me this
validation error:

(Hidden field authors) Enter a list of values.

The form input field looks like this:



Looks like a list of values to me, but maybe it's not getting read that
way.

In the meantime it's not a disaster if the monster "authors" dropdown is
visible for each of my Work forms, but it would be really nice to
eventually get it hidden.

In the past I did this by manually *removing* fields from the forms, and
adding the values in during the POST/save process, but that always felt
bad to me.

Thanks!
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87lhjdjpay.fsf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.