About Dynamic Class Attributes
Using __getattr__
on a class, you can define attributes dynamically, for example, coming from a configuration dictionary, JSON file, database, or external API.
1 2 3 4 5 6 7 8 9 10 11 |
|
Then you can get any value from the class or settings dictionary by doing this:
1 2 3 4 |
|
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You