I'm struggling with Django's view directory structure.

28 views
Skip to first unread message

片岡一平

unread,
Jan 7, 2020, 8:29:42 PM1/7/20
to Django users
Hi, 

I'm struggling with Django's view directory structure.
Now, I am creating an app with the following URL structure.


domain / app / page_category1 / action1
domain / app / page_category1 / action2
...
domain / app / page_categoryN / actionM


In this case, how should the Django view directory be constructed?

Thanks for watching.
I'm glad if you get some advice.

Kataoka

Scot Hacker

unread,
Jan 9, 2020, 2:22:25 AM1/9/20
to Django users
That is entirely up to you. The typical scenario is that you have one views module per app in your project, which would live at your `yourapp/views.py`. If your app has lots of views and you want to keep it from getting too large, another common pattern is to have one module per view in a directory, like: `yourapp/views/action1.py` and `yourapp/views/action2.py`. How are you organize it is up to you - you have control over your own Python imports. Really just a matter of housekeeping…

./s
Reply all
Reply to author
Forward
0 new messages