Skip to content
Advertisement

Change boolean data when adding new registration

In this piece of code l want to change the boolean data of room when adding new registration For example: when l add new registration in django admin the boolean data of room should change to False

JavaScript

Advertisement

Answer

You should use Django’s signals for that. Just create signals.py in your app’s folder and do that:

JavaScript

and add to your apps.py file in same app:

JavaScript

That signal will change proper Registration related Rooms object’s room_bool to False when it was saved during creation.

PS always name your model with singular version. Look how awfully looks Rooms when you actually talk about single room ;)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement