Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5850435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:08:24+00:00 2026-05-22T13:08:24+00:00

[Preamble: Whereas I realize there may be simpler ways to do this (i.e., just

  • 0

[Preamble: Whereas I realize there may be simpler ways to do this (i.e., just use Django built-in Admin, or use inlines to do all editing on one page, etc.), unfortunately, I am not in control of the designs, so I’m seeking help on how to work with what I’ve been tasked with implementing.]

I have 2 models, Deck and Slide. Slide has foreign key to Deck. (there is also an intermediate model–its a m2m relationship–but to simplify an already complex discussion, I’m going to pretend its a simpler many-to-one relationship.)

The interface i am implementing displays a page with a form to enter or edit Deck fields which also includes an embedded list of Slides in the Deck, with some fields (which I’m in the process of making text inputs) and also with an “edit” and a “remove” anchor link for each Slide. (see img) If you click an “edit” link, it takes you to a new page with a detailed form to input all the information representing the content for the corresponding slide. If you click submit in that form, it takes you back to the page for the deck.

Screen shot

As the title question proposes, I obviously don’t want to commit any Deck or Slides to the DB until a user clicks Submit for the entire Deck, i.e. they can add or edit many slides in the interim and may decide to cancel the whole process.

What is the best, cleanest way of doing this?

I’ve looked at Django’s FormWizard class ( http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/ ), but seems to be geared towards a multi-step linear flow, not my situation.

I already had to implement this for a demo, and I’ve gotten most of the way there by creating an inline FormSet for the Slides and a Form for the Deck, and then writing subclasses for my Forms that hide the form and the formset as I pass back and forth between the two pages. Here’s some code demonstrating how I use a hidden form for the deck in the slide page:

class DeckForm(ModelForm):
    class Meta:
        #stuff here

class HiddenDeckForm(DeckForm):
    def __init__(self, *args, **kwargs):
        super(DeckHiddenForm, self).__init__(*args, **kwargs)
        for name, field in self.fields.iteritems():
            field.widget = field.hidden_widget()
            field.required = False

So in my views, every time I go to the slide form page, I generate a HiddenDeckForm from the POST data and pass it in, and then in my view going back to the deck page, I regenerate the DeckForm (not hidden subclass) from the POST data. Not going to post all my Slide form code, since I’m basically asking whether there is a better way of doing it, but similarly, I have a HiddenSlideForm class, and pass a formset of those between my templates to save the state.

Then when the user clicks submit on the Deck page, the Deck form and Slides formset are all saved to the DB.

It works, but is this a good way to do it? Its been a good bit of code, and I’ve really had to dig into some Django internals–feel’s like I’m using things in a way they weren’t designed to be used. Or is there already a more standard way of handling this scenario?

I’ll post more code if its helpful.

Thanks for the help!

PS As you can see, I’m implementing it in a jquery colorbox and using ajax for the transitions between the forms, but I am just using normal template/form rendering in my views and passing the rendered html back to the page with an ajax call . . . guess I could do something with json, but strongly prefer to stick with passing a rendered template, as such an implementation could be used without ajax or javascript if desired.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:08:25+00:00Added an answer on May 22, 2026 at 1:08 pm

    Having done the very similar requirement by working around the formset tools, I completely agree that going hoops and bounds to understand/customize the formset is totally not worth it.

    For a screenshot like yours, I’d use just one form with all of the slides per deck. – Form, not formset.

    You should handle the slide “edit/delete/new” all in ajax requests that include the deck you create when someone creates a “new deck”. And then in the “Deck Form”, you only change the Deck properties like name and association.

    Or, if you are inlined to do all new elements in the page itself without Ajax and creating new “Slide” objects, you can use the formset and save the deck and all associated slides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preamble So, this question has already been answered, but as it was my first
can anyone give me more information on the following error I found in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.