Apparently the magic is:

queryset = Item.edit.filter(**kwargs).update(expires=set_expires (),is_active=True)


-- Clive

On 14 Jun 2020, at 03:24, Clive Bruton wrote:

I am trying to update an existing date field, however when I do that I get the following exception:

    Exception Type: TypeError
    Exception Value: expected string or bytes-like object

The query looks like this:

queryset = Item.edit.filter(**kwargs).update (expires=set_expires,is_active=True)

and set_expires looks like this:

    def set_expires():
        return datetime.now(timezone.utc) + timedelta(days=30)

I am using "set_expires" in the model for "Item", to set the initial value, without issue. Do I have to convert to a string when doing an update?

Thanks


-- Clive

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/ d/msgid/django-users/8B6B6771-0E9C-4E4A-A696-18CF9B7ED355% 40indx.co.uk.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/29D80E69-FDDF-4736-9AA0-2E4DBB9C972E%40indx.co.uk.

Reply via email to