I'm now using django 1.6
As I know, if I want to use some model classes (using ORM) I should put them under folder myapp/models.py
.
So what if I want to write some non-model classes (not using ORM), i.e. class Util
, and only contains some globally used methods, maybe date formatting or something else.
So, where should these code locate? Is there a generally used way to this case?
You can really put them anywhere you like, but I follow the pattern Django itself uses (in admin, cache, etc.) and put such things in a utils.py
file. I have one (if necessary) in each app folder, as well as one for the whole project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With