Wednesday, December 18, 2019

Re: Static files configuration

Hey, try this:

In settings:

# If running collectstatic
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# make sure if you have multiple apps that you want to direct to specific location of static files
STATIC_DIRS = (
    os.path.join(BASE_DIR, '../apps/core/static'),
)

Finally if you're using Django 2.0+

In the html file:
{% load static %} 


On Wed, Dec 18, 2019, 5:07 AM Yash Garg <gargyash512@gmail.com> wrote:
I have to display a HTML page with its supporting css, js and images. So i create a template folder to put HTML in it then i create a static folder in which i create css, js and img folder and put related files into these folders.
then I configure the
Settings.py

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

MEDIA_URL = '/media/'

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

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


.html file 

{% load staticfiles %}
<link href="{% static 'css/style.css' %}" rel="stylesheet">

views.py

def Index(request):
return render(request,'Teenager Startup.html')

please help me where i'm not getting the point.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68f02a87-1876-4d81-9cf7-daba5f9079ca%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANips4KMEPxo-3P6-9L_q7s2mhgBRoMu5jJUj3c4a%2Be3FofLrw%40mail.gmail.com.

No comments:

Post a Comment