Writing your first Django app, part 6
https://docs.djangoproject.com/en/3.0/intro/tutorial06/
Github Tag: https://github.com/studroid/writing-your-fisrt-django-app/commits/Part-6-Finished
참고 자료
Aside from the HTML generated by the server, web applications generally need to serve additional files — such as images, JavaScript, or CSS — necessary to render the complete web page. In Django, we refer to these files as “static files”.
Static file namespacing
Just like templates, we might be able to get away with putting our static files directly in polls/static
(rather than creating another polls
subdirectory), but it would actually be a bad idea. Django will choose the first static file it finds whose name matches, and if you had a static file with the same name in a different application, Django would be unable to distinguish between them. We need to be able to point Django at the right one, and the best way to ensure this is by namespacing them. That is, by putting those static files inside another directory named for the application itself.
{% load static %} <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">
These are the basics. For more details on settings and other bits included with the framework see the static files howto and the staticfiles reference. Deploying static files discusses how to use static files on a real server.