Reputation: 10765
Where would I put project based views that I've created for my django project?
For example - things like JSONResponseMixin?
I'd like to put them into a folder like my_project/views/generic/ajax.py - but I'm not sure how I would then call this within apps in my project?
Something like from my_project.views.generic.ajax import JSONResponseMixin doesn't work because it says there is no app "views"...
Upvotes: 1
Views: 2948
Reputation: 9933
In django it is probaby best to follow the django way so a project is divided into apps, apps contain there modules (models, views, urls ...), you can however create your own local/utility/contrib app, it can just be a folder with an init.py and your modules. If you want to partition it further into directories (each sub directory I believe would need it's own init.py), you would have to then include it (the apps root folder) in your INSTALLED_APPS tuple and from there should be able to (afaik) import the module as you would have done for anything else.
Edit: Just found this answer to a somewhat related question, probably worth a read
Upvotes: 1