Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the urls.py file not created automatically?

Tags:

django

Almost every video which I saw about Django (for beginners), people who create applications using the startapp command and add their urls.py file manually in their application. My question is, if urls.py is so important for views and for our app why it's not creating automatically when we run startapp command!

like image 505
ITguy Avatar asked Dec 14 '22 09:12

ITguy


2 Answers

Not every app directly serves the end user

URLs.py is only useful for routing users to pages which primarily have to do with that app. However, many apps may only do internal things. I have an app in one of my projects that handles badges and rewards, but there is no page which corresponds to any of that because it all shows exclusively as part of the profile pages (and the routing is handled within the profile app).

It just isn't always needed and that is why it is not always included.

like image 185
Matthew Gaiser Avatar answered Jan 07 '23 06:01

Matthew Gaiser


Simply you don't have to serve each of your app to the end-users. You may have apps responsible for only your inner interactions. So it is not logical to put urls.py in each and every app.

like image 34
engin_ipek Avatar answered Jan 07 '23 04:01

engin_ipek