Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango wizard, using form and formset in the same step
    primarykey
    data
    text
    <p>I have a scenario which I'm trying to plan to start coding and I'm thinking to use <code>django wizard</code>. </p> <p>My plan is to build a django wizard with two steps, the first simple but the second a bit more complicated. The second step will contain a form that will reshape based on value selected from the first step, which I can see myself doing. I already explored all the existing functionality and I think it can be done easily. </p> <p>The challenge I'm facing though, is that in the second step itself. I have a form and a formset, the formset is one to many to form (Article -> Images) so when reaching the second step the user will be able to upload one or more images to the same article. </p> <p>I tried to search everywhere on google mailing lists and stackoverflow for passing a formset to the django wizard class but it seems like you can not pass two forms in the same step. </p> <pre><code>NewItemWizard.as_view([ ('category', CategorySelectionForm), ('article', ArticleForm) ]) </code></pre> <p>as seen, in the example code above, I would like to be able to pass both ArticleForm and ImageFormset to the second step. Is there a way to do this out of the box? </p> <p>Based on what I'm reading, I believe using a function like get_context_data could help, but it will be very hacky. </p> <pre><code>def get_context_data(self, form, **kwargs): context = super(NewItemWizard, self).get_context_data(form=form, **kwargs) if self.steps.current == 'article': context.update({ 'image_formset': ImageFormset() }) return context </code></pre> <p>Anyone can advise for a better approach? </p> <p>Cheers,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload