1👍
✅
settting.py:
STATIC_URL = '/static/'
Only one {% load static %}
is enough in your html code:
<!DOCTYPE html>
{% load static %}
You have to Copy and Plast your STATIC files (Js, CSS, …) in your templates.
It will look like that :
djangoAjaxApp
|_migrations
|_templates
| |_djangoAjaxApp
| |_css_practice.html
|_static
|___djangoAjaxApp (directory with the same App name)
|_(here all your static file)
Your HTML will look like this:
<link type="text/css" rel="stylesheet" href"{% static 'djangoAjaxApp\ok.css' %}">
views.py:
# css practice
def cssRender(request):
return render(request, "djangoAjaxApp/css_practice.html")
urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', views.cssRender, name='cssRender'),
]
djangoAjax urls.py:
from django.conf import settings
from django.contrib import admin
from django.urls import path
urlpatterns = [
# ... the rest of your URLconf goes here ...
]
0👍
Could you please try it.
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
- [Answered ]-What is correct way to send mail asynchronously in python/django?
- [Answered ]-Django ModelForm not saving data that is added to request.POST or through form.save(commit=False)
- [Answered ]-Django-piston: Difference between returning a queryset and a list?
- [Answered ]-Two (Almost) Identical View.py Functions Behaving Differently
0👍
Just to remind you of it, have you tried hard refresh on your browser? I used to miss this when I was a beginner. (You can do it in chrome with ctrl+shift+r).
- [Answered ]-Django Filter Query Solution
- [Answered ]-Django : Automatically add user to group with signals
Source:stackexchange.com