> Hi all!
> I'm receiving the form from index.html and redirecting to order.html
> I would like to change "customer" value before redirection.
> When I try to modify it, Im getting "object does not support item
> assignment"
> How can I change "customer" value posted from index.html ?
> Thank you!
>
> ----------------------- models.py ---------------------
> class Order(models.Model):
> customer = models.CharField(max_length=20)
> email = models.EmailField()
> def __str__(self):
> return self.customer
>
> class OrderForm(ModelForm):
> class Meta:
> model=Order
>
> ----------------------- views.py ---------------------
> def order(request):
> form = OrderForm(request.POST)
> return render_to_response('order.html', {'form':form})
>
request.POST and request.GET are read-only MultiDicts, so if you want
to alter the contents, you would need to duplicate them, and replace
them with read-write copies:
request.POST = request.POST.copy()
request.POST['foo'] = ''bar'
Cheers
Tom
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment