Alfred Huang
Alfred Huang

Reputation: 18265

where to put non-model classes in django

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?

Upvotes: 7

Views: 1578

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49092

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.

Upvotes: 7

Related Questions