0

the picture

i am new user django-pycharm and i want to create a html/css template in the pycharm. my proplem is in the pycharm i cant to connect html file with css file. if i run that files with the classic way out of the pycharm its ok but i cant to connect in the program.

my connect line in the txt files

link href="templatemo_style.css" rel="stylesheet" type="text/css" />
3
  • your css and html file should be at same directory Commented Jan 3, 2016 at 20:35
  • This problem does not have anything to do with the programming language compiler. when you just type a file name in HTML, that file should be at the same directory as you html file... if you want to set another directory you can type full address or a tree mode address like css/file.css or ../file.css .... read more about rules Commented Jan 3, 2016 at 20:52
  • That is just not even vaguely true. The "HTML file" here is a Django template, which is rendered by a web framework; it is not served by the same means as the CSS file. Commented Jan 3, 2016 at 21:01

5 Answers 5

2

You need to put your static files inside the static directory inside your app. Then you should be able to access them using {{ STATIC_URL }} in your template.

Django Templating is a little different than usual HTML/CSS. You need to put some efforts into learning how the template works and how the static files are served.

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

Comments

2

in django, you need to set up things a little bit, so that django (in local machine) or your web server (if you deploy the code to production) will find and render the static files (they are: css, images and js files) correctly.

here you read how you set it up first in django itself.

at the end, you will have something like this in your html file:

{% load staticfiles %}


<link href="{% static 'css/templatemo_style.css' %}" rel="stylesheet" type="text/css" />

so, your static files dont live directly in the same folder where html files live, but in their own folders, I normally call them site-static.

and here how you set up PyCharm with Django by the way :) http://www.django-tips.com/tip/how-to-setup-pycharm-for-django/31/

Comments

0

There is a type there. The css link says: "templatemo" and the file is called "templatermo".

Comments

0

your html code is wrong

<link rel="stylesheet" href="templatermo_style.css">

also check file name, your css file's name is templatermo_style.css not templatemo_style.css

I recommend you to use static files instead of usual way, check other answers

Comments

0

So what I found to work is...

So basically what I did was I manually typed up until I got to the href link and then pressed control+spacebar and it automatically brought up my style.css link for me and did the directory itself. Maybe that would work.

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.