3

I have a jQuery/CSS/html webpage. I wanted to add some backend with Python/Django. I put that page (index.html) + all dependent css and js files into the templates folder (inside the Django project folder). I added the address to that page to the urls.py file and models.py file. When I run the server and try to access that page, it displays but without css styles and javascript code. So, it seems like it misses taking css and js files from that html webpage. What's wrong? What I've missed?

2 Answers 2

3

With Django, the static files are separated from the main web page templates. See the documentation on static files for more information.

Sign up to request clarification or add additional context in comments.

Comments

1

Use {% static %} method with every CSS and JS reference.

If href = "stackoverflow.jpeg" then adjust your code as follows :

href = "{% static 'stackoverflow.jpeg'%}"

Do the same with every piece of JS and CSS code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.