mikeckennedy / python-for-entrepreneurs-course-demos

Contains all the "handout" materials for Talk Python's Python for Entrepreneurs course. This includes notes and the final version of the website code.
https://training.talkpython.fm/courses/explore_entrepreneurs/python-for-entrepreneurs-build-and-launch-your-online-business
MIT License
286 stars 141 forks source link

Cannot resolve directory 'static' in PyCharm Professional #27

Closed jaylaw closed 7 years ago

jaylaw commented 7 years ago

I am having a problem with PyCharm using relative imports in my template files. I have found resources that provide solutions for a Django project. I have not been able to find anything specific about Pyramid projects. It would be helpful if I could see affected css tags when highlighting in the template as I see in your videos.

mikeckennedy commented 7 years ago

Hi Jay,

There is probably something like this:

<link href="${request.static_url('packagename:static/theme.css')}" rel="stylesheet">

This is basically useless but often causes trouble. Just put this instead:

<link href="/static/theme.css" rel="stylesheet">

jaylaw commented 7 years ago

Thanks! That seemed to work. PyCharm still highlights the as unresolved, but I have the breadcrumbs, at least. If I climb up one directory:

<link href="../static/theme.css" rel="stylesheet">

the warning goes away.

image

mikeckennedy commented 7 years ago

Yeah, that's annoying that it does that. To fix the missing static files, right click on the folder containing static, and choose mark directory as "resources root". Then it will find them.

jaylaw commented 7 years ago

That did it! Thanks a lot! I really appreciate the work you put into your podcast and courses. They have taught me a lot.

mikeckennedy commented 7 years ago

Great and you're welcome Jay!