This is a Python question, not a Django question. The Python
dictionary get() function accepts a second, optional value to use as
the default for what would otherwise raise a KeyError.
Shawn
Sent from my iPhone
On Mar 24, 2010, at 1:39 AM, Daniel <unagimiy...@gmail.com> wrote:
Hi there,
I'm reading the django book and they say that you can validate a form
like this in one line, checking for missing keys and missing data:
if not request.POST.get('subject', ' ')
errors.append('enter a subject')
I'm not sure how to read that line of code, though. Can someone
explain please?
Is this checking if the subject key is blank or nil and then appending
the error?
But if the subject key is nil, then the default value for the subject
key is made to be blank (' ')?
How does this code check for a non-existent subject key and the case
that the subject key exists, but is just empty?
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.