Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django views in project directory

I have a project with two apps with their respective views, but I want to create a views.py in django project directory for some generic pages such as about, login... It is correct to place the views.py and templates in the root project folder for this purpose?

like image 644
Adrián Álvarez Sáez Avatar asked Dec 01 '16 15:12

Adrián Álvarez Sáez


1 Answers

I have been reading about this. The practice more recommended for this is create an app that creates cohesion between other apps, call it web_site or site whatever is better for you.

python manage.py startapp my_site 

Everything in this site app will be done the regular way. In the projects url you will want to import the url in this way so the web pages appear in the / url pattern.

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('my_site.urls'))
]
like image 126
jogarcia Avatar answered Oct 02 '22 00:10

jogarcia