I have a question
I use xpath to get item['releaseday']
from website.
When xpath didn't get value
It will cause error :
django.core.exceptions.ValidationError: [u"'' value has an invalid date format. It must be in YYYY-MM-DD format."]
in my models.py I set null=True and blank=True seems like not work
releaseday = models.DateField(null=True,blank=True)
I try add this code,but not work
if 'releaseday' not in item:
item['releaseday']=''
How can I edit???
Please guide me thank you
Use item.get('releaseday') or None
.
You'll solve two problems:
When the key does not exist, this will default to None
, which is valid input for your model as you have null=True
.
If the key exists but its blank ''
, then it will result in None
which is a valid value for your model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With