I tried few of the solutions I found with no success.
Here is the urls.py file:
urls.py
from django.contrib import admin
from django.urls import path
from django.views.generic import TemplateView
from django.conf.urls import include
admin.site.site_header = 'Marked By Covid Admin'
urlpatterns = [
path('grappelli/', include('grappelli.urls')),
path('admin/', admin.site.urls),
path('', TemplateView.as_view(template_name='index.html'), name='index'),
]
The TEMPLATES part of settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'client-app/dist')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Please let me know if anything else is needed.
I'd be grateful for your suggestions regarding what's wrong.
Thanks!
CodePudding user response:
This line in your settings tells Django where to look for templates:
'DIRS': [os.path.join(BASE_DIR, 'client-app/dist')]
The basic Django's backend for it (that you are also using), checks for the template like:
YourProject/
YourProject/
<the directory you placed in 'DIRS'>
your_app/
<the directory you placed in 'DIRS'>
your_second_app/
<the directory you placed in 'DIRS'>
By default it's 'templates'
so it's simple. You have changed it to 'client-app/dist'
, so you can put index.html i.e. here:
YourProject/
YourProject/
client-app/
dist/
index.html
It has to be in an app (that is also in INSTALLED_APPS) or in project's core folder.
CodePudding user response:
i see:
TEMPLATES = [
{
# some staff
'DIRS': [os.path.join(BASE_DIR, 'client-app/dist')], # CLIENT-APP/DIST!
# otherr staff
}
]
But your index.html
template you put in folder: CLIENT-APP/PUBLIC
:
Are you really want to do it?