I know there are many posts about this error. Such as: this and this one
But I knew already that. And that's why I'm getting crazy.
When I create an instance and try to save it, I don't have problems:
per_detail.preview_title = per_detail.details_sample.preview_title
per_detail.icon = per_detail.details_sample.icon
per_detail.content = fill_content(per_detail)
per_detail.save()
easy.
But when there's already the instance, and I try to save it again (updated it). Then I get this error:
match = datetime_re.match(value)TypeError: expected string or bytes-like object
whit this code:
personal_detail_sample = kwargs['instance']
personal_details = PersonalDetail.objects.filter(Q(details_sample=personal_detail_sample))
for per_detail in personal_details:
per_detail_updated = fill_updated_content(personal_detail_sample, per_detail)
per_detail_updated.save()
I gotta say, it doesn't matter where I try to update that instance, I get always the same error. (so, it's not because the kwargs['instance'])
And here's the field, that is giving troubles:
sent_date = models.DateTimeField(_('sent_date'), null=True, blank=True)
As you maybe noticed, I never filled the field "sent_date", but it should be null. So it shouldn't be a problem. And for just being safe, I also tried to do:
per_detail.sent_date = *a date*
per_detail.save()
And I'm getting the same error.
I don't have any idea what could it be.
Maybe someone can help me.
valueis not a string or bytes-like object (maybe it's Unicode, maybe it's a Django field type - didn't read you question in enough detail), in any case you should probably print its value/type/repr - or set a breakpoint and inspect it...sent_date = Nonewhich for a database would be "null" and I permit it. I made "makemigrations" and "migrate" several times, just in case, and same result. :( I don't have any idea...per_detail_updated.sent_date = datetime.datetime.now()withsent_date = 2017-03-24 20:37:48.584796(debugged) and got the same error. I'm thinking about erasing every migrations and makemigrations again...