Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setter of class object
#1
I am trying to override setter of a class in django. I have a class shown below
class Student:
details_done = models.BooleanField(default = False)


I want to call a function every time, the value of details_done is changed. Can anybody help me find out how can this be done.
Reply
#2
Are you sure you want to do something whenever it's changed?  This sounds like something that should be done either in a validator or via a pre_save signal: https://docs.djangoproject.com/en/1.11/topics/signals/

Generally speaking, doing things just because something changed isn't a great idea.  What's "better" is making sure that the model is in a valid and complete state at the end of every transaction.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing out incidence values for Class Object SquderDragon 3 264 Apr-01-2024, 07:52 AM
Last Post: SquderDragon
  error in class: TypeError: 'str' object is not callable akbarza 2 499 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  question about using setter, getter and _ akbarza 4 673 Dec-28-2023, 09:43 PM
Last Post: deanhystad
  Python class doesn't invoke setter during __init__, not sure if's not supposed to? mtldvl 2 3,323 Dec-30-2021, 04:01 PM
Last Post: mtldvl
Exclamation win32com: How to pass a reference object into a COM server class Alfalfa 3 4,858 Jul-26-2021, 06:25 PM
Last Post: Alfalfa
  AttributeError class object has no attribute list object scttfnch 5 3,418 Feb-24-2021, 10:03 PM
Last Post: scttfnch
  Python Class and Object Parameters JoeDainton123 5 2,880 Sep-02-2020, 10:43 AM
Last Post: JoeDainton123
  Multiprocessing, class, run and a Queue Object SeanInColo 0 1,528 Jul-12-2020, 05:36 PM
Last Post: SeanInColo
  Getter/Setter : get parent attribute, but no Getter/Setter in parent nboweb 2 2,957 May-11-2020, 07:22 PM
Last Post: nboweb
  Hi, need help with class, object Houston222 1 1,824 Apr-04-2020, 01:55 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020