0

When i imported os at first and write at the most bottom of settings.py

STATICFILES_DIRS =[
os.path.join(BASE_DIR, 
'static')
 ]

To run my static folder which contains test.txt But when I tried to run it on Opera it shows Page not foun 404. Please tell what Can be the issue in this Django program.

  • Does this answer your question? [django html template can't find static css and js files](https://stackoverflow.com/questions/66437690/django-html-template-cant-find-static-css-and-js-files) – Ivan Starostin May 19 '21 at 09:14

2 Answers2

0

You need to run the following command to collect static files first

python manage.py collectstatic
0

Your settings.py file must include

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/'

STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'))

After this you import static method in your urls.py file of project and then add

from django.conf.urls.static import static

urlpatterns = [ ]+ ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Aalok kumar
  • 309
  • 2
  • 5