supercodepoet / django-merlin Goto Github PK
View Code? Open in Web Editor NEWProviding alternate form wizards for the Django project.
License: BSD 3-Clause "New" or "Revised" License
Providing alternate form wizards for the Django project.
License: BSD 3-Clause "New" or "Revised" License
Merlin will automatically check for form errors, but if there are problems in the done method where you need to show errors, merlin does not handle the redirect properly. A good example of this is an issue we had. We were processing credit card data in our done method, if there was a problem, I was redirecting back to the last step. The problem here was Merlin was calling self.clear which was clearing all of my session data.
I'm getting an error from the Django Debug Toolbar with my wizard. I'm not saying that Django Merlin is at fault; but is my wizard missing something? I can avoid the problem if I add this to my wizard:
def __name__(self):
return self.__class__.__name__
Re: http://jeffbaier.com/blog/problem-with-django-form-wizards-and-django-debug-toolbar/
Thanks
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/core/handlers/base.py" in get_response
178. response = middleware_method(request, response)
File "/usr/lib/python2.7/site-packages/django_debug_toolbar-0.8.5-py2.7.egg/debug_toolbar/middleware.py" in process_response
110. smart_unicode(self.debug_toolbars[request].render_toolbar() + self.tag))
File "/usr/lib/python2.7/site-packages/django_debug_toolbar-0.8.5-py2.7.egg/debug_toolbar/toolbar/loader.py" in render_toolbar
78. return render_to_string('debug_toolbar/base.html', context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/loader.py" in render_to_string
183. return t.render(Context(dictionary))
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in render
123. return self._render(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/test/utils.py" in instrumented_test_render
57. return self.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/defaulttags.py" in render
227. nodelist.append(node.render(context))
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/defaulttags.py" in render
311. return self.nodelist_true.render(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/debug.py" in render
90. output = self.filter_expression.resolve(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in resolve
510. obj = self.var.resolve(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in resolve
653. value = self._resolve_lookup(context)
File "/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/template/base.py" in _resolve_lookup
698. current = current()
File "/usr/lib/python2.7/site-packages/django_debug_toolbar-0.8.5-py2.7.egg/debug_toolbar/panels/request_vars.py" in content
35. 'view_func': '%s.%s' % (self.view_func.__module__, self.view_func.__name__),
Exception Type: TemplateSyntaxError at /block/create-block
Exception Value: Caught AttributeError while rendering: 'BlockWizard' object has no attribute '__name__'
Would be really good if there was a full example, I.E. a simple django app, with:
Simple 3 step wizard, outcome of 1st step changes subsequent steps.
Why does django-merlin seem to eat exceptions and return a 404?
If I have any errors in my code that uses django-merlin, I get a 404 with no output from django's dev server? Is there something I'm doing wrong? For example currently I'm getting a 404 after initialize() is called on my subclassed wizard:
Initialise {'form_data': {}, 'current_step': create-portlet, 'steps': [create-portlet]}
def initialize(self, request, wizard_state):
print('Initialise %s' % wizard_state)
My urls.py contains:
(r'^portlets/(?P[A-Za-z0-9_-]+)$', PortletWizard([Step('create-portlet', CreatePortletForm)])),
Thanks
It would be great to provide a default slug that could be used to cancel a wizard and clear the session information in the SessionWizard. This slug could be "cancel" and if someone wanted a step that would override this they could.
If the url string contains the same name as the slug in the request path _get_url_base fails and returns only part of the base URL.
For example, I had the url /registration/business/buy-referral/referral and _get_url_base only returned /registration/business/buy-
This issue is that _get_url_base uses:
index = request.path.find(step.slug)
which returns the first instance of the slug found (in my case referral). If _get_url_base instead used:
index = request.path.rindex(step.slug)
This would have returned the proper path, since it's starts searching from the right first, where the slug would be.
slug = '/registration/business/buy-referral/referral'
slug[:slug.find('referral')]
'/registration/business/buy-'
slug[:slug.rindex('referral')]
'/registration/business/buy-referral/'
Merlin was loosing session data between steps. We are seeing this when running in a multi-threaded environment.
I created a wizard with one form. When the user submits that form, I add another step dynamically based on the user's submitted data. When the user submits this new form I want to add another step, which I can do. But how do I set initial data in that third form based on the user's data submitted in the second form? I realise this sounds complicated, so here's a simple example:
class SelectTypeForm(forms.Form):
content_type = forms.ChoiceField(choices=build_content_types(), label='Select content type')
class EnterTitleForm(forms.Form):
title = forms.CharField(max_length=128)
class EnterDescriptionForm(forms.Form):
description = forms.CharField(max_length=128)
When the user submits the EnterTitleForm I want to set an initial value for the description field in the last form based on the user's input. For example, if the user enters a title of 'hello' I want to set the description to 'welcome'.
It's a trivial nonsensical example but hopefully it clarifies my question.
Thanks
Hello dear,
Ur application is good enough to use in projects, but it would be good if can also use ModelForms in creating forms. So I just wanted to know that is it possible to use ModelForm in place of simple forms
Do you have an example of inserting a new step after the first form is submitted? I can't seem to work it out. Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.