2021-08-28

Django condition in save method

I got storage places which have the field amount and article. If I call save() on one place I want to set the article field to None. What is the best approach for this?

I already tried this:

    def save(self, *args, **kwargs):
    if self.amount == 0:
        self.article = None
    super(LagerPlace, self).save(*args, **kwargs)


from Recent Questions - Stack Overflow https://ift.tt/3ynx6hw
https://ift.tt/eA8V8J

No comments:

Post a Comment