Django document said the QueryDict is only immutable, but why I can edit it sometimes
Django document said the QueryDict is only immutable, but why I can
edit it sometimes
The codes is almost the same, for example following,
The first kind of condition, the item I want to edit is not a field of
form.
I add a Captcha when user register or login, the querydict is mutable
when registering
if request.method == 'POST':
data = request.POST
data['captcha_text'] = Captcha(request).get()
But the same code when do login, the querydict is immutable, it is
must be create a copy
if request.method == "POST":
data = request.POST.copy()
data['captcha_text'] = Captcha(request).get()
The second kind of condition, the item I want to edit is a field of
form, but in fact I think it has no relation with form.
user = request.user
if request.method == "POST":
data = request.POST
data['title'] = data['title'].strip()
now = datetime.datetime.now()
topic = Topic(id = _md5_key(now, user.username), profile =
user.get_profile(), \
It is ok, but when I do this in other view, then django tell me the
querydict is immutable.
if request.method == 'POST':
data = request.POST
print data, '\n\n'
data['name'] = data['name'].strip()
print data, '\n\n'
What's difference ?
Thanks
--
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.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home