pycharm not inspecting imports correctly -


for directory structure below, pycharm can't seem detect import 1 file another

  • puzzle_project

    • __init__.py
    • snippets
      • __init__.py
      • models.py
      • views.py

for models.py code is:

from django.db import models pygments.lexers import get_all_lexers pygments.styles import get_all_styles  lexers = [item item in get_all_lexers() if item[1]] language_choices = sorted([(item[1][0], item[0]) item in lexers]) style_choices = sorted((item, item) item in get_all_styles())   class snippet (models.model):     created = models.datetimefield(auto_now_add=true)     title = models.charfield(max_length=100, blank=true, default='')     code = models.textfield()     linenos = models.booleanfield(default=false)     language = models.charfield(choices=language_choices, default='python', max_length=100)     style = models.charfield(choices=style_choices, default='friendly', max_length=100)      class meta:         ordering = ('created',) 

for views.py code is:

from snippets.models import snippet snippets.serializers import snippetserializer 

views.py run pycharm marks these lines unresolved refrence. when rewrite lines this:

from puzzle_project.snippets.models import snippet puzzle_project.snippets.serializers import snippetserializer 

will pycharm not declare unresolved reference. note code above not run in python.

please note using latest version of pycharm , python 3.4

how pycharm correctly inspect these lines of code?

the issue project structure in preferences. make sure root set correctly. inspector inspects code setting current working directory.

the inspector marked things wrong because if ran interpreter same directory root setting same error. fix error, either change root setting in project structure preferences pycharm or change cwd of run interpreter.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -