geraldcor
unread,Dec 1, 2009, 9:29:38 PM12/1/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
No normally I can use something lie /foo/edit/35/ and I can edit the
record whose pk is 35. Now with this, I have a url pattern like
(r'^edit/(?P<ssf_id>\d+)/$', 'edit'), which points to def edit
(request, ssf_id): in my views.py.
For my formwizard, by overriding various methods I have successfully
made it so that I can edit an instance by using a view to capture the
above url pattern and instead of passing it to 'edit' I pass it to
'edit_wizard' which looks like this:
@login_required
def edit_wizard(request, ssf_id):
instance = get_object_or_404(SSF, pk=ssf_id)
return EDIT_SSFWizard([SSF1, SSF2, SSF3])(request, instance=instance)
This works perfectly. However, there has been a request to have a
listing of the items that the user has already selected so they can
easily see what they have or maybe left off.
Normally I would use something like s=SSF.objects.filter(id=ssf_id)
using the variable from the url and then pass that as a context to the
template so I have my form instance as well as a context full of data.
So I keep putting ssf_id in various methods in my formwizard class to
only have error after error. Any ideas on how to pass this other
variable so I can use the variable to perform a query as below (line
3):
def render_template(self, request, form, previous_fields, step,
max_step, context=None):
context = context or {}
----------------context=SSF.objects.filter(pk=ssf_id).values
()--------------------------Look at this Line please
return render_to_response(self.get_template(step), dict
(context=context,
next_step_field=self.next_step_field_name,
max_step_field=self.max_step_field_name,
max_step=max_step,
step_field=self.step_field_name,
step0=step,
step=step + 1,
step_count=self.num_steps(),
form=form,
previous_fields=previous_fields
), context_instance=RequestContext(request))