How can I put one smear into another?

I am implementing a web-app using Django v1.9. I need the deployment and configuration of the site to be as reliable as possible.

So, I want to implement the First Use script, which allows the site administrator to configure the site through the site itself.

The obvious candidate for this is the Masters of Forms.

The site requires several configured resources. It can have multiple instances of each resource, but must have at least one instance of each.

Thus, the minimum sequence of first use may be:

  • Configure ResourceA Instance
  • Configure ResourceB Instance
  • Make these active instances.
  • Make a one-time setup

Subsequently, the administrator must define other instances of these resources, and steps 1 and 2 above are complex enough for each of them to guarantee their own FormWizard ; especially because they must be used independently to configure additional instances of each type of resource.

This means that my first use scenario is actually

  • Launch First-Time Use Wizard
    • Run the Add Resource 1 Instance Wizard
    • Run the "Add Resource 2 Instance Wizard"
    • Do other disposable things in several more forms.
  • First Time Wizard

My heart tells me that I have to die in the nest of wizards, getting good reuse of functionality. Django and Python in general are all about DRY.

But I'm at a dead end trying to figure out how to do this. I experimented and experimented many times so as not to feel anything there.

Can this be done? If so, how?

EDIT:

Try and clarify. Suppose that each master had a view associated with it based on a function.

 def AddResource1view(request): # Display the pages of the wizard to build object 1 # for model Resource1 object1.save() return object1 def AddResource2view(request): # Display the pages of the wizard to build object 2 # for model Resource2 object2.save() return object2 def FirstUseView(request): config = SystemConfiguration() config.r1 = AddResource1view(request) config.r2 = AddResource2view(request) # NOw step through the remaining pages of FirstUse wizard # filling out config ... config.save() 

My urls.py will have URLs pointing to each of the three views (via FormWizard.as_view() ). Thus, you can run any of the resource wizards independently or as part of the external FirstUse wizard.

Obviously, this is not real code - it just gives an idea of ​​what I mean by nesting.

+5
source share

All Articles