File not found when adding a new app

Hello

I have added a new app Verge3D to my First app

Main urls.py

path('verge3D/',include('verge3D.urls')),

In my urls.py / Verge3D app :

urlpatterns = [
    path('home3D',views.myFirst3D,name="home3D"),
]

In my views.py / Verge 3D app

def myFirst3D(request):
    print("on y est")
    return render(request,'3Dfiles/earth.html')

The problem is :

Django searches this 3Dfiles/earth.html still in my first app location (it works when I create this directory/files in my fist app Templates directory)

Did you add your new app to the INSTALLED_APPS setting? What does your TEMPLATES setting look like?

Yes the new app was intalled in setting.py

For the templates variable, as I have APP_DIRS’: True I thought Django checks in every templates app folder.

TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': [],

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [

                'django.template.context_processors.debug',

                'django.template.context_processors.request',

                'django.contrib.auth.context_processors.auth',

                'django.contrib.messages.context_processors.messages',

            ],

        },

    },

]

It does, if the app is installed in INSTALLED_APPS and APP_DIRS == True. (Which you have in both cases.)

So you have a directory named verge3D/templates/3Dfiles, where verge3D is your new app, and that directory has earth.html in it? What does your project directory structure look like?

Here is a screenshot. The main project is zer0day with this structure in setting.py

INSTALLED_APPS = [

    'django.contrib.admin',

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.messages',

    'django.contrib.staticfiles',

    'events',

    'members',

    'verge3D',

    'crispy_forms',

]

Just one more thing to confirm - in your verge3D/templates directory, you have a directory named 3Dfiles with the earth.html in it?

If you don’t have earth.html in your events/templates/3Dfiles directory, you mention an error. Can you post that complete error? (Specifically, near the top of the error there should be output showing the directories being searched.)

Yes the earth.html page is located inside verge3D/templates/3Dfiles
Which is strange as it works for the 2 others app

Here is the message log

So in the Template-loader postmortem section, it’s showing you the directories that it’s searching. The one you’re asking about is the next-to-last entry. Django is looking in the right location. There’s no Django-based-reason why it shouldn’t be able to find it. Usually then the problem ends up being a typo in the file name or incorrect file permissions or (in the case of a Unix-style system) a reference to a file with the wrong upper or lower case in the name.

I have created a new app without “3D” inside and it works

Don’t ask me why

:thinking: