Unresolved Libraries in Templates - PyCharm & Django 2.2
iamcb opened this issue · 3 comments
Following the Tutorial and creating the settings package or settings.py file and importing INSTALLED_APPS causes PyCharm to complain about unresolved libraries in HTML file.
ex: {% load staticfiles %} will give an unresolved library error
This Could be a PyCharm Issue as, as everything still runs without issue with "runserver" command.
Which file are you talking about?
Doing this creates the error in all HTML templates.
"""
project/project/settings/__init__.py
"""
import os
from split_settings.tools import include # optional
ENV = os.environ.get('DJANGO_ENV') or 'development'
base_settings = [
'common.py', # standard django settings - including INSTALLED_APPS
'database.py', # postgres
'logging.py', # logging settings
'app_settings.py', # app specific settings
# 'rq.py', # redis and redis-queue
# 'emails.py', # SMTP
# Select the right env:
'environments/%s.py' % ENV,
# Optionally override some settings:
# optional('environments/local.py'),
]
# Include settings:
include(*base_settings)
I've had to do this to make PyCharm not complain. sorry for the edits:
"""
project/project/settings/settings.py
"""
import os
from split_settings.tools import include # optional
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
ENV = os.environ.get('DJANGO_ENV') or 'development'
additional_settings = [
'database.py', # postgres
'logging.py', # logging settings
# 'rq.py', # redis and redis-queue
# 'emails.py', # SMTP
# Select the right env:
'environments/%s.py' % ENV,
# Optionally override some settings:
# optional('environments/local.py'),
]
# Include settings:
include(*additional_settings)
SITE_ID = 1
ROOT_URLCONF = 'rwe_website.urls'
INSTALLED_APPS = [
# All Django plugins and system wide apps:
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django_extensions',
'sslserver',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'django_select2',
# All User created apps
'core',
'user_profile',
'tsheets_auth',
'tsheets_api',
'tsheets_jobnotes',
]
.... the rest of the setting file....
So i figured it out, at least sort of and things work now with PyCharm.
PyCharm does not like that INSTALLED_APPS setting gets imported, and will fail to figure out where all the tags are for the templates. In Preferences->Languages&Frameworks->Django make sure the settings file you point to has INSTALLED_APPS in it, and PyCharm is copasetic.
This does seem to break the "run manage.py" command in the tools menu, but its a small price to pay, and everything still works from the command line with "python manage.py".
This issue is with PyCharm and not with Django-split-settings so I'm closing the issue.