Open ramast opened 4 years ago
URL: https://github.com/rewardz/django_model_helpers/
Installation: pip install django-model-helpers
Looks really exciting! I want to use it!
I have some questions about package and project infrastructure. Please see my quick issue at https://github.com/rewardz/django_model_helpers/issues/7
Django approach
django_model_helpers approach
Usage:
Why second approach is favourable over first one?
Then you can do
Choices
class is basically a dictionary, you can json serialize it - as it is - for mobile developers to know what options are availableMoreover, your API can continue using the "code names" of your choices in API requests/responses. For example:
When returning API data regarding your order, you don't need to show its internal database value
Finally django_model_helpers has other useful functions that make your life much easier.
For example:
upload_to
It will automatically create folder for your files (configurable), will do validations to ensure users don't upload dangerous files like .php or .exe (configurable) with almost no effort at all.
cached_model_property
Similar to django's cached_property except that it doesn't cache the value in the model instance but rather it utilize django's builtin cache feature
example: