I'm sure this is an issue on my end but I can't figure out why Django is throwing an ImportError for _db_filestorage.urls within my application's main urlpatterns (MyApp/urls.py). I've followed the configuration setup from here https://django-db-file-storage.readthedocs.io/en/master/ and I have the rest of the setup complete, I just can't seem to get past this Import issue.
When testing using the Django shell from CLI I am able to import 'db_file_storage.urls' fine and inspect the object. It's only when accessing the application from the browser does the Import fail to resolve and throws an error. I also tested importing _db_filestorage at the top of my urls.py which was successful. Any attempts to include urls from _db_filestorage resulted in the same Import error.
ImportError at /
No module named 'db_file_storage.urls'
Request Method: | GET
Request URL: https://myapp.internalsite.com/
Django Version: 2.0.1
Exception Type: ImportError
Exception Value: No module named 'db_file_storage.urls'
Exception Location: <frozen importlib._bootstrap> in _find_and_load_unlocked, line 2224
Python Executable /usr/bin/python3
Python Version: 3.4.9
Python Path: ['/opt/MyProject',
'/opt/virtual-env/lib64/python34.zip',
'/opt/virtual-env/lib64/python3.4',
'/opt/virtual-env/lib64/python3.4/plat-linux',
'/opt/virtual-env/lib64/python3.4/lib-dynload',
'/usr/lib64/python3.4',
'/usr/lib/python3.4',
'/opt/virtual-env/lib/python3.4/site-packages']
urls.py (version 1) - throws ImportError: No module named 'db_file_storage.urls'
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('', include('reports.urls')),
path('admin/', admin.site.urls),
path('findings/', include('findings.urls')),
path('reports/',include('reports.urls')),
path('accounts/', include('django.contrib.auth.urls')),
path('files/', include('db_file_storage.urls')),
] + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urls.py (version 2) - Commented out the offending line and included an import of db_file_storage. Throws no errors, but doesn't include the necessary urls for db_file_storage
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
import db_file_storage
urlpatterns = [
path('', include('reports.urls')),
path('admin/', admin.site.urls),
path('findings/', include('findings.urls')),
path('reports/',include('reports.urls')),
path('accounts/', include('django.contrib.auth.urls')),
# path('files/', include('db_file_storage.urls')),
] + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Description
I'm sure this is an issue on my end but I can't figure out why Django is throwing an ImportError for _db_filestorage.urls within my application's main urlpatterns (MyApp/urls.py). I've followed the configuration setup from here https://django-db-file-storage.readthedocs.io/en/master/ and I have the rest of the setup complete, I just can't seem to get past this Import issue.
When testing using the Django shell from CLI I am able to import 'db_file_storage.urls' fine and inspect the object. It's only when accessing the application from the browser does the Import fail to resolve and throws an error. I also tested importing _db_filestorage at the top of my urls.py which was successful. Any attempts to include urls from _db_filestorage resulted in the same Import error.
Environment
Browser Error
urls.py (version 1) - throws ImportError: No module named 'db_file_storage.urls'
urls.py (version 2) - Commented out the offending line and included an import of db_file_storage. Throws no errors, but doesn't include the necessary urls for db_file_storage
settings.py
httpd.conf - relevant configuration