Problem in the Django tutorial?

39 views
Skip to first unread message

Alesh Houdek

unread,
Aug 21, 2018, 8:01:41 AM8/21/18
to Django users
I'm doing the Django tutorial and got stuck on the static files section: https://docs.djangoproject.com/en/2.1/intro/tutorial06/#customize-your-app-s-look-and-feel 

Could not get the style.css file to work despite triple-checking everything. 

After much research, I got it to work by adding this to settings.py:

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

Daniel Hepper

unread,
Aug 21, 2018, 8:10:10 AM8/21/18
to django...@googlegroups.com
That shouldn't be necessary, as the tutorial has you put the CSS file into the static directory in your polls app, not your project. Static files in your polls app should be found with the default settings:

Django’s STATICFILES_FINDERS setting contains a list of finders that know how to discover static files from various sources. One of the defaults is AppDirectoriesFinder which looks for a “static” subdirectory in each of the INSTALLED_APPS, like the one in polls we just created. The admin site uses the same directory structure for its static files.

My guess is that you put your CSS file at static/polls/style.css (relative to BASE_DIR) instead of polls/static/polls/style.css

Hope that helps,
Daniel


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f5e58b12-a8d2-4ad2-983b-856895a91eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages