Reputation: 2239
I have a handful of functions in some of my views that could easily be abstracted away. Looking through the Django Docs, I couldn't find much info on where is the best place to keep them.
So should it go:
1: In the view, just abstracted away into another function.
or
2: In a new module within the same Django application.
Upvotes: 0
Views: 25
Reputation: 82470
It would depend on what your views do, if they verify form data, then use django-forms
to handle the form data, and that can make your code much cleaner. You can take a look at them here.
If you do a lot of things with models, just create a django ModelManager
to handle the queries that you always do in your views.
However, if you think that there is a lot of boiler-plate code that does not fit into all of these, then why not use django CBVs to get rid of having to write boiler-plate code all over again.
It all comes down to what you want.
Upvotes: 1