Thursday, October 14, 2010

Re: modelformset_factory, initial, and queryset

On Oct 14, 10:32 am, Tim Valenta <tonightslasts...@gmail.com> wrote:
> This is driving me mad, so I must ask the community, in hopes of a
> workaround:
>
> I've got a simple formset of models on a page, generated by
> modelformset_factory.  This particular page will never create forms--
> it only modifies existing ones.  Therefore the queryset I pass into
> the formset constructor gets built, and everything works great.
>
> I've added a field to the formset, but Django seems perfectly happy to
> totally ignore whatever initial data I want to supply for this
> 'virtual' field that I've added.  It seems that I've got absolutely no
> mechanism for setting a dynamically-generated value as a pre-computed
> field value.
>
> My situation is that I want to represent an many-to-many relationship
> on this 'virtual' field, which doesn't actually exist on my model.
> When the form is submitted, I can easily intercept the values sent and
> do what I will with them.  However, when the page refreshes after a
> submission, I cannot for the life of me inject this data back into the
> form.  As of right now, my select-multiple widget is quite blank, no
> matter what I do.
>
> Help?  I've literally been at this for hours off and on.

Can you show some code? It would help to understand what you're doing.
--
DR.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate